prismatic 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +0 -1
- data/README.md +31 -4
- data/lib/prismatic.rb +2 -0
- data/lib/prismatic/configuration.rb +31 -0
- data/lib/prismatic/element_container.rb +7 -2
- data/lib/prismatic/page.rb +27 -1
- data/lib/prismatic/section.rb +1 -1
- data/lib/prismatic/version.rb +1 -1
- data/prismatic.gemspec +2 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/unit/prismatic/configuration_spec.rb +54 -0
- data/spec/unit/prismatic/page_spec.rb +178 -24
- metadata +34 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4de90c9626cd6039b1246e18339c836a5ac409d
|
4
|
+
data.tar.gz: 029f05d754e03fb8fda36764af62a9be3223b734
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b2525abeb7c7b2866120e6a534af28bec2c22ffa5c630e62dee549606537fab2c1497e0554f2d65ce110b47d2fd1ed2e7ba7f65d792477660ceb25a71be141
|
7
|
+
data.tar.gz: 300bb6859b5f788c147bedb17dc9da1df6e661af6cc03675d06054048702152c640c76dcc89fdacf2484298a7c7ee9812bc77074da5750580d2b164e5435c80b
|
data/.rspec
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Prismatic
|
2
2
|
|
3
|
+
[][Continuous Integration]
|
4
|
+
[][Source Analysis]
|
5
|
+
[][Test Coverage]
|
6
|
+
|
7
|
+
* [Source Code]
|
8
|
+
* [API documentation]
|
9
|
+
* [Rubygem]
|
10
|
+
* [Continuous Integration]
|
11
|
+
|
12
|
+
[Source Code]: https://github.com/joeyates/prismatic "Source code at GitHub"
|
13
|
+
[API documentation]: http://rubydoc.info/gems/prismatic/frames "RDoc API Documentation at Rubydoc.info"
|
14
|
+
[Rubygem]: http://rubygems.org/gems/prismatic "Ruby gem at rubygems.org"
|
15
|
+
[Continuous Integration]: http://travis-ci.org/joeyates/prismatic "Build status by Travis-CI"
|
16
|
+
[Source Analysis]: https://codeclimate.com/github/joeyates/prismatic "Source code analysis by Code Climate"
|
17
|
+
[Test Coverage]: https://codeclimate.com/github/joeyates/prismatic "Test coverage by Code Climate"
|
18
|
+
|
3
19
|
Use a naming convention inside your HTML to describe the DOM elements you
|
4
20
|
want to access during tests. Prismatic will set up your SitePrism::Pages
|
5
21
|
with the intended Sections and Elements.
|
@@ -70,25 +86,36 @@ search_page.load
|
|
70
86
|
expect(search_page.search.start.text).to eq('Search')
|
71
87
|
```
|
72
88
|
|
89
|
+
## Warnings
|
90
|
+
|
91
|
+
* all Pages need an `url_matcher` so that Prismatic knows when a page is
|
92
|
+
actually loaded. If you don't specify one, Prismatic will create it
|
93
|
+
(see `auto_create_url_matcher` configuration setting),
|
94
|
+
* be careful with `wait_for_*`: you may need to manually define a section
|
95
|
+
or element you intend to use as a marker that content is loaded - Prismatic
|
96
|
+
won't create them until they are actually present.
|
97
|
+
|
73
98
|
## Configuration
|
74
99
|
|
75
100
|
In your test setup, do this:
|
76
101
|
|
77
102
|
```ruby
|
78
|
-
Prismatic.configure do
|
79
|
-
|
103
|
+
Prismatic.configure do
|
104
|
+
foo :bar
|
80
105
|
end
|
81
106
|
```
|
82
107
|
|
83
108
|
Configuration options:
|
84
109
|
|
85
110
|
* prefix: (default: 'prism'). By default, prismatic uses data attributes called
|
86
|
-
'data-prism-*'. Set prefix to another value to allow data
|
111
|
+
'data-prism-*'. Set prefix to another value to allow data attributes to be
|
87
112
|
named differently.
|
113
|
+
* auto_create_url_matcher: (default: true). If a Page has no `url_matcher` defined,
|
114
|
+
this sets it to a Regexp based on the Page's `url`.
|
88
115
|
|
89
116
|
## Contributing
|
90
117
|
|
91
|
-
1. Fork it ( https://github.com/
|
118
|
+
1. Fork it ( https://github.com/joeyates/prismatic/fork )
|
92
119
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
93
120
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
94
121
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/prismatic.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'docile'
|
2
|
+
|
3
|
+
module Prismatic::Configuration
|
4
|
+
OPTIONS_AND_DEFAULTS = {
|
5
|
+
prefix: 'prism',
|
6
|
+
auto_create_url_matcher: true,
|
7
|
+
}
|
8
|
+
|
9
|
+
OPTIONS_AND_DEFAULTS.each do |option, default|
|
10
|
+
define_method option do |value = :no_value_supplied|
|
11
|
+
v = "@#{option}"
|
12
|
+
if instance_variable_defined?(v) and value == :no_value_supplied
|
13
|
+
return instance_variable_get(v)
|
14
|
+
end
|
15
|
+
new_value = value == :no_value_supplied ? default : value
|
16
|
+
instance_variable_set(v, new_value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure(&block)
|
21
|
+
Docile.dsl_eval(self, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def reset_configuration
|
25
|
+
OPTIONS_AND_DEFAULTS.each do |option, default|
|
26
|
+
v = "@#{option}"
|
27
|
+
instance_variable_set(v, default)
|
28
|
+
end
|
29
|
+
true
|
30
|
+
end
|
31
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Prismatic::ElementContainer
|
2
2
|
private
|
3
3
|
|
4
|
-
def
|
4
|
+
def update_elements
|
5
5
|
find_matches 'element'
|
6
6
|
find_matches 'elements'
|
7
7
|
find_matches 'section'
|
@@ -13,6 +13,7 @@ module Prismatic::ElementContainer
|
|
13
13
|
|
14
14
|
find_all("[#{attribute}]").each do |el|
|
15
15
|
name = el[attribute]
|
16
|
+
next if has_instance_method?(self.class, name)
|
16
17
|
if is_section?(type)
|
17
18
|
self.class.send type.intern, name, Prismatic::Section, "[#{attribute}=\"#{name}\"]"
|
18
19
|
else
|
@@ -26,6 +27,10 @@ module Prismatic::ElementContainer
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def attribute_for(type)
|
29
|
-
"data
|
30
|
+
"data-#{Prismatic.prefix}-#{type}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_instance_method?(klass, method)
|
34
|
+
klass.instance_methods.include?(method.intern)
|
30
35
|
end
|
31
36
|
end
|
data/lib/prismatic/page.rb
CHANGED
@@ -3,6 +3,32 @@ class Prismatic::Page < SitePrism::Page
|
|
3
3
|
|
4
4
|
def load
|
5
5
|
super
|
6
|
-
|
6
|
+
optionally_update_elements
|
7
|
+
end
|
8
|
+
|
9
|
+
def respond_to?(method_id, include_all = false)
|
10
|
+
optionally_update_elements
|
11
|
+
methods.include?(method_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing(method_id, *args)
|
15
|
+
optionally_update_elements
|
16
|
+
return super unless methods.include?(method_id)
|
17
|
+
send(method_id, *args)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def optionally_update_elements
|
23
|
+
optionally_set_url_matcher
|
24
|
+
return unless displayed?(0)
|
25
|
+
update_elements
|
26
|
+
end
|
27
|
+
|
28
|
+
def optionally_set_url_matcher
|
29
|
+
return unless self.class.url_matcher.nil?
|
30
|
+
return if self.class.url.nil?
|
31
|
+
return unless Prismatic.auto_create_url_matcher
|
32
|
+
self.class.set_url_matcher %r(^https?://[^/]+#{self.class.url}([#\?].*)?$)
|
7
33
|
end
|
8
34
|
end
|
data/lib/prismatic/section.rb
CHANGED
data/lib/prismatic/version.rb
CHANGED
data/prismatic.gemspec
CHANGED
@@ -23,8 +23,10 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
25
|
spec.add_dependency 'site_prism', '~> 2.6'
|
26
|
+
spec.add_dependency 'docile', '~> 1.1'
|
26
27
|
|
27
28
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
28
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
29
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
+
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
|
30
32
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
require 'codeclimate-test-reporter'
|
3
|
+
|
2
4
|
spec_path = File.dirname(__FILE__)
|
3
5
|
$LOAD_PATH << File.expand_path('../lib', spec_path)
|
4
6
|
|
7
|
+
SimpleCov.start do
|
8
|
+
formatter SimpleCov::Formatter::MultiFormatter[
|
9
|
+
SimpleCov::Formatter::HTMLFormatter,
|
10
|
+
CodeClimate::TestReporter::Formatter
|
11
|
+
]
|
12
|
+
SimpleCov.start do
|
13
|
+
add_filter '/spec/'
|
14
|
+
add_filter '/vendor/'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
require 'prismatic'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'prismatic'
|
2
|
+
|
3
|
+
describe Prismatic::Configuration do
|
4
|
+
after do
|
5
|
+
Prismatic.reset_configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
[
|
9
|
+
[:prefix, 'prism', 'foo'],
|
10
|
+
[:auto_create_url_matcher, true, false],
|
11
|
+
].each do |option, default, new_value|
|
12
|
+
describe "##{option}" do
|
13
|
+
it 'returns the value' do
|
14
|
+
expect(Prismatic.send(option)).to eq(default)
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'setting' do
|
18
|
+
it 'sets the value' do
|
19
|
+
Prismatic.send(option, new_value)
|
20
|
+
expect(Prismatic.send(option)).to eq(new_value)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "accepts 'nil'" do
|
24
|
+
Prismatic.send(option, nil)
|
25
|
+
expect(Prismatic.send(option)).to eq(nil)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the value' do
|
29
|
+
expect(Prismatic.send(option, new_value)).to eq(new_value)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context '.configure' do
|
36
|
+
it 'sets values in the block' do
|
37
|
+
Prismatic.configure do
|
38
|
+
prefix 'bar'
|
39
|
+
end
|
40
|
+
|
41
|
+
expect(Prismatic.prefix).to eq('bar')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context '.reset_configuration' do
|
46
|
+
it 'resets options to defaults' do
|
47
|
+
Prismatic.prefix 'aaaaaaa'
|
48
|
+
|
49
|
+
Prismatic.reset_configuration
|
50
|
+
|
51
|
+
expect(Prismatic.prefix).to eq('prism')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,7 +1,3 @@
|
|
1
|
-
class MyPage < Prismatic::Page
|
2
|
-
set_url '/'
|
3
|
-
end
|
4
|
-
|
5
1
|
describe Prismatic::Page do
|
6
2
|
def make_element(name, attribute)
|
7
3
|
el = double(Capybara::Node::Element)
|
@@ -15,7 +11,11 @@ describe Prismatic::Page do
|
|
15
11
|
el
|
16
12
|
end
|
17
13
|
|
18
|
-
let(:page) { double(Capybara::Session, visit: nil) }
|
14
|
+
let(:page) { double(Capybara::Session, visit: nil, current_url: current_url) }
|
15
|
+
let(:current_url) { non_matching_url } # this means the page is not displayed
|
16
|
+
let(:matching_url) { 'http://example.com/search' }
|
17
|
+
let(:non_matching_url) { 'http://example.com/quux' }
|
18
|
+
|
19
19
|
let(:page_element_array) { [] }
|
20
20
|
let(:page_elements_array) { [] }
|
21
21
|
let(:page_section_array) { [] }
|
@@ -23,28 +23,73 @@ describe Prismatic::Page do
|
|
23
23
|
let(:singleton_element) { make_element('foo', 'data-prism-element') }
|
24
24
|
let(:collection_element) { make_element('bar', 'data-prism-elements') }
|
25
25
|
|
26
|
-
|
26
|
+
before do
|
27
|
+
allow(Capybara).to receive(:current_session).and_return(page)
|
28
|
+
allow(page).to receive(:all).with('[data-prism-element]').and_return(page_element_array)
|
29
|
+
allow(page).to receive(:all).with('[data-prism-elements]').and_return(page_elements_array)
|
30
|
+
allow(page).to receive(:all).with('[data-prism-section]').and_return(page_section_array)
|
31
|
+
allow(page).to receive(:all).with('[data-prism-sections]').and_return(page_sections_array)
|
32
|
+
end
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
34
|
+
# As 'url' and 'url_matcher' get set on the class itself,
|
35
|
+
# we use different subclasses for each example
|
36
|
+
let(:klass) do
|
37
|
+
Class.new(Prismatic::Page) do
|
38
|
+
set_url '/search'
|
33
39
|
end
|
40
|
+
end
|
41
|
+
subject { klass.new }
|
42
|
+
|
43
|
+
specify { expect(subject).to be_a(SitePrism::Page) }
|
44
|
+
|
45
|
+
context 'configuration' do
|
46
|
+
let(:current_url) { matching_url }
|
47
|
+
let(:prefix) { 'hello' }
|
48
|
+
let(:singleton_element) { make_element('foo', "data-#{prefix}-element") }
|
34
49
|
|
35
50
|
before do
|
36
|
-
allow(
|
37
|
-
allow(page).to receive(:all).with(
|
38
|
-
allow(page).to receive(:all).with(
|
39
|
-
allow(page).to receive(:all).with(
|
40
|
-
allow(page).to receive(:
|
51
|
+
allow(page).to receive(:all).with("[data-#{prefix}-element]").and_return([singleton_element])
|
52
|
+
allow(page).to receive(:all).with("[data-#{prefix}-elements]").and_return([])
|
53
|
+
allow(page).to receive(:all).with("[data-#{prefix}-section]").and_return([])
|
54
|
+
allow(page).to receive(:all).with("[data-#{prefix}-sections]").and_return([])
|
55
|
+
allow(page).to receive(:find).with("[data-#{prefix}-element=\"foo\"]").and_return(singleton_element)
|
41
56
|
end
|
42
57
|
|
58
|
+
after { Prismatic.reset_configuration }
|
59
|
+
|
60
|
+
context 'when a prefix is configured' do
|
61
|
+
before { Prismatic.prefix prefix }
|
62
|
+
|
63
|
+
it 'is used' do
|
64
|
+
subject.load
|
65
|
+
expect(subject.foo).to be(singleton_element)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when auto_create_url_matcher is set to false' do
|
70
|
+
before { Prismatic.auto_create_url_matcher false }
|
71
|
+
|
72
|
+
it 'fails to create elements' do
|
73
|
+
expect do
|
74
|
+
subject.load
|
75
|
+
end.to raise_error
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#load' do
|
81
|
+
let(:current_url) { matching_url }
|
82
|
+
|
43
83
|
context "for 'data-prism-element' attributes" do
|
44
84
|
let(:page_element_array) { [singleton_element] }
|
45
85
|
|
86
|
+
before do
|
87
|
+
allow(page).to receive(:find).with("[data-prism-element=\"foo\"]").and_return(singleton_element)
|
88
|
+
subject.load
|
89
|
+
end
|
90
|
+
|
46
91
|
it "creates a single element" do
|
47
|
-
expect(subject).to
|
92
|
+
expect(subject.foo).to be(singleton_element)
|
48
93
|
end
|
49
94
|
end
|
50
95
|
|
@@ -54,6 +99,7 @@ describe Prismatic::Page do
|
|
54
99
|
|
55
100
|
before do
|
56
101
|
allow(page).to receive(:all).with('[data-prism-elements="bar"]').and_return(bar_elements_array)
|
102
|
+
subject.load
|
57
103
|
end
|
58
104
|
|
59
105
|
it "creates an arrays of elements" do
|
@@ -80,8 +126,12 @@ describe Prismatic::Page do
|
|
80
126
|
allow(singleton_section).to receive(:all).with('[data-prism-sections]').and_return(nested_sections_array)
|
81
127
|
end
|
82
128
|
|
83
|
-
|
84
|
-
|
129
|
+
context 'the section' do
|
130
|
+
before { subject.load }
|
131
|
+
|
132
|
+
it "is created" do
|
133
|
+
expect(subject.send(section_name.intern)).to be_a(Prismatic::Section)
|
134
|
+
end
|
85
135
|
end
|
86
136
|
|
87
137
|
context "with contained 'data-prism-element' attributes" do
|
@@ -89,7 +139,8 @@ describe Prismatic::Page do
|
|
89
139
|
|
90
140
|
before do
|
91
141
|
allow(singleton_section).to receive(:find).with('[data-prism-element="foo"]').and_return(singleton_element)
|
92
|
-
allow(singleton_section).to receive(:find).with('[data-prism-elements="
|
142
|
+
allow(singleton_section).to receive(:find).with('[data-prism-elements="bar"]').and_return([])
|
143
|
+
subject.load
|
93
144
|
end
|
94
145
|
|
95
146
|
it 'creates an element' do
|
@@ -101,14 +152,15 @@ describe Prismatic::Page do
|
|
101
152
|
let(:bar_elements_array) { [collection_element] }
|
102
153
|
|
103
154
|
before do
|
104
|
-
allow(singleton_section).to receive(:all).with('[data-prism-element="foo"]').and_return(
|
105
|
-
allow(singleton_section).to receive(:all).with('[data-prism-elements="
|
155
|
+
allow(singleton_section).to receive(:all).with('[data-prism-element="foo"]').and_return([])
|
156
|
+
allow(singleton_section).to receive(:all).with('[data-prism-elements="bar"]').and_return(bar_elements_array)
|
106
157
|
allow(singleton_section).to receive(:find).with('[data-prism-element="foo"]').and_return([])
|
107
|
-
allow(singleton_section).to receive(:find).with('[data-prism-elements="
|
158
|
+
allow(singleton_section).to receive(:find).with('[data-prism-elements="bar"]').and_return(collection_element)
|
159
|
+
subject.load
|
108
160
|
end
|
109
161
|
|
110
162
|
it 'creates an element array' do
|
111
|
-
expect(subject.send(section_name).
|
163
|
+
expect(subject.send(section_name).bar).to be_a(Array)
|
112
164
|
end
|
113
165
|
end
|
114
166
|
|
@@ -116,6 +168,8 @@ describe Prismatic::Page do
|
|
116
168
|
let(:baz_section) { make_section('baz', 'data-prism-section') }
|
117
169
|
let(:nested_section_array) { [baz_section] }
|
118
170
|
|
171
|
+
before { subject.load }
|
172
|
+
|
119
173
|
it "creates a heirarchy of sections containing elements" do
|
120
174
|
expect(subject.send(section_name)).to respond_to(:baz)
|
121
175
|
end
|
@@ -137,6 +191,7 @@ describe Prismatic::Page do
|
|
137
191
|
allow(section_collection_member).to receive(:all).with('[data-prism-elements]').and_return(bar_elements_array)
|
138
192
|
allow(section_collection_member).to receive(:all).with('[data-prism-section]').and_return([])
|
139
193
|
allow(section_collection_member).to receive(:all).with('[data-prism-sections]').and_return([])
|
194
|
+
subject.load
|
140
195
|
end
|
141
196
|
|
142
197
|
it "creates an array of sections" do
|
@@ -145,4 +200,103 @@ describe Prismatic::Page do
|
|
145
200
|
end
|
146
201
|
end
|
147
202
|
end
|
203
|
+
|
204
|
+
shared_examples 'optionally creates elements' do |action|
|
205
|
+
context 'when the page is not displayed' do
|
206
|
+
let(:current_url) { non_matching_url }
|
207
|
+
|
208
|
+
before do
|
209
|
+
allow(page).to receive(:all)
|
210
|
+
action.call subject
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'does nothing' do
|
214
|
+
expect(page).to_not have_received(:all)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
context 'when the page is displayed' do
|
219
|
+
let(:current_url) { matching_url }
|
220
|
+
let(:page_element_array) { [singleton_element] }
|
221
|
+
|
222
|
+
before do
|
223
|
+
allow(page).to receive(:all).with("[data-prism-element]").and_return([singleton_element])
|
224
|
+
allow(page).to receive(:find).with("[data-prism-element=\"foo\"]").and_return(singleton_element)
|
225
|
+
action.call subject
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'creates elements' do
|
229
|
+
# stop elements being created:
|
230
|
+
allow(page).to receive(:find).with("[data-prism-element]").and_return([])
|
231
|
+
expect(subject.foo).to be(singleton_element)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
describe '#respond_to?' do
|
237
|
+
action = ->(subject) { subject.respond_to?(:baz) }
|
238
|
+
include_examples 'optionally creates elements', action
|
239
|
+
end
|
240
|
+
|
241
|
+
describe '#method_missing' do
|
242
|
+
action = ->(subject) { subject.baz rescue nil }
|
243
|
+
include_examples 'optionally creates elements', action
|
244
|
+
|
245
|
+
context 'with truly missing methods' do
|
246
|
+
specify 'raise an error' do
|
247
|
+
expect do
|
248
|
+
subject.baz
|
249
|
+
end.to raise_error(NoMethodError)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
context 'on-the-fly methods' do
|
254
|
+
let(:current_url) { matching_url }
|
255
|
+
let(:page_element_array) { [singleton_element] }
|
256
|
+
|
257
|
+
before do
|
258
|
+
allow(page).to receive(:all).with("[data-prism-element]").and_return([singleton_element])
|
259
|
+
allow(page).to receive(:find).with("[data-prism-element=\"foo\"]").and_return(singleton_element)
|
260
|
+
end
|
261
|
+
|
262
|
+
specify 'get called' do
|
263
|
+
expect(subject.foo).to eq(singleton_element)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
context 'on-the-fly methods' do
|
269
|
+
let(:current_url) { matching_url }
|
270
|
+
let(:page_element_array) { [singleton_element] }
|
271
|
+
|
272
|
+
before do
|
273
|
+
allow(page).to receive(:all).with("[data-prism-element]").and_return([singleton_element])
|
274
|
+
allow(page).to receive(:find).with("[data-prism-element=\"foo\"]").and_return(singleton_element)
|
275
|
+
end
|
276
|
+
|
277
|
+
specify "don't replace existing methods" do
|
278
|
+
subject.class.send(:define_method, :foo) { 'hello' }
|
279
|
+
|
280
|
+
subject.baz rescue nil
|
281
|
+
|
282
|
+
expect(subject.foo).to eq('hello')
|
283
|
+
end
|
284
|
+
|
285
|
+
context 'with dynamic content' do
|
286
|
+
specify 'missing methods are created on successive updates' do
|
287
|
+
# Initially it's not there:
|
288
|
+
allow(page).to receive(:all).with("[data-prism-element]").and_return([])
|
289
|
+
subject.baz rescue nil
|
290
|
+
|
291
|
+
expect(subject.methods).to_not include(:foo)
|
292
|
+
|
293
|
+
# Then it appears:
|
294
|
+
allow(page).to receive(:all).with("[data-prism-element]").and_return([singleton_element])
|
295
|
+
subject.baz rescue nil
|
296
|
+
|
297
|
+
expect(subject.methods).to include(:foo)
|
298
|
+
expect(subject.foo).to eq(singleton_element)
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
148
302
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prismatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: site_prism
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: docile
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codeclimate-test-reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.4'
|
69
97
|
description: 'Thanks to a naming convention, Prismatic recognises the DOM elements
|
70
98
|
in your web pages that you intend to access during integration tests and automatically
|
71
99
|
creates the intended SitePrism sections and elements. '
|
@@ -77,17 +105,20 @@ extra_rdoc_files: []
|
|
77
105
|
files:
|
78
106
|
- ".gitignore"
|
79
107
|
- ".rspec"
|
108
|
+
- ".travis.yml"
|
80
109
|
- Gemfile
|
81
110
|
- LICENSE.txt
|
82
111
|
- README.md
|
83
112
|
- Rakefile
|
84
113
|
- lib/prismatic.rb
|
114
|
+
- lib/prismatic/configuration.rb
|
85
115
|
- lib/prismatic/element_container.rb
|
86
116
|
- lib/prismatic/page.rb
|
87
117
|
- lib/prismatic/section.rb
|
88
118
|
- lib/prismatic/version.rb
|
89
119
|
- prismatic.gemspec
|
90
120
|
- spec/spec_helper.rb
|
121
|
+
- spec/unit/prismatic/configuration_spec.rb
|
91
122
|
- spec/unit/prismatic/page_spec.rb
|
92
123
|
homepage: https://github.com/joeyates/prismatic
|
93
124
|
licenses:
|
@@ -115,5 +146,6 @@ specification_version: 4
|
|
115
146
|
summary: Automate SitePrism's access to DOM elements
|
116
147
|
test_files:
|
117
148
|
- spec/spec_helper.rb
|
149
|
+
- spec/unit/prismatic/configuration_spec.rb
|
118
150
|
- spec/unit/prismatic/page_spec.rb
|
119
151
|
has_rdoc:
|