capybara-wheel 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +72 -3
- data/lib/capybara/wheel/element.rb +2 -2
- data/lib/capybara/wheel/page.rb +2 -2
- data/lib/capybara/wheel/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -32,6 +32,25 @@ Specs are always written in one uniform, clean, way - always calling the same mo
|
|
32
32
|
|
33
33
|
The Element model DSL is still eaily customisable just like "normal" page model classes so domain specfic applications are just as easy, resulting in descriptive, easy to read specs.
|
34
34
|
|
35
|
+
## Example spec:
|
36
|
+
|
37
|
+
feature "Supervillan Console" do
|
38
|
+
|
39
|
+
let(:supervillan_console) { SuperVillanConsole.new }
|
40
|
+
|
41
|
+
it 'can destroy the world with the push of a button' do
|
42
|
+
supervillan_console.visit do |page|
|
43
|
+
page.button_of_doom.should be_present
|
44
|
+
page.button_of_doom.click
|
45
|
+
|
46
|
+
# assert that world was destroyed
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
More spec goodness below.
|
53
|
+
|
35
54
|
## Installation
|
36
55
|
|
37
56
|
Add this line to your application's Gemfile:
|
@@ -117,7 +136,11 @@ Out of the box, Element accepts all the old familar Capybara Element actions / q
|
|
117
136
|
|
118
137
|
Passing a block to element gives access to the Element object for the purpose of implamenting a subelement (see below) or rolling your own customised methods:
|
119
138
|
|
120
|
-
**The
|
139
|
+
**The following messages are delegated to the native Capybara element callback.**
|
140
|
+
|
141
|
+
```
|
142
|
+
#find, #click, #has_content?, #checked?, #text, #visible?, #present?, #selected?, #disabled?, #tag_name, #value, #set, #select_option, #unselect_option, #hover
|
143
|
+
```
|
121
144
|
|
122
145
|
**_Example:_**
|
123
146
|
|
@@ -156,7 +179,7 @@ When called inside an element block, the element behaves like an Element but is
|
|
156
179
|
element 'ArmingKey', 'li.key' do
|
157
180
|
|
158
181
|
def turn
|
159
|
-
|
182
|
+
click
|
160
183
|
end
|
161
184
|
|
162
185
|
end
|
@@ -168,7 +191,7 @@ When called inside an element block, the element behaves like an Element but is
|
|
168
191
|
element 'ArmingKey', 'li.key' do
|
169
192
|
|
170
193
|
def turn
|
171
|
-
|
194
|
+
click
|
172
195
|
end
|
173
196
|
|
174
197
|
end
|
@@ -176,6 +199,52 @@ When called inside an element block, the element behaves like an Element but is
|
|
176
199
|
|
177
200
|
#=> SuperVillanConsole.new.button_of_world_peace.arming_key.turn
|
178
201
|
#=> SuperVillanConsole.new.button_of_doom.arming_key.turn
|
202
|
+
|
203
|
+
## Specs
|
204
|
+
|
205
|
+
Wheel specs are written to always refer to the models and to never refer to Capybara directly. The page methods we implemented above allows us the do:
|
206
|
+
|
207
|
+
let(:some_page) { SomePageModel.new }
|
208
|
+
|
209
|
+
it 'can visit a page' do
|
210
|
+
some_page.visit
|
211
|
+
end
|
212
|
+
|
213
|
+
The visit page would use the `on_page?` method to determine if we are indeed on the page. It will use Capyara's internal wait to poll the page until it is ready. We can then even excute within the scope of the page:
|
214
|
+
|
215
|
+
it 'can visit a page and pass a block to execute' do
|
216
|
+
some_page.visit do | page |
|
217
|
+
page.some_element.should be_visible
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'can also just check if we're on the page without visiting it'
|
222
|
+
some_page.on do | page |
|
223
|
+
page.some_element.should be_visible
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
|
228
|
+
**_Example:_**
|
229
|
+
|
230
|
+
feature "Supervillan Console" do
|
231
|
+
|
232
|
+
let(:supervillan_console) { SuperVillanConsole.new }
|
233
|
+
|
234
|
+
before :each do
|
235
|
+
supervillan_console.visit
|
236
|
+
end
|
237
|
+
|
238
|
+
scenario 'can arm doom button' do
|
239
|
+
supervillan_console.on do | con |
|
240
|
+
con.button_of_doom.arming_key.turn
|
241
|
+
con.button_of_doom.armed?.should be_true
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
|
246
|
+
end
|
247
|
+
|
179
248
|
***
|
180
249
|
***
|
181
250
|
***
|
@@ -17,6 +17,7 @@ module Capybara
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def_delegators :capybara_element,
|
20
|
+
:find,
|
20
21
|
:click,
|
21
22
|
:has_content?,
|
22
23
|
:checked?,
|
@@ -79,8 +80,7 @@ module Capybara
|
|
79
80
|
@selector
|
80
81
|
end
|
81
82
|
|
82
|
-
|
83
|
-
|
83
|
+
private
|
84
84
|
|
85
85
|
# Finds a capybara element representing this thing
|
86
86
|
def capybara_element
|
data/lib/capybara/wheel/page.rb
CHANGED
@@ -21,7 +21,7 @@ module Capybara
|
|
21
21
|
# execute a block in the context of this page
|
22
22
|
def on
|
23
23
|
unless on_page?
|
24
|
-
raise "We don't appear to be on #{
|
24
|
+
raise "We don't appear to be on the #{self.class}"
|
25
25
|
end
|
26
26
|
yield self if block_given?
|
27
27
|
self
|
@@ -38,7 +38,7 @@ module Capybara
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def has_title?(expected_title)
|
41
|
-
capybara.has_css?("head title", :
|
41
|
+
capybara.has_css?("head title", text: expected_title)
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.element(name, selector, &block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-wheel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|