site_prism.vcr 0.1.2 → 0.2.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 +5 -0
- data/CHANGELOG.md +51 -4
- data/Gemfile +3 -4
- data/README.md +88 -10
- data/TODO.md +29 -31
- data/lib/site_prism_vcr/applier.rb +51 -13
- data/lib/site_prism_vcr/dsl/adjuster.rb +1 -1
- data/lib/site_prism_vcr/dsl/initial_adjuster.rb +26 -6
- data/lib/site_prism_vcr/fixture.rb +7 -4
- data/lib/site_prism_vcr/fixtures/manager.rb +30 -11
- data/lib/site_prism_vcr/fixtures/modifiers/path.rb +6 -6
- data/lib/site_prism_vcr/fixtures/modifiers/shortcut_path.rb +25 -0
- data/lib/site_prism_vcr/mixins/element.rb +23 -0
- data/lib/site_prism_vcr/mixins/page.rb +63 -0
- data/lib/site_prism_vcr/options.rb +20 -6
- data/lib/site_prism_vcr/patches/element.rb +4 -0
- data/lib/site_prism_vcr/patches/page.rb +2 -38
- data/lib/site_prism_vcr/version.rb +1 -1
- data/lib/site_prism_vcr.rb +2 -2
- data/spec/integration/elements/apply_spec.rb +4 -0
- data/spec/integration/pages/custom_event_spec.rb +1 -1
- data/spec/integration/pages/load_spec.rb +11 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/spec_integration_helper.rb +0 -3
- data/spec/support/shared/integration/home_path.rb +1 -1
- data/spec/support/shared/integration/shortcut_path.rb +13 -0
- data/spec/support/site_prism/pages/page_load/subpage_with_fixtures.rb +14 -0
- data/spec/unit/applier_spec.rb +97 -43
- data/spec/unit/dsl/adjuster_spec.rb +7 -7
- data/spec/unit/dsl/initial_adjuster_spec.rb +29 -13
- data/spec/unit/element_spec.rb +3 -3
- data/spec/unit/fixture_spec.rb +47 -17
- data/spec/unit/fixtures/converter_spec.rb +1 -1
- data/spec/unit/fixtures/handler_spec.rb +3 -3
- data/spec/unit/fixtures/manager_spec.rb +76 -29
- data/spec/unit/fixtures/modifiers/path_spec.rb +10 -10
- data/spec/unit/fixtures/modifiers/relative_path_spec.rb +1 -1
- data/spec/unit/fixtures/modifiers/shortcut_path_spec.rb +61 -0
- data/spec/unit/{patches/element_container_spec.rb → mixins/element_spec.rb} +2 -2
- data/spec/unit/mixins/page_spec.rb +105 -0
- data/spec/unit/options_spec.rb +6 -6
- data/spec/unit/waiter_spec.rb +3 -3
- metadata +28 -22
- data/lib/site_prism_vcr/fixtures/modifiers/home_path.rb +0 -25
- data/lib/site_prism_vcr/patches/element_container.rb +0 -19
- data/spec/unit/fixtures/modifiers/home_path_spec.rb +0 -58
- data/spec/unit/patches/page_spec.rb +0 -50
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site_prism.vcr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Nesteryuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: site_prism
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: vcr
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.9.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.9.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: webmock
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: This gem integrates VCR library into SitePrism
|
@@ -59,9 +59,9 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .rspec
|
64
|
-
- .travis.yml
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
65
|
- CHANGELOG.md
|
66
66
|
- Gemfile
|
67
67
|
- LICENSE.txt
|
@@ -80,13 +80,15 @@ files:
|
|
80
80
|
- lib/site_prism_vcr/fixtures/handler.rb
|
81
81
|
- lib/site_prism_vcr/fixtures/manager.rb
|
82
82
|
- lib/site_prism_vcr/fixtures/modifiers/base.rb
|
83
|
-
- lib/site_prism_vcr/fixtures/modifiers/home_path.rb
|
84
83
|
- lib/site_prism_vcr/fixtures/modifiers/path.rb
|
85
84
|
- lib/site_prism_vcr/fixtures/modifiers/relative_path.rb
|
85
|
+
- lib/site_prism_vcr/fixtures/modifiers/shortcut_path.rb
|
86
86
|
- lib/site_prism_vcr/fixtures/tmp_keeper.rb
|
87
|
+
- lib/site_prism_vcr/mixins/element.rb
|
88
|
+
- lib/site_prism_vcr/mixins/page.rb
|
87
89
|
- lib/site_prism_vcr/options.rb
|
88
90
|
- lib/site_prism_vcr/options_with_path.rb
|
89
|
-
- lib/site_prism_vcr/patches/
|
91
|
+
- lib/site_prism_vcr/patches/element.rb
|
90
92
|
- lib/site_prism_vcr/patches/page.rb
|
91
93
|
- lib/site_prism_vcr/vcr_helpers.rb
|
92
94
|
- lib/site_prism_vcr/version.rb
|
@@ -110,12 +112,14 @@ files:
|
|
110
112
|
- spec/support/shared/integration/custom_fixtures.rb
|
111
113
|
- spec/support/shared/integration/exchange.rb
|
112
114
|
- spec/support/shared/integration/home_path.rb
|
115
|
+
- spec/support/shared/integration/shortcut_path.rb
|
113
116
|
- spec/support/shared/integration/waiter.rb
|
114
117
|
- spec/support/site_prism/pages/base.rb
|
115
118
|
- spec/support/site_prism/pages/home.rb
|
116
119
|
- spec/support/site_prism/pages/page_load/home_path.rb
|
117
120
|
- spec/support/site_prism/pages/page_load/one_request.rb
|
118
121
|
- spec/support/site_prism/pages/page_load/subpage.rb
|
122
|
+
- spec/support/site_prism/pages/page_load/subpage_with_fixtures.rb
|
119
123
|
- spec/support/site_prism/pages/page_load/two_requests.rb
|
120
124
|
- spec/support/site_prism/pages/page_load/waiter_without_fixtures_ejection.rb
|
121
125
|
- spec/support/site_prism/sections/console_block.rb
|
@@ -131,14 +135,14 @@ files:
|
|
131
135
|
- spec/unit/fixtures/converter_spec.rb
|
132
136
|
- spec/unit/fixtures/handler_spec.rb
|
133
137
|
- spec/unit/fixtures/manager_spec.rb
|
134
|
-
- spec/unit/fixtures/modifiers/home_path_spec.rb
|
135
138
|
- spec/unit/fixtures/modifiers/path_spec.rb
|
136
139
|
- spec/unit/fixtures/modifiers/relative_path_spec.rb
|
140
|
+
- spec/unit/fixtures/modifiers/shortcut_path_spec.rb
|
137
141
|
- spec/unit/fixtures/tmp_keeper_spec.rb
|
138
142
|
- spec/unit/fixtures_spec.rb
|
143
|
+
- spec/unit/mixins/element_spec.rb
|
144
|
+
- spec/unit/mixins/page_spec.rb
|
139
145
|
- spec/unit/options_spec.rb
|
140
|
-
- spec/unit/patches/element_container_spec.rb
|
141
|
-
- spec/unit/patches/page_spec.rb
|
142
146
|
- spec/unit/vcr_helpers_spec.rb
|
143
147
|
- spec/unit/waiter_spec.rb
|
144
148
|
homepage: http://github.com/dnesteryuk/site_prism.vcr
|
@@ -151,17 +155,17 @@ require_paths:
|
|
151
155
|
- lib
|
152
156
|
required_ruby_version: !ruby/object:Gem::Requirement
|
153
157
|
requirements:
|
154
|
-
- -
|
158
|
+
- - ">="
|
155
159
|
- !ruby/object:Gem::Version
|
156
160
|
version: '0'
|
157
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
162
|
requirements:
|
159
|
-
- -
|
163
|
+
- - ">="
|
160
164
|
- !ruby/object:Gem::Version
|
161
165
|
version: '0'
|
162
166
|
requirements: []
|
163
167
|
rubyforge_project:
|
164
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.4.3
|
165
169
|
signing_key:
|
166
170
|
specification_version: 4
|
167
171
|
summary: VCR and SitePrism are awesome libraries. But, it is a bit difficult to work
|
@@ -188,12 +192,14 @@ test_files:
|
|
188
192
|
- spec/support/shared/integration/custom_fixtures.rb
|
189
193
|
- spec/support/shared/integration/exchange.rb
|
190
194
|
- spec/support/shared/integration/home_path.rb
|
195
|
+
- spec/support/shared/integration/shortcut_path.rb
|
191
196
|
- spec/support/shared/integration/waiter.rb
|
192
197
|
- spec/support/site_prism/pages/base.rb
|
193
198
|
- spec/support/site_prism/pages/home.rb
|
194
199
|
- spec/support/site_prism/pages/page_load/home_path.rb
|
195
200
|
- spec/support/site_prism/pages/page_load/one_request.rb
|
196
201
|
- spec/support/site_prism/pages/page_load/subpage.rb
|
202
|
+
- spec/support/site_prism/pages/page_load/subpage_with_fixtures.rb
|
197
203
|
- spec/support/site_prism/pages/page_load/two_requests.rb
|
198
204
|
- spec/support/site_prism/pages/page_load/waiter_without_fixtures_ejection.rb
|
199
205
|
- spec/support/site_prism/sections/console_block.rb
|
@@ -209,13 +215,13 @@ test_files:
|
|
209
215
|
- spec/unit/fixtures/converter_spec.rb
|
210
216
|
- spec/unit/fixtures/handler_spec.rb
|
211
217
|
- spec/unit/fixtures/manager_spec.rb
|
212
|
-
- spec/unit/fixtures/modifiers/home_path_spec.rb
|
213
218
|
- spec/unit/fixtures/modifiers/path_spec.rb
|
214
219
|
- spec/unit/fixtures/modifiers/relative_path_spec.rb
|
220
|
+
- spec/unit/fixtures/modifiers/shortcut_path_spec.rb
|
215
221
|
- spec/unit/fixtures/tmp_keeper_spec.rb
|
216
222
|
- spec/unit/fixtures_spec.rb
|
223
|
+
- spec/unit/mixins/element_spec.rb
|
224
|
+
- spec/unit/mixins/page_spec.rb
|
217
225
|
- spec/unit/options_spec.rb
|
218
|
-
- spec/unit/patches/element_container_spec.rb
|
219
|
-
- spec/unit/patches/page_spec.rb
|
220
226
|
- spec/unit/vcr_helpers_spec.rb
|
221
227
|
- spec/unit/waiter_spec.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require_relative 'base'
|
2
|
-
|
3
|
-
module SPV
|
4
|
-
class Fixtures
|
5
|
-
module Modifiers
|
6
|
-
# It takes a fixture and replaces "~/" with
|
7
|
-
# a defined home path.
|
8
|
-
class HomePath < Base
|
9
|
-
def modify(fixture)
|
10
|
-
if fixture.has_link_to_home_path?
|
11
|
-
if @options.home_path
|
12
|
-
fixture.set_home_path(@options.home_path)
|
13
|
-
else
|
14
|
-
raise ArgumentError.new(
|
15
|
-
"You are trying to use a home path for #{fixture.name} fixture. " \
|
16
|
-
"Home path cannot be used since it is not defined, please refer to the documentation " \
|
17
|
-
"to make sure you define the home path properly."
|
18
|
-
)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module SitePrism::ElementContainer
|
2
|
-
def element_with_vcr(element_name, *args, &block)
|
3
|
-
element element_name, *args
|
4
|
-
|
5
|
-
link_vcr_with_element(element_name, &block)
|
6
|
-
end
|
7
|
-
|
8
|
-
def link_vcr_with_element(element_name, &block)
|
9
|
-
origin_element_name = "origin_#{element_name}"
|
10
|
-
|
11
|
-
alias_method origin_element_name, element_name
|
12
|
-
|
13
|
-
define_method element_name.to_s do
|
14
|
-
elem = public_send(origin_element_name)
|
15
|
-
|
16
|
-
SPV::Element.new(elem, self, &block)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SPV::Fixtures::Modifiers::HomePath do
|
4
|
-
describe '#modify' do
|
5
|
-
let(:path) { 'some home path' }
|
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
|
14
|
-
|
15
|
-
subject { described_class.new(options).modify(fixture) }
|
16
|
-
|
17
|
-
context 'when a name of the fixture has a link to the home path' do
|
18
|
-
context 'when the home_path is defined' do
|
19
|
-
it 'writes a proper path to the fixture' do
|
20
|
-
expect(fixture).to receive(:set_home_path).with(path)
|
21
|
-
|
22
|
-
subject
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when the home_path is not defined' do
|
27
|
-
before do
|
28
|
-
options.stub(:home_path).and_return(nil)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'raises an argument error about wrong way of defining fixtures' do
|
32
|
-
msg = 'You are trying to use a home path for test_with_home_path fixture. ' \
|
33
|
-
'Home path cannot be used since it is not defined, please refer to the documentation ' \
|
34
|
-
'to make sure you define the home path properly.'
|
35
|
-
|
36
|
-
expect { subject }.to raise_error(
|
37
|
-
ArgumentError, msg
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when a name of the fixture has no link to the home path' do
|
44
|
-
let(:fixture) do
|
45
|
-
instance_double(
|
46
|
-
'SPV::Fixture',
|
47
|
-
:has_link_to_home_path? => false
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'does not set any home path' do
|
52
|
-
expect(fixture).to_not receive(:set_home_path)
|
53
|
-
|
54
|
-
subject
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SitePrism::Page do
|
4
|
-
subject { SitePrism::Page.new }
|
5
|
-
|
6
|
-
let(:applier) do
|
7
|
-
instance_double(
|
8
|
-
'SPV::Applier',
|
9
|
-
apply_vcr: true
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
|
-
before do
|
14
|
-
SitePrism::Page.vcr_options_for_load { }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '.new' do
|
18
|
-
before do
|
19
|
-
SPV::Applier.stub(:new).and_return(applier)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'initializes the fixtures applier' do
|
23
|
-
expect(SPV::Applier).to receive(:new).with(
|
24
|
-
kind_of(described_class)
|
25
|
-
)
|
26
|
-
|
27
|
-
subject
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#load_and_apply_vcr' do
|
32
|
-
before do
|
33
|
-
subject.stub(:load)
|
34
|
-
subject.stub(:shift_event).and_yield.and_return(applier)
|
35
|
-
end
|
36
|
-
|
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
|
43
|
-
|
44
|
-
it 'applies vcr' do
|
45
|
-
expect(applier).to receive(:apply_vcr)
|
46
|
-
|
47
|
-
subject.load_and_apply_vcr
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|