napybara 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +56 -14
  4. data/lib/napybara/version.rb +1 -1
  5. metadata +33 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d7b59ac7590d39a09e63cc572d21aa5c43f6c27
4
- data.tar.gz: 9f3b75d890dbed6b3d19a0d4413950a212e3088f
3
+ metadata.gz: 53a5710df7b6badb61d443588bec50cd7d179618
4
+ data.tar.gz: 61e611ff8fa988a70190860db4e0b8800cb010ce
5
5
  SHA512:
6
- metadata.gz: a6e6557bf502740bff951cca82f8a2fbd1f177cd725e04e2dc506b89118974231ef0a58a1dd64d022b3b53c102756855c284a65b9841f9792b20c915d0b64c2a
7
- data.tar.gz: fbb927c8fa87961f978213aa665a03622369cb427fa954985a358db171313394ebcaf02ee7cf08efa1e9b9c6a578ce28c040000ffdb7e87f87b8e5d900a674d1
6
+ metadata.gz: 7e25b434912b12dc7175089a32433d62a24ec4b1d8a533e80e4a86c46c98d6e04b157528aa37a7462dbaf930f51cd7e2f6725297db3366fc9ef0901f47f37503
7
+ data.tar.gz: 81beacfbd669927f9798c7c4ecec8333f88bbb16fe285aee98d0836f6ba7c6d3f87b5fa62ee744a8e44719bd9c41c055ae0a1879e48f509c44e24d523af92a22
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1
4
+
5
+ Update README.
6
+
7
+
3
8
  ## 0.4.0
4
9
 
5
10
  Require separate record selector for finding records.
data/README.md CHANGED
@@ -19,7 +19,7 @@ So you're writing an integration test for the following page:
19
19
  </html>
20
20
  ```
21
21
 
22
- Wouldn't it be nice if you can write test helpers so that they followed the page structure?
22
+ Wouldn't it be nice if your test helpers followed the page's structure?
23
23
 
24
24
  ```ruby
25
25
  messages_page.visit!
@@ -46,9 +46,9 @@ let(:messages_page) do
46
46
  end
47
47
  ```
48
48
 
49
- In Rails integration tests which use Capybara, `self` usually is the Capybara session.
49
+ In Rails integration tests which use Capybara, `self` is usually the Capybara session.
50
50
 
51
- You can get the capybara element wrapped by the Napybara element with
51
+ You can get the Capybara element wrapped by the Napybara element with
52
52
  `Napybara::Element#get`:
53
53
 
54
54
  ```ruby
@@ -90,7 +90,7 @@ end
90
90
  # ...
91
91
 
92
92
  expect(messages_page.message(some_message).get['id'])
93
- .to eq("messages-#{some_message.id}")
93
+ .to eq("message-#{some_message.id}")
94
94
 
95
95
  ```
96
96
 
@@ -110,7 +110,7 @@ With the Napybara elements above, you can call:
110
110
  expect(messages_page.has_form?).to be_true
111
111
  expect(messages_page).to have_form
112
112
 
113
- expect(messages_page.has_message?(some_message).to be_true
113
+ expect(messages_page.has_message?(some_message)).to be_true
114
114
  expect(messages_page).to have_message(some_message)
115
115
 
116
116
  non_existent_message = Message.find(3)
@@ -144,7 +144,7 @@ Napybara uses ActiveSupport to get the plural version of the finder name.
144
144
 
145
145
  ## Adding custom methods to a Napybara element
146
146
 
147
- We can add new methods to a Napybara element with plain Ruby:
147
+ You can add new methods to a Napybara element with plain Ruby:
148
148
 
149
149
  ```ruby
150
150
  let(:messages_page) do
@@ -188,28 +188,70 @@ messages_page.visit!
188
188
  expect(messages_page).to be_visited
189
189
  ```
190
190
 
191
+ ## Extending a Napybara element with a module with finders
192
+
193
+ And what if you want to share a module with finders? Again, with plain Ruby:
194
+
195
+ ```
196
+ module IsAForm
197
+ def submit!
198
+ submit_button.get.click
199
+ end
200
+
201
+ def self.add_to(form)
202
+ form.extend self
203
+ form.finder :submit_button, 'input[type=submit]'
204
+ end
205
+ end
206
+
207
+ # ...
208
+
209
+ page.finder :form, 'form.new-message' do |form|
210
+ IsAForm.add_to(form)
211
+ end
212
+ ```
213
+
214
+ It may not sexy, but it gets the job done :)
215
+
191
216
  ## Putting it all together
192
217
 
193
218
  Oh yeah, the "N" in Napybara stands for nesting. Here's how you can define the
194
219
  helpers at the start of this README:
195
220
 
196
221
  ```ruby
222
+
223
+ module PageExtensions
224
+ def visit!
225
+ get.visit get.messages_path
226
+ @visited = true
227
+ end
228
+
229
+ def visited?
230
+ !! @visited
231
+ end
232
+ end
233
+
234
+ module IsAForm
235
+ def submit!
236
+ submit_button.get.click
237
+ end
238
+
239
+ def self.add_to(form)
240
+ form.extend self
241
+ form.finder :submit_button, 'input[type=submit]'
242
+ end
243
+ end
244
+
197
245
  let(:messages_page) do
198
246
  Napybara::Element.new(capybara_page) do |page|
199
- def page.visit!
200
- get.visit get.messages_path
201
- end
247
+ page.extend PageExtensions
202
248
 
203
249
  page.finder :form, 'form.new-message' do |form|
204
- def form.submit!
205
- submit_button.get.click
206
- end
250
+ IsAForm.add_to form
207
251
 
208
252
  form.finder :message_row, '.message-row' do |row|
209
253
  row.finder :text_field, 'input[type=text]'
210
254
  end
211
-
212
- form.finder :submit_button, 'input[type=submit]'
213
255
  end
214
256
 
215
257
  page.finder :message, '.message-list .message', '#message-{id}'
@@ -1,3 +1,3 @@
1
1
  module Napybara
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,181 +1,181 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: napybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
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-05-01 00:00:00.000000000 Z
11
+ date: 2014-05-18 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: '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: '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
  description: DSL for nesting capybara helpers
@@ -185,11 +185,11 @@ executables: []
185
185
  extensions: []
186
186
  extra_rdoc_files: []
187
187
  files:
188
- - .gitignore
189
- - .overcommit.yml
190
- - .rspec
191
- - .rubocop.yml
192
- - .travis.yml
188
+ - ".gitignore"
189
+ - ".overcommit.yml"
190
+ - ".rspec"
191
+ - ".rubocop.yml"
192
+ - ".travis.yml"
193
193
  - CHANGELOG.md
194
194
  - Gemfile
195
195
  - Guardfile
@@ -219,12 +219,12 @@ require_paths:
219
219
  - lib
220
220
  required_ruby_version: !ruby/object:Gem::Requirement
221
221
  requirements:
222
- - - '>='
222
+ - - ">="
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - '>='
227
+ - - ">="
228
228
  - !ruby/object:Gem::Version
229
229
  version: '0'
230
230
  requirements: []