Add missing feature specs

openid
Marcin Kulik 12 years ago
parent 62a3ffed92
commit 61ac829715

@ -12,6 +12,7 @@ FactoryGirl.define do
terminal_lines 25
shell "/bin/bash"
uname "uname"
views_count 1
stdout do
fixture_file_upload("spec/fixtures/stdout", "application/octet-stream")
end

@ -0,0 +1,18 @@
require 'spec_helper'
feature "Asciicast page", :js => true do
let(:asciicast) { load_asciicast(1) }
scenario 'Visiting as guest' do
visit asciicast_path(asciicast)
expect(page).to have_content('Recorded')
expect(page).to have_content('Viewed')
expect(page).to have_content('OS')
expect(page).to have_content('SHELL')
expect(page).to have_content('TERM')
expect(page).to have_selector('.play-button')
end
end

@ -1,66 +1,25 @@
require 'spec_helper'
def uploaded_file(path, type)
ActionDispatch::Http::UploadedFile.new(
:filename => File.basename(path),
:tempfile => File.open(path),
:type => type
)
end
describe 'Asciicast playback', :type => :feature, :js => true do
feature "Asciicast lists" do
def load_asciicast(id)
FactoryGirl.create(
:asciicast,
:meta => uploaded_file(
"spec/fixtures/asciicasts/#{id}/meta.json",
'application/json'
),
:stdout => fixture_file_upload(
"spec/fixtures/asciicasts/#{id}/stdout",
"application/octet-stream"
),
:stdout_timing => fixture_file_upload(
"spec/fixtures/asciicasts/#{id}/stdout.time",
"application/octet-stream"
)
)
end
let!(:asciicast) { load_asciicast(1) }
def visit_asciicast(id)
asciicast = load_asciicast(id)
visit "/a/#{asciicast.id}/raw?speed=5"
end
scenario 'Visiting all' do
visit browse_path
def inject_on_finished_callback
page.execute_script(<<EOS)
window.player.movie.on('finished', function() {
$('body').append('<span class=\"finished\"></span>');
})
EOS
expect(page).to have_content(/All Asciicasts/i)
expect_browse_section
expect(page).to have_link("##{asciicast.id}")
expect(page).to have_selector('.supplimental .play-button')
end
Dir['spec/fixtures/asciicasts/*'].each do |dir|
id = dir[/\d+/]
describe "from fixture #{id}" do
before do
@old_wait_time = Capybara.default_wait_time
Capybara.default_wait_time = 120
end
after do
Capybara.default_wait_time = @old_wait_time
end
scenario 'Visiting popular' do
visit popular_path
it "is successful" do
visit_asciicast(id)
find(".play-button").find(".arrow").click
inject_on_finished_callback
page.should have_selector('body .finished')
end
end
expect(page).to have_content(/Popular Asciicasts/i)
expect_browse_section
expect(page).to have_link("##{asciicast.id}")
expect(page).to have_selector('.supplimental .play-button')
end
end

@ -0,0 +1,19 @@
require 'spec_helper'
feature "Homepage", :js => true do
let!(:asciicast) { load_asciicast(1) }
scenario 'Visiting' do
visit root_path
expect(page).to have_content(/Recent Asciicasts/i)
page.save_screenshot 'a.png'
expect(page).to have_link('Browse')
expect(page).to have_link('Record')
expect_browse_section
expect(page).to have_link("##{asciicast.id}")
expect(page).to have_selector('#about .play-button')
end
end

@ -0,0 +1,40 @@
require 'spec_helper'
describe 'Asciicast playback', :js => true, :slow => true do
def visit_asciicast(id)
asciicast = load_asciicast(id)
visit "/a/#{asciicast.id}/raw?speed=5"
end
def inject_on_finished_callback
page.execute_script(<<EOS)
window.player.movie.on('finished', function() {
$('body').append('<span class=\"finished\"></span>');
})
EOS
end
Dir['spec/fixtures/asciicasts/*'].each do |dir|
id = dir[/\d+/]
describe "from fixture #{id}" do
before do
@old_wait_time = Capybara.default_wait_time
Capybara.default_wait_time = 120
end
after do
Capybara.default_wait_time = @old_wait_time
end
it "is successful" do
visit_asciicast(id)
find(".play-button").find(".arrow").click
inject_on_finished_callback
page.should have_selector('body .finished')
end
end
end
end

@ -27,6 +27,7 @@ RSpec.configure do |config|
config.infer_base_class_for_anonymous_controllers = false
config.include FactoryGirl::Syntax::Methods
config.include AsciiIo::FeatureHelpers
config.include AsciiIo::ControllerMacros, :type => :controller
config.before(:suite) do

@ -0,0 +1,43 @@
module AsciiIo
module FeatureHelpers
def uploaded_file(path, type)
ActionDispatch::Http::UploadedFile.new(
:filename => File.basename(path),
:tempfile => File.open(path),
:type => type
)
end
def load_asciicast(id)
FactoryGirl.create(
:asciicast,
:meta => uploaded_file(
"spec/fixtures/asciicasts/#{id}/meta.json",
'application/json'
),
:stdout => fixture_file_upload(
"spec/fixtures/asciicasts/#{id}/stdout",
"application/octet-stream"
),
:stdout_timing => fixture_file_upload(
"spec/fixtures/asciicasts/#{id}/stdout.time",
"application/octet-stream"
)
)
end
def load_all_asciicasts
Dir['spec/fixtures/asciicasts/*'].each do |dir|
id = dir[/\d+/]
load_asciicast(id)
end
end
def expect_browse_section
expect(page).to have_link('All')
expect(page).to have_link('Popular')
end
end
end
Loading…
Cancel
Save