site_prism.vcr 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +12 -0
  5. data/Gemfile +17 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +381 -0
  8. data/Rakefile +1 -0
  9. data/TODO.md +71 -0
  10. data/lib/site_prism.vcr.rb +1 -0
  11. data/lib/site_prism_vcr/applier.rb +54 -0
  12. data/lib/site_prism_vcr/dsl/adjuster.rb +82 -0
  13. data/lib/site_prism_vcr/dsl/initial_adjuster.rb +97 -0
  14. data/lib/site_prism_vcr/element.rb +18 -0
  15. data/lib/site_prism_vcr/fixture.rb +29 -0
  16. data/lib/site_prism_vcr/fixtures/converter.rb +17 -0
  17. data/lib/site_prism_vcr/fixtures/handler.rb +31 -0
  18. data/lib/site_prism_vcr/fixtures/manager.rb +38 -0
  19. data/lib/site_prism_vcr/fixtures/modifiers/home_path.rb +27 -0
  20. data/lib/site_prism_vcr/fixtures/modifiers/path.rb +30 -0
  21. data/lib/site_prism_vcr/fixtures/tmp_keeper.rb +21 -0
  22. data/lib/site_prism_vcr/fixtures.rb +41 -0
  23. data/lib/site_prism_vcr/options.rb +22 -0
  24. data/lib/site_prism_vcr/options_with_path.rb +7 -0
  25. data/lib/site_prism_vcr/patches/element_container.rb +15 -0
  26. data/lib/site_prism_vcr/patches/page.rb +41 -0
  27. data/lib/site_prism_vcr/vcr_helpers.rb +18 -0
  28. data/lib/site_prism_vcr/version.rb +3 -0
  29. data/lib/site_prism_vcr/waiter.rb +23 -0
  30. data/lib/site_prism_vcr.rb +24 -0
  31. data/site_prism.vcr.gemspec +24 -0
  32. data/spec/fixtures/arya_stark.yml +44 -0
  33. data/spec/fixtures/custom/blank.yml +44 -0
  34. data/spec/fixtures/custom/bran_stark.yml +44 -0
  35. data/spec/fixtures/custom/daenerys_targaryen.yml +44 -0
  36. data/spec/fixtures/jon_snow.yml +44 -0
  37. data/spec/fixtures/ned_stark.yml +44 -0
  38. data/spec/fixtures/robb_stark.yml +44 -0
  39. data/spec/integration/http_interactions_on_even/click_spec.rb +75 -0
  40. data/spec/integration/immediate_http_interactions/page_load_on_click_spec.rb +18 -0
  41. data/spec/integration/immediate_http_interactions/page_load_spec.rb +56 -0
  42. data/spec/spec_helper.rb +18 -0
  43. data/spec/spec_integration_helper.rb +27 -0
  44. data/spec/support/shared/integration/custom_fixtures.rb +32 -0
  45. data/spec/support/shared/integration/exchange.rb +42 -0
  46. data/spec/support/shared/integration/home_path.rb +49 -0
  47. data/spec/support/shared/integration/waiter.rb +75 -0
  48. data/spec/support/site_prism/pages/base.rb +18 -0
  49. data/spec/support/site_prism/pages/home.rb +44 -0
  50. data/spec/support/site_prism/pages/immediate_http_interactions/home_path.rb +15 -0
  51. data/spec/support/site_prism/pages/immediate_http_interactions/one_request.rb +13 -0
  52. data/spec/support/site_prism/pages/immediate_http_interactions/subpage.rb +7 -0
  53. data/spec/support/site_prism/pages/immediate_http_interactions/two_requests.rb +12 -0
  54. data/spec/support/site_prism/pages/immediate_http_interactions/waiter_without_fixtures_ejection.rb +12 -0
  55. data/spec/support/site_prism/sections/console_block.rb +8 -0
  56. data/spec/support/test_app/public/jquery.min.js +5 -0
  57. data/spec/support/test_app/public/test.js +44 -0
  58. data/spec/support/test_app/test_app.rb +46 -0
  59. data/spec/support/test_app/views/index.erb +26 -0
  60. data/spec/unit/applier_spec.rb +134 -0
  61. data/spec/unit/dsl/adjuster_spec.rb +141 -0
  62. data/spec/unit/dsl/initial_adjuster_spec.rb +166 -0
  63. data/spec/unit/element_container_spec.rb +48 -0
  64. data/spec/unit/element_spec.rb +47 -0
  65. data/spec/unit/fixture_spec.rb +45 -0
  66. data/spec/unit/fixtures/converter_spec.rb +36 -0
  67. data/spec/unit/fixtures/handler_spec.rb +72 -0
  68. data/spec/unit/fixtures/manager_spec.rb +58 -0
  69. data/spec/unit/fixtures/modifiers/home_path_spec.rb +47 -0
  70. data/spec/unit/fixtures/modifiers/path_spec.rb +45 -0
  71. data/spec/unit/fixtures/tmp_keeper_spec.rb +17 -0
  72. data/spec/unit/fixtures_spec.rb +76 -0
  73. data/spec/unit/options_spec.rb +41 -0
  74. data/spec/unit/patches/element_container_spec.rb +48 -0
  75. data/spec/unit/patches/page_spec.rb +57 -0
  76. data/spec/unit/vcr_helpers_spec.rb +18 -0
  77. data/spec/unit/waiter_spec.rb +67 -0
  78. metadata +213 -0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/users/max/orgs
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - GitHub.com
17
+ Date:
18
+ - Mon, 18 Mar 2013 21:29:04 GMT
19
+ Content-Type:
20
+ - application/json; charset=utf-8
21
+ Connection:
22
+ - keep-alive
23
+ Status:
24
+ - 200 OK
25
+ X-Ratelimit-Limit:
26
+ - "60"
27
+ X-Ratelimit-Remaining:
28
+ - "54"
29
+ X-Github-Media-Type:
30
+ - github.beta
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Length:
34
+ - '2'
35
+ Etag:
36
+ - '"d751713988987e9331980363e24189ce"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ body:
40
+ encoding: ASCII-8BIT
41
+ string: '{"cat_owner":"Daenerys Targaryen","cat_name":"Max"}'
42
+ http_version:
43
+ recorded_at: Mon, 18 Mar 2013 21:29:05 GMT
44
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/users/felix/orgs
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - GitHub.com
17
+ Date:
18
+ - Mon, 18 Mar 2013 21:29:04 GMT
19
+ Content-Type:
20
+ - application/json; charset=utf-8
21
+ Connection:
22
+ - keep-alive
23
+ Status:
24
+ - 200 OK
25
+ X-Ratelimit-Limit:
26
+ - '60'
27
+ X-Ratelimit-Remaining:
28
+ - '54'
29
+ X-Github-Media-Type:
30
+ - github.beta
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Length:
34
+ - '2'
35
+ Etag:
36
+ - '"d751713988987e9331980363e24189ce"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ body:
40
+ encoding: ASCII-8BIT
41
+ string: '{"cat_owner":"Jon Snow","cat_name":"Felix"}'
42
+ http_version:
43
+ recorded_at: Mon, 18 Mar 2013 21:29:05 GMT
44
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/users/max/orgs
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - GitHub.com
17
+ Date:
18
+ - Mon, 18 Mar 2013 21:29:04 GMT
19
+ Content-Type:
20
+ - application/json; charset=utf-8
21
+ Connection:
22
+ - keep-alive
23
+ Status:
24
+ - 200 OK
25
+ X-Ratelimit-Limit:
26
+ - '60'
27
+ X-Ratelimit-Remaining:
28
+ - '54'
29
+ X-Github-Media-Type:
30
+ - github.beta
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Length:
34
+ - '2'
35
+ Etag:
36
+ - '"d751713988987e9331980363e24189ce"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ body:
40
+ encoding: ASCII-8BIT
41
+ string: '{"cat_owner":"Ned Stark","cat_name":"Max"}'
42
+ http_version:
43
+ recorded_at: Thu, 23 May 2013 19:43:53 GMT
44
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/users/felix/orgs
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - GitHub.com
17
+ Date:
18
+ - Sun, 12 May 2013 18:09:05 GMT
19
+ Content-Type:
20
+ - application/json; charset=utf-8
21
+ Connection:
22
+ - keep-alive
23
+ Status:
24
+ - 200 OK
25
+ X-Ratelimit-Limit:
26
+ - '60'
27
+ X-Ratelimit-Remaining:
28
+ - '54'
29
+ X-Github-Media-Type:
30
+ - github.beta
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Length:
34
+ - '2'
35
+ Etag:
36
+ - '"d751713988987e9331980363e24189ce"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ body:
40
+ encoding: ASCII-8BIT
41
+ string: '{"cat_owner":"Robb Stark","cat_name":"Felix"}'
42
+ http_version:
43
+ recorded_at: Sun, 12 May 2013 18:09:05 GMT
44
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,75 @@
1
+ require 'spec_integration_helper'
2
+
3
+ feature 'Http interactions on event > Click' do
4
+ let(:cat_owner) { test_app_page.cat_owner }
5
+ let(:test_app_page) { HomePage.new }
6
+ let(:action_method) { :click_and_apply_vcr }
7
+
8
+ before do
9
+ test_app_page.load
10
+ end
11
+
12
+ context 'clicks and handles one HTTP request' do
13
+ before do
14
+ test_app_page.link_with_one_request.click_and_apply_vcr
15
+ end
16
+
17
+ it 'applies a default fixture' do
18
+ expect(test_app_page.cat_owner).to have_content('Ned Stark')
19
+ end
20
+ end
21
+
22
+ context 'when there is a delay between clicking and doing an HTTP request' do
23
+ before do
24
+ test_app_page.link_with_one_request_and_delay.click_and_apply_vcr
25
+ end
26
+
27
+ it 'applies a fixture and the test waits for results' do
28
+ expect(cat_owner).to have_content('Ned Stark')
29
+ end
30
+ end
31
+
32
+ # TODO: should we write the same test for the page load?
33
+ context 'when an user clicks on the link which causes 2 HTTP requests' do
34
+ before do
35
+ test_app_page.link_with_2_requests.click_and_apply_vcr
36
+ end
37
+
38
+ it 'applies 2 fixtures' do
39
+ expect(cat_owner).to have_content('Ned Stark')
40
+ expect(cat_owner).to have_content('Robb Stark')
41
+ end
42
+ end
43
+
44
+ it_behaves_like 'when a custom fixture is applied' do
45
+ let(:actor) { test_app_page.link_with_one_request }
46
+
47
+ context 'when clicks again without specifying a custom fixture' do
48
+ it 'uses a default fixture again' do
49
+ actor.click_and_apply_vcr
50
+
51
+ expect(cat_owner).to have_content('Ned Stark')
52
+ end
53
+ end
54
+ end
55
+
56
+ context 'waiters' do
57
+ it_behaves_like 'when a default waiter does not eject fixtures' do
58
+ let(:actor) { test_app_page.link_without_ejecting_fixtures }
59
+ end
60
+
61
+ it_behaves_like 'custom waiters' do
62
+ let(:actor) { test_app_page.link_with_2_requests }
63
+ end
64
+ end
65
+
66
+ it_behaves_like 'when a home path is define' do
67
+ let(:actor_with_home_path) { test_app_page.link_with_home_path }
68
+ let(:actor_without_home_path) { test_app_page.link_with_one_request }
69
+ end
70
+
71
+ it_behaves_like 'when a default fixture is exchanged' do
72
+ let(:actor_with_home_path) { test_app_page.link_with_home_path }
73
+ let(:actor_without_home_path) { test_app_page.link_with_2_requests }
74
+ end
75
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_integration_helper'
2
+
3
+ feature 'Immediate Http interactions > Page load on click' do
4
+ let(:one_request_page) { ImmediateHttpInteractions::OneRequestPage.new }
5
+
6
+ before do
7
+ index_page = HomePage.new
8
+ index_page.load
9
+
10
+ one_request_page.apply_vcr proc { index_page.link_to_go_to_another_page.click }
11
+ end
12
+
13
+ it 'loads fixtures on opening a page by click on a link' do
14
+ expect(one_request_page.displayed?).to be_true
15
+
16
+ expect(one_request_page).to have_content('Ned Stark')
17
+ end
18
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_integration_helper'
2
+
3
+ feature 'Immediate Http interactions > Page load' do
4
+ let(:cat_owner) { test_app_page.cat_owner }
5
+ let(:test_app_page) { ImmediateHttpInteractions::OneRequestPage.new }
6
+ let(:action_method) { :load_and_apply_vcr }
7
+
8
+ context 'when one default fixture is defined' do
9
+ it 'opens the page and applies a default fixture' do
10
+ test_app_page.load_and_apply_vcr
11
+
12
+ expect(cat_owner).to have_content('Ned Stark')
13
+ end
14
+ end
15
+
16
+ it 'applies additional query to url' do
17
+ test_app_page.load_and_apply_vcr(cat: 'ford')
18
+
19
+ expect(page.current_url).to match(/\?cat=ford/)
20
+ end
21
+
22
+ context 'when a subpage inherits a page with a defined vcr options' do
23
+ let(:test_app_page) { ImmediateHttpInteractions::SubPage.new }
24
+
25
+ it 'subpage inherits the defined options for its parent page' do
26
+ test_app_page.load_and_apply_vcr
27
+
28
+ expect(cat_owner).to have_content('Ned Stark')
29
+ end
30
+ end
31
+
32
+ it_behaves_like 'when a custom fixture is applied' do
33
+ let(:actor) { test_app_page }
34
+ end
35
+
36
+ context 'waiters' do
37
+ it_behaves_like 'when a default waiter does not eject fixtures' do
38
+ let(:actor) { ImmediateHttpInteractions::WaiterWithoutFixturesEjectionPage.new }
39
+ end
40
+
41
+ it_behaves_like 'custom waiters' do
42
+ let(:actor) { ImmediateHttpInteractions::TwoRequestsPage.new }
43
+ let(:test_app_page) { actor }
44
+ end
45
+ end
46
+
47
+ it_behaves_like 'when a home path is define' do
48
+ let(:actor_with_home_path) { ImmediateHttpInteractions::HomePathPage.new }
49
+ let(:actor_without_home_path) { ImmediateHttpInteractions::OneRequestPage.new }
50
+ end
51
+
52
+ it_behaves_like 'when a default fixture is exchanged' do
53
+ let(:actor_without_home_path) { ImmediateHttpInteractions::TwoRequestsPage.new }
54
+ let(:actor_with_home_path) { ImmediateHttpInteractions::HomePathPage.new }
55
+ end
56
+ end
@@ -0,0 +1,18 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'rspec'
4
+ require 'coveralls'
5
+
6
+ require 'site_prism.vcr'
7
+
8
+ Coveralls.wear!
9
+
10
+ RSpec.configure do |config|
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
15
+
16
+ VCR.configure do |c|
17
+ c.cassette_library_dir = 'spec/fixtures'
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ require 'capybara/rspec'
4
+ require 'capybara/firebug'
5
+
6
+ require 'support/test_app/test_app'
7
+
8
+ Dir["./spec/support/shared/integration/**/*.rb"].sort.each {|f| require f }
9
+ Dir["./spec/support/site_prism/pages/**/*.rb"].sort.each {|f| require f }
10
+
11
+ Capybara.app = TestApp
12
+ Capybara.default_driver = :selenium
13
+ HTTPI.log = false
14
+
15
+ Selenium::WebDriver::Firefox::Profile.firebug_version = '1.11.0'
16
+
17
+ VCR.configure do |c|
18
+ c.cassette_library_dir = 'spec/fixtures'
19
+ c.hook_into :webmock
20
+ c.ignore_localhost = true
21
+ c.preserve_exact_body_bytes { false }
22
+
23
+ c.default_cassette_options = {
24
+ serialize_with: :psych,
25
+ allow_playback_repeats: true
26
+ }
27
+ end
@@ -0,0 +1,32 @@
1
+ shared_examples 'when a custom fixture is applied' do
2
+ context 'when no VCR options are passed' do
3
+ before do
4
+ actor.public_send(action_method) do
5
+ path 'custom', ['daenerys_targaryen']
6
+ end
7
+ end
8
+
9
+ it 'uses a custom fixture instead of a default one' do
10
+ expect(cat_owner).to have_content('Daenerys Targaryen')
11
+ end
12
+ end
13
+
14
+ context 'when VCR options are passed' do
15
+ before do
16
+ actor.public_send(action_method) do
17
+ path 'custom', [
18
+ {
19
+ fixture: 'blank',
20
+ options: {
21
+ erb: {cat_owner: 'Robert Baratheon'}
22
+ }
23
+ }
24
+ ]
25
+ end
26
+ end
27
+
28
+ it 'uses a custom fixture instead of a default one and takes VCR options' do
29
+ expect(cat_owner).to have_content('Robert Baratheon')
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,42 @@
1
+ shared_examples 'when a default fixture is exchanged' do
2
+ context 'without a home path' do
3
+ before do
4
+ actor_without_home_path.public_send(action_method) do
5
+ waiter &:wait_for_arya_stark_and_robb_stark
6
+
7
+ exchange 'ned_stark', 'arya_stark'
8
+ end
9
+ end
10
+
11
+ it 'uses the exchanged fixture' do
12
+ expect(cat_owner).to have_content('Arya Stark')
13
+ expect(cat_owner).to have_content('Robb Stark')
14
+ end
15
+ end
16
+
17
+ context 'with a defined home path' do
18
+ context 'when fixtures are defined without Vcr options' do
19
+ before do
20
+ actor_with_home_path.public_send(action_method) do
21
+ exchange '~/daenerys_targaryen', '~/bran_stark'
22
+ end
23
+ end
24
+
25
+ it 'uses the exchanged fixture which are stored in the sub directory' do
26
+ expect(cat_owner).to have_content('Bran Stark')
27
+ end
28
+ end
29
+
30
+ context 'when fixtures are defined with Vcr options' do
31
+ before do
32
+ actor_with_home_path.public_send(action_method) do
33
+ exchange '~/daenerys_targaryen', {fixture: '~/blank', options: {erb: {cat_owner: 'Robert Baratheon'} }}
34
+ end
35
+ end
36
+
37
+ it 'uses the exchanged fixture with specified erb variables' do
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,49 @@
1
+ shared_examples 'when a home path is define' do
2
+ shared_examples 'expects the custom fixture on the page' do
3
+ it 'applies a stored fixture in the directory defined in the home path' do
4
+ expect(test_app_page.cat_owner).to have_content('Bran Stark')
5
+ end
6
+ end
7
+
8
+ context 'when no custom fixture is applied' do
9
+ before do
10
+ actor_with_home_path.public_send(action_method)
11
+ end
12
+
13
+ it 'applies a stored fixture in the directory defined in the home path' do
14
+ expect(cat_owner).to have_content('Daenerys Targaryen')
15
+ end
16
+ end
17
+
18
+ context 'when a custom fixture is applied' do
19
+ before do
20
+ actor_with_home_path.public_send(action_method) do
21
+ fixtures ['~/bran_stark']
22
+ end
23
+ end
24
+
25
+ it_behaves_like 'expects the custom fixture on the page'
26
+ end
27
+
28
+ context 'when a home path is used within the path helper method' do
29
+ before do
30
+ actor_with_home_path.public_send(action_method) do
31
+ path '~/', ['bran_stark']
32
+ end
33
+ end
34
+
35
+ it_behaves_like 'expects the custom fixture on the page'
36
+ end
37
+
38
+ context 'when a home path is directly defined in the block for applying fixtures' do
39
+ before do
40
+ actor_without_home_path.public_send(action_method) do
41
+ home_path 'custom'
42
+
43
+ fixtures ['~/bran_stark']
44
+ end
45
+ end
46
+
47
+ it_behaves_like 'expects the custom fixture on the page'
48
+ end
49
+ end
@@ -0,0 +1,75 @@
1
+ shared_examples 'custom waiters' do
2
+ context 'when a waiter is redefined' do
3
+ before do
4
+ actor.public_send(action_method) do
5
+ fixtures ['arya_stark', 'jon_snow']
6
+
7
+ waiter &:wait_for_arya_stark_and_jon_snow
8
+ end
9
+ end
10
+
11
+ it 'uses a custom waiter' do
12
+ expect(cat_owner).to have_content('Arya Stark')
13
+ expect(cat_owner).to have_content('Jon Snow')
14
+ end
15
+
16
+ it 'VCR has not any fixtures' do
17
+ expect(VCR.eject_cassette).to be_nil
18
+ end
19
+
20
+ it 'uses a default waiter after using the custom waiter' do
21
+ actor.public_send(action_method)
22
+
23
+ expect(cat_owner).to have_content('Ned Stark')
24
+ expect(cat_owner).to have_content('Robb Stark')
25
+ end
26
+ end
27
+
28
+ context 'when a custom waiter does not eject fixtures' do
29
+ before do
30
+ my_page = test_app_page
31
+
32
+ actor.public_send(action_method) do
33
+ fixtures ['arya_stark', 'jon_snow']
34
+
35
+ waiter({eject_cassettes: false}, &:wait_for_arya_stark_and_jon_snow)
36
+ end
37
+ end
38
+
39
+ after do
40
+ SPV::Helpers.eject_all_cassettes
41
+ end
42
+
43
+ it 'uses a custom waiter' do
44
+ expect(cat_owner).to have_content('Arya Stark')
45
+ expect(cat_owner).to have_content('Jon Snow')
46
+ end
47
+
48
+ it 'VCR contains all cassettes' do
49
+ expect(VCR.eject_cassette.name).to eq('jon_snow')
50
+ expect(VCR.eject_cassette.name).to eq('arya_stark')
51
+ expect(VCR.eject_cassette).to be_nil
52
+ end
53
+ end
54
+ end
55
+
56
+ shared_examples 'when a default waiter does not eject fixtures' do
57
+ before do
58
+ actor.public_send(action_method)
59
+ end
60
+
61
+ after do
62
+ SPV::Helpers.eject_all_cassettes
63
+ end
64
+
65
+ it 'uses a default waiter' do
66
+ expect(cat_owner).to have_content('Ned Stark')
67
+ expect(cat_owner).to have_content('Robb Stark')
68
+ end
69
+
70
+ it 'VCR contains all cassettes' do
71
+ expect(VCR.eject_cassette.name).to eq('robb_stark')
72
+ expect(VCR.eject_cassette.name).to eq('ned_stark')
73
+ expect(VCR.eject_cassette).to be_nil
74
+ end
75
+ end
@@ -0,0 +1,18 @@
1
+ require_relative '../sections/console_block'
2
+
3
+ class BasePage < SitePrism::Page
4
+ element :cat_owner, '#result'
5
+ section :console_block, ConsoleBlockSection, '#console'
6
+
7
+ def wait_for_arya_stark_and_jon_snow
8
+ console_block.arya_stark && console_block.jon_snow
9
+ end
10
+
11
+ def wait_for_ned_stark_and_robb_stark
12
+ console_block.ned_stark && console_block.robb_stark
13
+ end
14
+
15
+ def wait_for_arya_stark_and_robb_stark
16
+ console_block.arya_stark && console_block.robb_stark
17
+ end
18
+ end
@@ -0,0 +1,44 @@
1
+ require_relative './base'
2
+
3
+ class HomePage < BasePage
4
+ set_url '/'
5
+
6
+ element :link_to_go_to_another_page, '#link_to_go_to_another_page'
7
+
8
+ element_with_vcr \
9
+ :link_with_one_request,
10
+ '#link_with_one_request' do
11
+ fixtures ['ned_stark']
12
+ waiter &:wait_for_cat_owner
13
+ end
14
+
15
+ element_with_vcr \
16
+ :link_with_home_path,
17
+ '#link_with_one_request' do
18
+ home_path 'custom'
19
+
20
+ fixtures ['~/daenerys_targaryen']
21
+ waiter &:wait_for_cat_owner
22
+ end
23
+
24
+ element_with_vcr \
25
+ :link_with_one_request_and_delay,
26
+ '#link_with_one_request_and_delay' do
27
+ fixtures ['ned_stark']
28
+ waiter &:wait_for_cat_owner
29
+ end
30
+
31
+ element_with_vcr \
32
+ :link_with_2_requests,
33
+ '#link_with_2_requests' do
34
+ fixtures ['ned_stark', 'robb_stark']
35
+ waiter &:wait_for_ned_stark_and_robb_stark
36
+ end
37
+
38
+ element_with_vcr \
39
+ :link_without_ejecting_fixtures,
40
+ '#link_with_2_requests' do
41
+ fixtures ['ned_stark', 'robb_stark']
42
+ waiter({eject_cassettes: false}, &:wait_for_ned_stark_and_robb_stark)
43
+ end
44
+ end
@@ -0,0 +1,15 @@
1
+ require_relative '../base'
2
+
3
+ module ImmediateHttpInteractions
4
+ class HomePathPage < BasePage
5
+ set_url '/immediate-http-interactions/one-request'
6
+ set_url_matcher /immediate\-http\-interactions\/one\-request/
7
+
8
+ vcr_options_for_load do
9
+ home_path 'custom'
10
+
11
+ fixtures ['~/daenerys_targaryen']
12
+ waiter &:wait_for_cat_owner
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../base'
2
+
3
+ module ImmediateHttpInteractions
4
+ class OneRequestPage < BasePage
5
+ set_url '/immediate-http-interactions/one-request?cat={cat}'
6
+ set_url_matcher /immediate\-http\-interactions\/one\-request/
7
+
8
+ vcr_options_for_load do
9
+ fixtures ['ned_stark']
10
+ waiter &:wait_for_cat_owner
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ require_relative './one_request'
2
+
3
+ module ImmediateHttpInteractions
4
+ class SubPage < OneRequestPage
5
+ set_url '/immediate-http-interactions/one-request'
6
+ end
7
+ end