diff --git a/spec/features/asciicasts_spec.rb b/spec/features/asciicasts_spec.rb index 4d48227..bad18cd 100644 --- a/spec/features/asciicasts_spec.rb +++ b/spec/features/asciicasts_spec.rb @@ -2,14 +2,14 @@ require 'spec_helper' feature "Asciicast lists" do - let!(:asciicast) { load_asciicast(1) } + let!(:asciicast) { create(:asciicast) } scenario 'Visiting all' do visit browse_path expect(page).to have_content(/All Asciicasts/i) expect_browse_links - expect(page).to have_link("##{asciicast.id}") + expect(page).to have_link("bashing") expect(page).to have_selector('.supplimental .play-button') end @@ -19,7 +19,7 @@ feature "Asciicast lists" do expect(page).to have_content(/Popular Asciicasts/i) expect_browse_links - expect(page).to have_link("##{asciicast.id}") + expect(page).to have_link("bashing") expect(page).to have_selector('.supplimental .play-button') end diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index 5a0ebcc..1da32b5 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -2,16 +2,17 @@ require 'spec_helper' feature "Homepage", :js => true do - let!(:asciicast) { load_asciicast(1) } + let!(:user) { create(:user) } + let!(:asciicast) { create(:asciicast, :user => user) } scenario 'Visiting' do visit root_path - expect(page).to have_content(/Recent Asciicasts/i) expect(page).to have_link('Browse') - expect(page).to have_link('Record') + expect(page).to have_link('Docs') expect_browse_links - expect(page).to have_link("##{asciicast.id}") + expect(page).to have_content(/Recent Asciicasts/i) + expect(page).to have_link("bashing") expect(page).to have_selector('#about .play-button') end diff --git a/spec/features/playback_spec.rb b/spec/features/playback_spec.rb index 6e21c75..ce4f912 100644 --- a/spec/features/playback_spec.rb +++ b/spec/features/playback_spec.rb @@ -2,38 +2,31 @@ 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 + let(:asciicast) { create(:asciicast) } - def inject_on_finished_callback - page.execute_script(<'); - }) + describe "from fixture" do + def inject_on_finished_callback + page.execute_script(<'); + }) EOS - end + end - Dir['spec/fixtures/asciicasts/*'].each do |dir| - id = dir[/\d+/] + before do + @old_wait_time = Capybara.default_wait_time + Capybara.default_wait_time = 120 + end - 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 - 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 + it "is successful" do + visit asciicast_path(asciicast, speed: 5) + find(".play-button").find(".arrow").click + inject_on_finished_callback + page.should have_selector('body .finished') end end diff --git a/spec/fixtures/asciicasts/1/meta.json b/spec/fixtures/asciicasts/1/meta.json deleted file mode 100644 index a8a9748..0000000 --- a/spec/fixtures/asciicasts/1/meta.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "command": null, - "duration": 5.914434194564819, - "recorded_at": "Sun, 04 Mar 2012 16:43:52 +0000", - "shell": "/bin/zsh", - "term": { - "columns": 89, - "lines": 27, - "type": "rxvt-unicode-256color" - }, - "title": null, - "uname": "Linux 3.2.6-3.fc16.x86_64 #1 SMP Mon Feb 13 20:35:42 UTC 2012 x86_64", - "user_token": "2b4b4e02-6613-11e1-9be5-00215c6bbb11" -} diff --git a/spec/fixtures/asciicasts/1/stdout b/spec/fixtures/asciicasts/1/stdout deleted file mode 100644 index d5e8e81..0000000 Binary files a/spec/fixtures/asciicasts/1/stdout and /dev/null differ diff --git a/spec/fixtures/asciicasts/1/stdout.time b/spec/fixtures/asciicasts/1/stdout.time deleted file mode 100644 index e86c9c2..0000000 Binary files a/spec/fixtures/asciicasts/1/stdout.time and /dev/null differ diff --git a/spec/fixtures/asciicasts/10/meta.json b/spec/fixtures/asciicasts/10/meta.json deleted file mode 100644 index c33dbe8..0000000 --- a/spec/fixtures/asciicasts/10/meta.json +++ /dev/null @@ -1 +0,0 @@ -{"duration":19.3045,"term":{"columns":89,"lines":27}} \ No newline at end of file diff --git a/spec/fixtures/asciicasts/10/stdout b/spec/fixtures/asciicasts/10/stdout deleted file mode 100644 index 07e2e35..0000000 Binary files a/spec/fixtures/asciicasts/10/stdout and /dev/null differ diff --git a/spec/fixtures/asciicasts/10/stdout.time b/spec/fixtures/asciicasts/10/stdout.time deleted file mode 100644 index ad2aa8b..0000000 Binary files a/spec/fixtures/asciicasts/10/stdout.time and /dev/null differ diff --git a/spec/fixtures/asciicasts/15/meta.json b/spec/fixtures/asciicasts/15/meta.json deleted file mode 100644 index e3cafaa..0000000 --- a/spec/fixtures/asciicasts/15/meta.json +++ /dev/null @@ -1 +0,0 @@ -{"duration":260.875012,"term":{"columns":107,"lines":29}} \ No newline at end of file diff --git a/spec/fixtures/asciicasts/15/stdout b/spec/fixtures/asciicasts/15/stdout deleted file mode 100644 index 7130175..0000000 Binary files a/spec/fixtures/asciicasts/15/stdout and /dev/null differ diff --git a/spec/fixtures/asciicasts/15/stdout.time b/spec/fixtures/asciicasts/15/stdout.time deleted file mode 100644 index 0249358..0000000 Binary files a/spec/fixtures/asciicasts/15/stdout.time and /dev/null differ diff --git a/spec/fixtures/asciicasts/190/meta.json b/spec/fixtures/asciicasts/190/meta.json deleted file mode 100644 index 898b731..0000000 --- a/spec/fixtures/asciicasts/190/meta.json +++ /dev/null @@ -1 +0,0 @@ -{"duration":426.9083879999997,"term":{"columns":119,"lines":39}} \ No newline at end of file diff --git a/spec/fixtures/asciicasts/190/stdout b/spec/fixtures/asciicasts/190/stdout deleted file mode 100644 index bc21701..0000000 Binary files a/spec/fixtures/asciicasts/190/stdout and /dev/null differ diff --git a/spec/fixtures/asciicasts/190/stdout.time b/spec/fixtures/asciicasts/190/stdout.time deleted file mode 100644 index 8fc2c66..0000000 Binary files a/spec/fixtures/asciicasts/190/stdout.time and /dev/null differ diff --git a/spec/fixtures/asciicasts/3/meta.json b/spec/fixtures/asciicasts/3/meta.json deleted file mode 100644 index 11d95a5..0000000 --- a/spec/fixtures/asciicasts/3/meta.json +++ /dev/null @@ -1 +0,0 @@ -{"duration":64.2345,"term":{"columns":80,"lines":27}} \ No newline at end of file diff --git a/spec/fixtures/asciicasts/3/stdout b/spec/fixtures/asciicasts/3/stdout deleted file mode 100644 index 5b05343..0000000 Binary files a/spec/fixtures/asciicasts/3/stdout and /dev/null differ diff --git a/spec/fixtures/asciicasts/3/stdout.time b/spec/fixtures/asciicasts/3/stdout.time deleted file mode 100644 index 738454f..0000000 Binary files a/spec/fixtures/asciicasts/3/stdout.time and /dev/null differ diff --git a/spec/fixtures/asciicasts/354/meta.json b/spec/fixtures/asciicasts/354/meta.json deleted file mode 100644 index 7a86711..0000000 --- a/spec/fixtures/asciicasts/354/meta.json +++ /dev/null @@ -1 +0,0 @@ -{"duration":57.8766,"term":{"columns":102,"lines":30}} \ No newline at end of file diff --git a/spec/fixtures/asciicasts/354/stdout b/spec/fixtures/asciicasts/354/stdout deleted file mode 100644 index 30c1be1..0000000 Binary files a/spec/fixtures/asciicasts/354/stdout and /dev/null differ diff --git a/spec/fixtures/asciicasts/354/stdout.time b/spec/fixtures/asciicasts/354/stdout.time deleted file mode 100644 index ba0f54b..0000000 Binary files a/spec/fixtures/asciicasts/354/stdout.time and /dev/null differ diff --git a/spec/fixtures/asciicasts/7/meta.json b/spec/fixtures/asciicasts/7/meta.json deleted file mode 100644 index 68892e3..0000000 --- a/spec/fixtures/asciicasts/7/meta.json +++ /dev/null @@ -1 +0,0 @@ -{"duration":38.238195,"term":{"columns":98,"lines":27}} \ No newline at end of file diff --git a/spec/fixtures/asciicasts/7/stdout b/spec/fixtures/asciicasts/7/stdout deleted file mode 100644 index 894ddad..0000000 Binary files a/spec/fixtures/asciicasts/7/stdout and /dev/null differ diff --git a/spec/fixtures/asciicasts/7/stdout.time b/spec/fixtures/asciicasts/7/stdout.time deleted file mode 100644 index b197507..0000000 Binary files a/spec/fixtures/asciicasts/7/stdout.time and /dev/null differ diff --git a/spec/fixtures/asciicasts/8/meta.json b/spec/fixtures/asciicasts/8/meta.json deleted file mode 100644 index f73dba0..0000000 --- a/spec/fixtures/asciicasts/8/meta.json +++ /dev/null @@ -1 +0,0 @@ -{"duration":170.28530999999998,"term":{"columns":89,"lines":27}} \ No newline at end of file diff --git a/spec/fixtures/asciicasts/8/stdout b/spec/fixtures/asciicasts/8/stdout deleted file mode 100644 index 813a46d..0000000 Binary files a/spec/fixtures/asciicasts/8/stdout and /dev/null differ diff --git a/spec/fixtures/asciicasts/8/stdout.time b/spec/fixtures/asciicasts/8/stdout.time deleted file mode 100644 index c68eb01..0000000 Binary files a/spec/fixtures/asciicasts/8/stdout.time and /dev/null differ diff --git a/spec/fixtures/asciicasts/9/meta.json b/spec/fixtures/asciicasts/9/meta.json deleted file mode 100644 index 3dbcf71..0000000 --- a/spec/fixtures/asciicasts/9/meta.json +++ /dev/null @@ -1 +0,0 @@ -{"duration":112.36874,"term":{"columns":89,"lines":27}} \ No newline at end of file diff --git a/spec/fixtures/asciicasts/9/stdout b/spec/fixtures/asciicasts/9/stdout deleted file mode 100644 index c311dd3..0000000 Binary files a/spec/fixtures/asciicasts/9/stdout and /dev/null differ diff --git a/spec/fixtures/asciicasts/9/stdout.time b/spec/fixtures/asciicasts/9/stdout.time deleted file mode 100644 index 7b649d1..0000000 Binary files a/spec/fixtures/asciicasts/9/stdout.time and /dev/null differ diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index e265809..e932c1c 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -1,38 +1,6 @@ module Asciinema 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) - AsciicastCreator.new.create( - :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_links expect(page).to have_link('All') expect(page).to have_link('Popular')