site_prism.vcr 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +1 -0
- data/CHANGELOG.md +78 -0
- data/Gemfile +2 -0
- data/README.md +61 -24
- data/TODO.md +28 -40
- data/lib/site_prism_vcr/applier.rb +20 -6
- data/lib/site_prism_vcr/dsl/adjuster.rb +40 -19
- data/lib/site_prism_vcr/dsl/initial_adjuster.rb +1 -1
- data/lib/site_prism_vcr/element.rb +8 -5
- data/lib/site_prism_vcr/fixture.rb +0 -1
- data/lib/site_prism_vcr/options.rb +12 -1
- data/lib/site_prism_vcr/patches/element_container.rb +4 -0
- data/lib/site_prism_vcr/patches/page.rb +25 -27
- data/lib/site_prism_vcr/version.rb +1 -1
- data/site_prism.vcr.gemspec +2 -2
- data/spec/integration/elements/apply_spec.rb +100 -0
- data/spec/integration/elements/events/click_spec.rb +20 -0
- data/spec/integration/{immediate_http_interactions/page_load_on_click_spec.rb → pages/custom_event_spec.rb} +5 -3
- data/spec/integration/{immediate_http_interactions/page_load_spec.rb → pages/load_spec.rb} +13 -9
- data/spec/spec_helper.rb +3 -0
- data/spec/support/shared/integration/custom_fixtures.rb +17 -0
- data/spec/support/shared/integration/exchange.rb +1 -1
- data/spec/support/shared/integration/home_path.rb +1 -1
- data/spec/support/shared/integration/waiter.rb +37 -25
- data/spec/support/site_prism/pages/home.rb +7 -0
- data/spec/support/site_prism/pages/{immediate_http_interactions → page_load}/home_path.rb +1 -1
- data/spec/support/site_prism/pages/{immediate_http_interactions → page_load}/one_request.rb +1 -1
- data/spec/support/site_prism/pages/{immediate_http_interactions → page_load}/subpage.rb +1 -1
- data/spec/support/site_prism/pages/{immediate_http_interactions → page_load}/two_requests.rb +1 -1
- data/spec/support/site_prism/pages/{immediate_http_interactions → page_load}/waiter_without_fixtures_ejection.rb +1 -1
- data/spec/unit/applier_spec.rb +74 -56
- data/spec/unit/dsl/adjuster_spec.rb +58 -47
- data/spec/unit/dsl/initial_adjuster_spec.rb +18 -12
- data/spec/unit/element_spec.rb +11 -13
- data/spec/unit/fixtures/handler_spec.rb +7 -2
- data/spec/unit/fixtures/manager_spec.rb +20 -4
- data/spec/unit/fixtures/modifiers/home_path_spec.rb +14 -3
- data/spec/unit/fixtures/modifiers/path_spec.rb +9 -3
- data/spec/unit/fixtures/tmp_keeper_spec.rb +1 -1
- data/spec/unit/fixtures_spec.rb +5 -5
- data/spec/unit/options_spec.rb +35 -1
- data/spec/unit/patches/element_container_spec.rb +25 -12
- data/spec/unit/patches/page_spec.rb +23 -30
- data/spec/unit/waiter_spec.rb +16 -4
- metadata +30 -30
- data/spec/integration/http_interactions_on_even/click_spec.rb +0 -75
- data/spec/unit/element_container_spec.rb +0 -48
@@ -1,10 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SPV::DSL::Adjuster do
|
4
|
-
let(:raw_fixtures)
|
5
|
-
let(:fixtures)
|
6
|
-
let(:tmp_keeper)
|
7
|
-
|
4
|
+
let(:raw_fixtures) { 'some fixtures' }
|
5
|
+
let(:fixtures) { instance_double('SPV::Fixtures', exchange: true) }
|
6
|
+
let(:tmp_keeper) {
|
7
|
+
instance_double(
|
8
|
+
'SPV::Fixtures::TmpKeeper',
|
9
|
+
{fixtures: raw_fixtures, clean_fixtures: true}
|
10
|
+
)
|
11
|
+
}
|
12
|
+
|
13
|
+
let(:options) {
|
14
|
+
instance_double(
|
15
|
+
'SPV::Options',
|
16
|
+
waiter: :wait_for_me,
|
17
|
+
merge_waiter_options!: nil
|
18
|
+
)
|
19
|
+
}
|
8
20
|
|
9
21
|
before do
|
10
22
|
SPV::Fixtures::TmpKeeper.stub(:new).and_return(tmp_keeper)
|
@@ -12,55 +24,50 @@ describe SPV::DSL::Adjuster do
|
|
12
24
|
|
13
25
|
subject { described_class.new(options, fixtures) }
|
14
26
|
|
15
|
-
describe '#
|
16
|
-
|
27
|
+
describe '#prepare_fixtures' do
|
28
|
+
context 'when the replace action is defined' do
|
29
|
+
let(:replaced_fixtures) { 'replaced fixtures' }
|
17
30
|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'replaces fixtures' do
|
23
|
-
expect(fixtures).to receive(:replace).with(raw_fixtures)
|
24
|
-
|
25
|
-
subject.replace
|
26
|
-
end
|
31
|
+
before do
|
32
|
+
fixtures.stub(:replace).and_return(replaced_fixtures)
|
27
33
|
|
28
|
-
|
29
|
-
|
34
|
+
subject.replace
|
35
|
+
end
|
30
36
|
|
31
|
-
|
32
|
-
|
37
|
+
it 'replaces fixtures' do
|
38
|
+
expect(fixtures).to receive(:replace).with(raw_fixtures)
|
33
39
|
|
34
|
-
|
35
|
-
|
40
|
+
subject.prepare_fixtures
|
41
|
+
end
|
36
42
|
|
37
|
-
|
43
|
+
it 'returns a new container with fixtures' do
|
44
|
+
expect(subject.prepare_fixtures).to eq(replaced_fixtures)
|
45
|
+
end
|
38
46
|
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#union' do
|
42
|
-
let(:new_fixtures) { 'new fixtures' }
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
48
|
+
context 'when the union action is defined' do
|
49
|
+
let(:new_fixtures) { 'new fixtures' }
|
47
50
|
|
48
|
-
|
49
|
-
|
51
|
+
before do
|
52
|
+
fixtures.stub(:union).and_return(new_fixtures)
|
53
|
+
subject.union
|
54
|
+
end
|
50
55
|
|
51
|
-
|
52
|
-
|
56
|
+
it 'joins fixtures' do
|
57
|
+
expect(fixtures).to receive(:union).with(raw_fixtures)
|
53
58
|
|
54
|
-
|
55
|
-
|
59
|
+
subject.prepare_fixtures
|
60
|
+
end
|
56
61
|
|
57
|
-
|
62
|
+
it 'returns a new container with fixtures' do
|
63
|
+
expect(subject.prepare_fixtures).to eq(new_fixtures)
|
64
|
+
end
|
58
65
|
end
|
59
66
|
|
60
|
-
it '
|
61
|
-
|
67
|
+
it 'the replace action is used as a default' do
|
68
|
+
expect(fixtures).to receive(:replace).with(raw_fixtures)
|
62
69
|
|
63
|
-
|
70
|
+
subject.prepare_fixtures
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|
@@ -84,9 +91,8 @@ describe SPV::DSL::Adjuster do
|
|
84
91
|
end
|
85
92
|
end
|
86
93
|
|
87
|
-
let(:
|
88
|
-
let(:
|
89
|
-
let(:home_path_modifier) { double(modify: true) }
|
94
|
+
let(:fixtures_handler) { instance_double('SPV::Fixtures::Handler') }
|
95
|
+
let(:home_path_modifier) { double('home path modifier') }
|
90
96
|
|
91
97
|
let(:raw_old_fixtures) { ['old fixtures'] }
|
92
98
|
let(:raw_new_fixtures) { ['new fixtures'] }
|
@@ -94,11 +100,8 @@ describe SPV::DSL::Adjuster do
|
|
94
100
|
let(:expected_raw_old_fixtures) { raw_old_fixtures }
|
95
101
|
let(:expected_raw_new_fixtures) { raw_new_fixtures }
|
96
102
|
|
97
|
-
let(:
|
98
|
-
let(:
|
99
|
-
|
100
|
-
let(:handled_old_fixtures) { [old_fixture] }
|
101
|
-
let(:handled_new_fixtures) { [new_fixture] }
|
103
|
+
let(:handled_old_fixtures) { ['old fixture'] }
|
104
|
+
let(:handled_new_fixtures) { ['old fixture'] }
|
102
105
|
|
103
106
|
before do
|
104
107
|
SPV::Fixtures::Handler.stub(:new).and_return(fixtures_handler)
|
@@ -138,4 +141,12 @@ describe SPV::DSL::Adjuster do
|
|
138
141
|
exchange
|
139
142
|
end
|
140
143
|
end
|
144
|
+
|
145
|
+
describe '#waiter_options' do
|
146
|
+
it 'merges default waiter options with a given' do
|
147
|
+
expect(options).to receive(:merge_waiter_options!).with(my: 'options')
|
148
|
+
|
149
|
+
subject.waiter_options(my: 'options')
|
150
|
+
end
|
151
|
+
end
|
141
152
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SPV::DSL::InitialAdjuster do
|
4
|
-
let(:options) {
|
5
|
-
let(:tmp_keeper) {
|
6
|
-
let(:handled_fixtures) {
|
7
|
-
let(:fixtures_handler) {
|
4
|
+
let(:options) { instance_double('SPV::Options') }
|
5
|
+
let(:tmp_keeper) { instance_double('SPV::Fixtures::TmpKeeper', add_fixtures: true) }
|
6
|
+
let(:handled_fixtures) { 'handled fixtures' }
|
7
|
+
let(:fixtures_handler) { instance_double('SPV::Fixtures::Handler', handle_raw: handled_fixtures) }
|
8
8
|
|
9
9
|
subject { described_class.new(options) }
|
10
10
|
|
@@ -29,7 +29,7 @@ describe SPV::DSL::InitialAdjuster do
|
|
29
29
|
|
30
30
|
describe '#fixtures' do
|
31
31
|
let(:raw_fixtures) { 'some fixtures' }
|
32
|
-
let(:home_path_modifier) { '
|
32
|
+
let(:home_path_modifier) { double('home path modifier') }
|
33
33
|
|
34
34
|
before do
|
35
35
|
SPV::Fixtures::Modifiers::HomePath.stub(:new).and_return(home_path_modifier)
|
@@ -73,10 +73,10 @@ describe SPV::DSL::InitialAdjuster do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
let(:raw_fixtures) { 'some raw fixtures' }
|
76
|
-
let(:options_with_path) {
|
76
|
+
let(:options_with_path) { instance_double('SPV::OptionsWithPath', 'path=' => true) }
|
77
77
|
|
78
|
-
let(:path_modifier)
|
79
|
-
let(:home_path_modifier)
|
78
|
+
let(:path_modifier) { double('path modifier') }
|
79
|
+
let(:home_path_modifier) { double('home path modifier') }
|
80
80
|
|
81
81
|
before do
|
82
82
|
SPV::OptionsWithPath.stub(:new).and_return(options_with_path)
|
@@ -132,7 +132,13 @@ describe SPV::DSL::InitialAdjuster do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
describe '#waiter' do
|
135
|
-
let(:options) {
|
135
|
+
let(:options) {
|
136
|
+
instance_double(
|
137
|
+
'SPV::Options',
|
138
|
+
'waiter='.to_sym => true,
|
139
|
+
'waiter_options='.to_sym => true
|
140
|
+
)
|
141
|
+
}
|
136
142
|
|
137
143
|
it 'defines a new waiter' do
|
138
144
|
expect(options).to receive(:waiter=).with(kind_of(Proc))
|
@@ -147,8 +153,8 @@ describe SPV::DSL::InitialAdjuster do
|
|
147
153
|
end
|
148
154
|
end
|
149
155
|
|
150
|
-
describe '#
|
151
|
-
let(:fixtures) { double }
|
156
|
+
describe '#prepare_fixtures' do
|
157
|
+
let(:fixtures) { double('fixtures') }
|
152
158
|
let(:raw_fixtures) { 'some raw fixtures' }
|
153
159
|
|
154
160
|
before do
|
@@ -160,7 +166,7 @@ describe SPV::DSL::InitialAdjuster do
|
|
160
166
|
it 'initializes the fixtures handler' do
|
161
167
|
expect(SPV::Fixtures).to receive(:new).with(raw_fixtures).and_return(fixtures)
|
162
168
|
|
163
|
-
expect(subject.
|
169
|
+
expect(subject.prepare_fixtures).to eq(fixtures)
|
164
170
|
end
|
165
171
|
end
|
166
172
|
end
|
data/spec/unit/element_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SPV::Element do
|
4
|
-
let(:node) {
|
5
|
-
let(:parent) { double }
|
6
|
-
let(:applier) {
|
4
|
+
let(:node) { double('node of DOM') }
|
5
|
+
let(:parent) { double('parent element') }
|
6
|
+
let(:applier) { instance_double('SPV::Applier', apply_vcr: true) }
|
7
7
|
|
8
8
|
before do
|
9
9
|
SPV::Applier.stub(:new).and_return(applier)
|
@@ -26,22 +26,20 @@ describe SPV::Element do
|
|
26
26
|
|
27
27
|
before do
|
28
28
|
subject.stub(:click)
|
29
|
+
subject.stub(:shift_event).and_yield.and_return(applier)
|
29
30
|
end
|
30
31
|
|
31
|
-
it '
|
32
|
-
expect(
|
33
|
-
|
34
|
-
)
|
32
|
+
it 'shifts a click event to the applier' do
|
33
|
+
expect(subject).to receive(:shift_event).and_yield.and_return(applier)
|
34
|
+
expect(subject).to receive(:click)
|
35
35
|
|
36
|
-
subject.click_and_apply_vcr
|
36
|
+
subject.click_and_apply_vcr
|
37
37
|
end
|
38
38
|
|
39
|
-
it '
|
40
|
-
applier.
|
41
|
-
|
42
|
-
expect(subject).to receive(:click)
|
39
|
+
it 'applies vcr' do
|
40
|
+
expect(applier).to receive(:apply_vcr)
|
43
41
|
|
44
42
|
subject.click_and_apply_vcr
|
45
43
|
end
|
46
44
|
end
|
47
|
-
end
|
45
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SPV::Fixtures::Handler do
|
4
|
-
let(:options) {
|
4
|
+
let(:options) { instance_double('SPV::Options') }
|
5
5
|
let(:converted_fixtures) { [] }
|
6
6
|
let(:fixtures_converter) { SPV::Fixtures::Converter }
|
7
7
|
|
@@ -19,7 +19,12 @@ describe SPV::Fixtures::Handler do
|
|
19
19
|
let(:raw_fixtures) { 'some raw fixtures' }
|
20
20
|
let(:converted_fixture) { 'converted fixture' }
|
21
21
|
let(:converted_fixtures) { [converted_fixture] }
|
22
|
-
let(:modifier)
|
22
|
+
let(:modifier) do
|
23
|
+
instance_double(
|
24
|
+
'SPV::Fixtures::Modifiers::HomePath',
|
25
|
+
modify: true
|
26
|
+
)
|
27
|
+
end
|
23
28
|
|
24
29
|
it 'converts raw fixtures' do
|
25
30
|
expect(fixtures_converter).to receive(:convert_raw).with(raw_fixtures)
|
@@ -1,12 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SPV::Fixtures::Manager do
|
4
|
-
let(:options) {
|
4
|
+
let(:options) { instance_double('SPV::Options', fixtures: ['some fixture']) }
|
5
5
|
|
6
6
|
describe '#inject' do
|
7
|
-
let(:fixture1)
|
8
|
-
|
9
|
-
|
7
|
+
let(:fixture1) do
|
8
|
+
instance_double(
|
9
|
+
'SPV::Fixture',
|
10
|
+
name: 'arya_stark',
|
11
|
+
options: {erb: {testvar: true}}
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:fixture2) do
|
16
|
+
instance_double(
|
17
|
+
'SPV::Fixture',
|
18
|
+
name: 'jon_snow',
|
19
|
+
options: {}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:fixtures) do
|
24
|
+
[fixture1, fixture2]
|
25
|
+
end
|
10
26
|
|
11
27
|
subject(:manager) { described_class.new(options) }
|
12
28
|
|
@@ -3,8 +3,14 @@ require 'spec_helper'
|
|
3
3
|
describe SPV::Fixtures::Modifiers::HomePath do
|
4
4
|
describe '#modify' do
|
5
5
|
let(:path) { 'some home path' }
|
6
|
-
let(:options) {
|
7
|
-
let(:fixture)
|
6
|
+
let(:options) { instance_double('SPV::Options', home_path: path) }
|
7
|
+
let(:fixture) do
|
8
|
+
instance_double(
|
9
|
+
'SPV::Fixture',
|
10
|
+
name: 'test_with_home_path',
|
11
|
+
:has_link_to_home_path? => true
|
12
|
+
)
|
13
|
+
end
|
8
14
|
|
9
15
|
subject { described_class.new(options).modify(fixture) }
|
10
16
|
|
@@ -35,7 +41,12 @@ describe SPV::Fixtures::Modifiers::HomePath do
|
|
35
41
|
end
|
36
42
|
|
37
43
|
context 'when a name of the fixture has no link to the home path' do
|
38
|
-
let(:fixture)
|
44
|
+
let(:fixture) do
|
45
|
+
instance_double(
|
46
|
+
'SPV::Fixture',
|
47
|
+
:has_link_to_home_path? => false
|
48
|
+
)
|
49
|
+
end
|
39
50
|
|
40
51
|
it 'does not set any home path' do
|
41
52
|
expect(fixture).to_not receive(:set_home_path)
|
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe SPV::Fixtures::Modifiers::Path do
|
4
4
|
describe '#modify' do
|
5
5
|
let(:path) { 'some path' }
|
6
|
-
let(:options) {
|
7
|
-
let(:fixture) {
|
6
|
+
let(:options) { instance_double('SPV::Options', path: path) }
|
7
|
+
let(:fixture) { instance_double('SPV::Fixture', :has_link_to_home_path? => false) }
|
8
8
|
|
9
9
|
subject { described_class.new(options).modify(fixture) }
|
10
10
|
|
@@ -27,7 +27,13 @@ describe SPV::Fixtures::Modifiers::Path do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'when the fixture has a link to the home path' do
|
30
|
-
let(:fixture)
|
30
|
+
let(:fixture) do
|
31
|
+
instance_double(
|
32
|
+
'SPV::Fixture',
|
33
|
+
:has_link_to_home_path? => true,
|
34
|
+
clean_name: 'Max'
|
35
|
+
)
|
36
|
+
end
|
31
37
|
|
32
38
|
it 'raises an error about link to the home path' do
|
33
39
|
expect{
|
data/spec/unit/fixtures_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SPV::Fixtures do
|
4
|
-
let(:fixture1) {
|
5
|
-
let(:fixture2) {
|
6
|
-
let(:fixture3) {
|
7
|
-
let(:fixture4) {
|
8
|
-
let(:fixture5) {
|
4
|
+
let(:fixture1) { instance_double('SPV::Fixture', name: 'fixture1') }
|
5
|
+
let(:fixture2) { instance_double('SPV::Fixture', name: 'fixture2') }
|
6
|
+
let(:fixture3) { instance_double('SPV::Fixture', name: 'fixture3') }
|
7
|
+
let(:fixture4) { instance_double('SPV::Fixture', name: 'fixture4') }
|
8
|
+
let(:fixture5) { instance_double('SPV::Fixture', name: 'fixture5') }
|
9
9
|
|
10
10
|
subject(:fixtures) { described_class.new([fixture1, fixture2, fixture3]) }
|
11
11
|
|
data/spec/unit/options_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SPV::Options do
|
4
|
-
|
4
|
+
subject(:options) { described_class.new }
|
5
5
|
|
6
6
|
describe '.new' do
|
7
7
|
it 'holds the passed options' do
|
@@ -38,4 +38,38 @@ describe SPV::Options do
|
|
38
38
|
expect(cloned_options.object_id).to_not eq(options.object_id)
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
describe '#waiter_options' do
|
43
|
+
context 'when options are not defined' do
|
44
|
+
it 'returns an empty hash' do
|
45
|
+
expect(options.waiter_options).to be_a(Hash)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when options are defined' do
|
50
|
+
it 'returns it' do
|
51
|
+
expected = {eject_fixtures: false}
|
52
|
+
|
53
|
+
subject.waiter_options = expected
|
54
|
+
|
55
|
+
expect(subject.waiter_options).to eq(expected)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#merge_waiter_options!' do
|
61
|
+
it 'redefines default options' do
|
62
|
+
subject.waiter_options = {
|
63
|
+
eject_fixtures: false,
|
64
|
+
some_another_option: true
|
65
|
+
}
|
66
|
+
|
67
|
+
subject.merge_waiter_options!(eject_fixtures: true)
|
68
|
+
|
69
|
+
expect(options.waiter_options).to include(
|
70
|
+
eject_fixtures: true,
|
71
|
+
some_another_option: true
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
41
75
|
end
|
@@ -7,38 +7,51 @@ class TestPageWithElement
|
|
7
7
|
def element(*); end
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
|
10
|
+
def test_el1; end
|
11
|
+
def test_el2
|
12
|
+
'original element'
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
element_with_vcr(:el_with_options, '#selector', fixtures: 'some fixtures') {}
|
15
|
+
link_vcr_with_element :test_el2
|
17
16
|
end
|
18
17
|
|
19
18
|
describe SitePrism::ElementContainer do
|
20
19
|
describe '.element_with_vcr' do
|
20
|
+
subject do
|
21
|
+
TestPageWithElement.instance_eval do
|
22
|
+
element_with_vcr :test_el1, '#test_selector', visible: false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
21
26
|
it 'calls the original element method with given arguments' do
|
22
27
|
expect(TestPageWithElement).to receive(:element).with(
|
23
|
-
:
|
28
|
+
:test_el1,
|
24
29
|
'#test_selector',
|
25
30
|
visible: false
|
26
31
|
)
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
33
|
+
subject
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'links vcr with an element' do
|
37
|
+
expect(TestPageWithElement).to receive(:link_vcr_with_element).with(
|
38
|
+
:test_el1
|
39
|
+
)
|
40
|
+
|
41
|
+
subject
|
31
42
|
end
|
43
|
+
end
|
32
44
|
|
45
|
+
describe '.link_vcr_with_element' do
|
33
46
|
context 'when a method for getting an element is called' do
|
34
47
|
let(:page) { TestPageWithElement.new }
|
35
48
|
let(:vcr_el) { 'vcr element' }
|
36
49
|
|
37
|
-
subject { page.
|
50
|
+
subject { page.test_el2 }
|
38
51
|
|
39
|
-
it 'initializes a new instance of an element
|
52
|
+
it 'initializes a new instance of an element' do
|
40
53
|
expect(SPV::Element).to receive(:new).with(
|
41
|
-
'original element
|
54
|
+
'original element', page
|
42
55
|
).and_return(vcr_el)
|
43
56
|
|
44
57
|
expect(subject).to eq(vcr_el)
|
@@ -3,55 +3,48 @@ require 'spec_helper'
|
|
3
3
|
describe SitePrism::Page do
|
4
4
|
subject { SitePrism::Page.new }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
let(:applier) do
|
7
|
+
instance_double(
|
8
|
+
'SPV::Applier',
|
9
|
+
apply_vcr: true
|
10
|
+
)
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
before do
|
14
|
+
SitePrism::Page.vcr_options_for_load { }
|
15
|
+
end
|
12
16
|
|
17
|
+
describe '.new' do
|
18
|
+
before do
|
13
19
|
SPV::Applier.stub(:new).and_return(applier)
|
14
20
|
end
|
15
21
|
|
16
22
|
it 'initializes the fixtures applier' do
|
17
23
|
expect(SPV::Applier).to receive(:new).with(
|
18
|
-
|
19
|
-
).and_return(applier)
|
20
|
-
|
21
|
-
subject.apply_vcr(action_block)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'applies fixtures' do
|
25
|
-
expect(applier).to receive(:apply).with(
|
26
|
-
kind_of(Proc)
|
24
|
+
kind_of(described_class)
|
27
25
|
)
|
28
26
|
|
29
|
-
subject
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'does the action from the action block' do
|
33
|
-
applier.stub(:apply).and_yield
|
34
|
-
|
35
|
-
expect(action_block).to receive(:call)
|
36
|
-
|
37
|
-
subject.apply_vcr('arg1', 'arg2', action_block) { }
|
27
|
+
subject
|
38
28
|
end
|
39
29
|
end
|
40
30
|
|
41
31
|
describe '#load_and_apply_vcr' do
|
42
32
|
before do
|
43
|
-
subject.stub(:apply_vcr)
|
44
33
|
subject.stub(:load)
|
34
|
+
subject.stub(:shift_event).and_yield.and_return(applier)
|
45
35
|
end
|
46
36
|
|
47
|
-
it '
|
48
|
-
expect(subject).to receive(:
|
49
|
-
|
37
|
+
it 'shifts a load event to the applier' do
|
38
|
+
expect(subject).to receive(:shift_event).and_yield.and_return(applier)
|
39
|
+
expect(subject).to receive(:load).with('some arguments')
|
40
|
+
|
41
|
+
subject.load_and_apply_vcr('some arguments')
|
42
|
+
end
|
50
43
|
|
51
|
-
|
52
|
-
|
44
|
+
it 'applies vcr' do
|
45
|
+
expect(applier).to receive(:apply_vcr)
|
53
46
|
|
54
|
-
subject.load_and_apply_vcr
|
47
|
+
subject.load_and_apply_vcr
|
55
48
|
end
|
56
49
|
end
|
57
50
|
end
|
data/spec/unit/waiter_spec.rb
CHANGED
@@ -1,15 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SPV::Waiter do
|
4
|
-
let(:node)
|
5
|
-
let(:options)
|
6
|
-
|
4
|
+
let(:node) { double('node of DOM') }
|
5
|
+
let(:options) {
|
6
|
+
instance_double(
|
7
|
+
'SPV::Options',
|
8
|
+
waiter_options: nil,
|
9
|
+
waiter: nil
|
10
|
+
)
|
11
|
+
}
|
12
|
+
|
13
|
+
let(:fixtures_manager) {
|
14
|
+
instance_double(
|
15
|
+
'SPV::Fixtures::Manager',
|
16
|
+
eject: true
|
17
|
+
)
|
18
|
+
}
|
7
19
|
|
8
20
|
subject(:waiter) { described_class.new(node, fixtures_manager, options) }
|
9
21
|
|
10
22
|
describe '#wait' do
|
11
23
|
context 'when a waiter is defined' do
|
12
|
-
let(:node) { double(wait_for_content: true) }
|
24
|
+
let(:node) { double('node of DOM', wait_for_content: true) }
|
13
25
|
|
14
26
|
before do
|
15
27
|
options.stub(:waiter).and_return(proc { self.wait_for_content })
|