napybara 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dea35db336bc51c0fc90751281e7fc09460ca9d8
4
- data.tar.gz: 0ad486329f004d1bd180333eb6ff8d109a130089
3
+ metadata.gz: aafff1aff960b383fbfc84e14791bb5914c1bc86
4
+ data.tar.gz: 8630038a9f727f4a5a817f3928e0caca46ae6186
5
5
  SHA512:
6
- metadata.gz: f15a944eda01a2496cbbf76b217139c2e5c75eff72ecc1ef9e1b3febe5dc9998c5ddf9fa0f8832294f14403a4590a8bd9e6828c03a303f0b9df54cd5fe012356
7
- data.tar.gz: 4856ea54f2bdbb92311ce06daea0ab463312bc09287df95af220972a8b76e676657025f6f261208b8a656828660a38d252c02ccdfa249b49ec3f069e8e82adf6
6
+ metadata.gz: e6bb6ef73196fa5f9c317fded3227fd5a891c399ddf1234b7d0b6a7660efad6a87545128e09f2e55bdcd61a073f73c74925bc19ccb63c960a0105b3ecbbe42f9
7
+ data.tar.gz: cb5b3de8e7da98bf601af1a5c3049cbb0751e317125a738c4691351c8691bac099974db653bfc555bab02a5abe642ba92372a0ffbeffbee2e98fdae7740bb19d
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## Master
4
+
5
+ ## 0.7.0
6
+
7
+ * Make Napybara::Element#inspect more readable.
8
+ * Be able to find the root of an element.
9
+
3
10
  ## 0.6.0
4
11
 
5
12
  Allow Capybara options to be passed to finders.
data/README.md CHANGED
@@ -130,7 +130,7 @@ friendly `has_no_css?` method.
130
130
 
131
131
  ## Finding all elements matching a selector
132
132
 
133
- Finally, `Napybara::Element#finder` adds a pluralized version of the finder. For example,
133
+ `Napybara::Element#finder` adds a pluralized version of the finder. For example,
134
134
 
135
135
  ```ruby
136
136
  let(:messages_page) do
@@ -147,6 +147,28 @@ expect(messages_page.messages[1].node.text).to eq("Kamusta mundo!")
147
147
 
148
148
  Napybara uses ActiveSupport to get the plural version of the finder name.
149
149
 
150
+ ## Finding the parent and root of an element
151
+
152
+ You can also get the parent and root of an element:
153
+
154
+ ```ruby
155
+ let(:messages_page) do
156
+ Napybara::Element.new(self) do |page|
157
+ page.finder :message_list, '.message-list' do |message_list|
158
+ message_list.finder :message, '.message'
159
+ end
160
+ end
161
+ end
162
+
163
+ # ...
164
+
165
+ expect(messages_page.message_list.messages[0].parent.selector)
166
+ .to eq(messages_page.message_list.selector)
167
+
168
+ expect(messages_page.message_list.messages[0].root.selector)
169
+ .to eq(messages_page.selector)
170
+ ```
171
+
150
172
  ## Adding custom methods to a Napybara element
151
173
 
152
174
  You can add new methods to a Napybara element with plain Ruby:
@@ -21,6 +21,14 @@ module Napybara
21
21
  appender.execute
22
22
  end
23
23
 
24
+ def inspect
25
+ %(#<Napybara::Element selector="#{selector}">)
26
+ end
27
+
28
+ def root
29
+ parent ? parent.parent : self
30
+ end
31
+
24
32
  def selector
25
33
  parent_selector = parent.try(:selector)
26
34
  parent_selector ? "#{parent_selector} #{selector_string}" : selector_string
@@ -1,3 +1,3 @@
1
1
  module Napybara
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -221,4 +221,28 @@ describe 'Readme example:' do
221
221
  expect(@messages_page.title.node.text).to eq('Your messages')
222
222
  end
223
223
  end
224
+
225
+ context do
226
+ let(:messages_page) do
227
+ Napybara::Element.new(capybara_page) do |page|
228
+ page.finder :message_list, '.messages-list' do |message_list|
229
+ message_list.finder :message, '.message'
230
+ end
231
+ end
232
+ end
233
+
234
+ Steps 'Finding the parent and root of an element' do
235
+ Given "I have a element with a child and grandchildren" do
236
+ messages_page
237
+ end
238
+
239
+ Then "I should be able to get the parent and root of that element" do
240
+ expect(messages_page.message_list.messages[0].parent.selector)
241
+ .to eq(messages_page.message_list.selector)
242
+
243
+ expect(messages_page.message_list.messages[0].root.selector)
244
+ .to eq(messages_page.selector)
245
+ end
246
+ end
247
+ end
224
248
  end
@@ -180,4 +180,19 @@ describe Napybara::Element do
180
180
  expect(napybara_page.buttons[0].image.selector).to eq('button img')
181
181
  end
182
182
  end
183
+
184
+ describe "#inspect" do
185
+ let(:napybara_page) do
186
+ described_class.new(capybara_page) do |page|
187
+ page.finder :button, 'button' do |button|
188
+ button.finder :image, 'img'
189
+ end
190
+ end
191
+ end
192
+
193
+ it "includes only the selector of the element" do
194
+ expect(napybara_page.buttons[0].image.inspect)
195
+ .to eq('#<Napybara::Element selector="button img">')
196
+ end
197
+ end
183
198
  end
metadata CHANGED
@@ -1,195 +1,195 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: napybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Mendoza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-15 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
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: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: capybara
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '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: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.5'
48
48
  type: :development
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: '1.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: fuubar
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: overcommit
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: poltergeist
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
131
  version: 2.14.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.14.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec-example_steps
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - '>='
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - '>='
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rubocop
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - '>='
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: sinatra
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ">="
171
+ - - '>='
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ">="
178
+ - - '>='
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: verified_double
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ">="
185
+ - - '>='
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ">="
192
+ - - '>='
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  description: DSL for nesting capybara helpers
@@ -199,11 +199,11 @@ executables: []
199
199
  extensions: []
200
200
  extra_rdoc_files: []
201
201
  files:
202
- - ".gitignore"
203
- - ".overcommit.yml"
204
- - ".rspec"
205
- - ".rubocop.yml"
206
- - ".travis.yml"
202
+ - .gitignore
203
+ - .overcommit.yml
204
+ - .rspec
205
+ - .rubocop.yml
206
+ - .travis.yml
207
207
  - CHANGELOG.md
208
208
  - Gemfile
209
209
  - Guardfile
@@ -237,12 +237,12 @@ require_paths:
237
237
  - lib
238
238
  required_ruby_version: !ruby/object:Gem::Requirement
239
239
  requirements:
240
- - - ">="
240
+ - - '>='
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0'
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  requirements:
245
- - - ">="
245
+ - - '>='
246
246
  - !ruby/object:Gem::Version
247
247
  version: '0'
248
248
  requirements: []