2012-11-18 23:19:42 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
def uploaded_file(path, type)
|
|
|
|
ActionDispatch::Http::UploadedFile.new(
|
|
|
|
:filename => File.basename(path),
|
|
|
|
:tempfile => File.open(path),
|
|
|
|
:type => type
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2012-11-21 22:53:48 +00:00
|
|
|
describe 'Asciicast', :type => :feature, :js => true 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"
|
|
|
|
)
|
2012-11-18 23:37:25 +00:00
|
|
|
)
|
2012-11-21 22:53:48 +00:00
|
|
|
end
|
2012-11-18 23:19:42 +00:00
|
|
|
|
2012-11-21 22:53:48 +00:00
|
|
|
def visit_asciicast(id)
|
|
|
|
asciicast = load_asciicast(id)
|
|
|
|
visit "/a/#{asciicast.id}/raw?speed=2"
|
|
|
|
end
|
2012-11-20 17:47:22 +00:00
|
|
|
|
2012-11-21 22:53:48 +00:00
|
|
|
def inject_on_finished_callback
|
|
|
|
page.execute_script(<<EOS)
|
|
|
|
window.player.movie.on('finished', function() {
|
|
|
|
$('body').append('<span class=\"finished\"></span>');
|
|
|
|
})
|
2012-11-20 17:47:22 +00:00
|
|
|
EOS
|
2012-11-21 22:53:48 +00:00
|
|
|
end
|
2012-11-18 23:19:42 +00:00
|
|
|
|
|
|
|
Dir['spec/fixtures/asciicasts/*'].each do |dir|
|
|
|
|
id = dir[/\d+/]
|
|
|
|
|
|
|
|
describe "from fixture #{id}" do
|
|
|
|
it "successfully plays to the end" do
|
|
|
|
visit_asciicast(id)
|
|
|
|
find(".play-button").find(".arrow").click
|
2012-11-20 17:47:22 +00:00
|
|
|
inject_on_finished_callback
|
|
|
|
page.should have_selector('body .finished')
|
2012-11-18 23:19:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|