tedium 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +17 -7
- data/lib/tedium/site_prism/form_dsl.rb +4 -1
- data/lib/tedium/version.rb +1 -1
- data/spec/features/fill_in_form_spec.rb +26 -2
- data/spec/fixtures/form.html +1 -1
- data/spec/fixtures/submitted_form.html +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8766bb089e801c3bef29f442029c3e7c646d5518
|
4
|
+
data.tar.gz: 9d1458219ddd62f9fb0070641b5e98d47a2173d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3036b24f0627c6c0bf929673e6201d8a0390a5b6da7d1d5250e107c27858e3fda8d519dece3986ab90ce93a45d64ebabe8e858210ec04ae80041d93fbb411fc7
|
7
|
+
data.tar.gz: 1903646b66c43c8e92e4fe5e7402ae5d37c9796feefc455989a51dd1f87ce2dea92c5f34a8a44e9967325120d9c0730d1901c16d4f6d8f316941518927a10ccc
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ class SignInPage < SitePrism::Page
|
|
12
12
|
fields :name, :email, :terms_of_service
|
13
13
|
submit_button
|
14
14
|
|
15
|
-
submission :sign_in
|
15
|
+
submission :sign_in
|
16
16
|
end
|
17
17
|
|
18
18
|
feature 'New user registration' do
|
@@ -38,8 +38,7 @@ Declares the presence of a field within the page. The selector used to find the
|
|
38
38
|
|
39
39
|
If the underlying attribute name differs from the name you want to give to the page object field, provide the attribute name as the second argument.
|
40
40
|
|
41
|
-
Once a `:foobar` field is declared, the page object will define a `#foobar_field` method, which will return the corresponding Capybara node.
|
42
|
-
element.
|
41
|
+
Once a `:foobar` field is declared, the page object will define a `#foobar_field` method, which will return the corresponding Capybara node element.
|
43
42
|
|
44
43
|
### fields
|
45
44
|
|
@@ -75,7 +74,7 @@ You can access to the specific hour and minute select elements with `.hour_eleme
|
|
75
74
|
submit_button(role = nil)
|
76
75
|
```
|
77
76
|
|
78
|
-
Declares the presence of a submit button within the page. It can be either a `input[type=select]` or a `button`. If you pass an argument to the method (ie. `submit_button :sign_in`), the selector will be augmented with a `[role='sign-in']` filter (please note the automatic *
|
77
|
+
Declares the presence of a submit button within the page. It can be either a `input[type=select]` or a `button`. If you pass an argument to the method (ie. `submit_button :sign_in`), the selector will be augmented with a `[role='sign-in']` filter (please note the automatic conversion in *snake-case*).
|
79
78
|
|
80
79
|
Once the submit button is declared, the page object will define a `#submit!`
|
81
80
|
method which will press the button.
|
@@ -83,7 +82,7 @@ method which will press the button.
|
|
83
82
|
### submission
|
84
83
|
|
85
84
|
```ruby
|
86
|
-
submission(name, fields)
|
85
|
+
submission(name, fields = nil)
|
87
86
|
```
|
88
87
|
|
89
88
|
Declares a submission process.
|
@@ -95,7 +94,7 @@ class SignInPage < SitePrism::Page
|
|
95
94
|
fields :name, :email, :terms_of_service
|
96
95
|
submit_button
|
97
96
|
|
98
|
-
submission :sign_in
|
97
|
+
submission :sign_in
|
99
98
|
end
|
100
99
|
```
|
101
100
|
|
@@ -110,6 +109,17 @@ def sign_in!(name, email, terms_of_service)
|
|
110
109
|
end
|
111
110
|
```
|
112
111
|
|
112
|
+
You can explicitly change the fields used during the submission (or their order) passing an array of field names as second argument:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
class SignInPage < SitePrism::Page
|
116
|
+
fields :name, :email, :terms_of_service
|
117
|
+
submit_button
|
118
|
+
|
119
|
+
submission :sign_in, %w(email name)
|
120
|
+
end
|
121
|
+
```
|
122
|
+
|
113
123
|
### action
|
114
124
|
|
115
125
|
```ruby
|
@@ -160,7 +170,7 @@ page.find_first('select').set('2')
|
|
160
170
|
|
161
171
|
## has_record?
|
162
172
|
|
163
|
-
Every SitePrism page inherits
|
173
|
+
Every SitePrism page inherits a `:record` SitePrism dynamic element, useful in conjunction with the [Rails `div_for` helper](http://devdocs.io/rails/actionview/helpers/recordtaghelper#method-i-div_for) or [Showcase Record trait](https://github.com/stefanoverna/showcase#showcasetraitsrecord):
|
164
174
|
|
165
175
|
```erb
|
166
176
|
<%= div_for(@person, class: "foo") do %>
|
@@ -5,6 +5,8 @@ module Tedium
|
|
5
5
|
module SitePrism
|
6
6
|
module FormDsl
|
7
7
|
def field(name, attribute_name = name)
|
8
|
+
@fields ||= []
|
9
|
+
@fields << name
|
8
10
|
element "#{name}_field", :input_for_field, attribute_name
|
9
11
|
end
|
10
12
|
|
@@ -32,7 +34,8 @@ module Tedium
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
def submission(name, fields)
|
37
|
+
def submission(name, fields = nil)
|
38
|
+
fields ||= @fields
|
36
39
|
define_method "#{name}!" do |*args|
|
37
40
|
Array(fields).each_with_index do |field, i|
|
38
41
|
send("#{field}_field").set(args[i])
|
data/lib/tedium/version.rb
CHANGED
@@ -9,6 +9,7 @@ describe 'Given a SitePrism page object with some fields and a submission' do
|
|
9
9
|
submit_button :sign_in
|
10
10
|
|
11
11
|
submission :sign_in, %w(email password)
|
12
|
+
submission :implicit_sign_in
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
@@ -28,8 +29,31 @@ describe 'Given a SitePrism page object with some fields and a submission' do
|
|
28
29
|
expect(page_object.submit_button).to be_present
|
29
30
|
end
|
30
31
|
|
31
|
-
it '
|
32
|
-
page_object.
|
32
|
+
it 'submits the form' do
|
33
|
+
page_object.submit!
|
34
|
+
expect(page).to have_content 'Submitted!'
|
35
|
+
end
|
36
|
+
|
37
|
+
context do
|
38
|
+
before do
|
39
|
+
page_object.stub(:submit!)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'performs the submission' do
|
43
|
+
page_object.sign_in!('foo@bar.com', 'qux')
|
44
|
+
|
45
|
+
expect(page_object.email_field.value).to eq 'foo@bar.com'
|
46
|
+
expect(page_object.password_field.value).to eq 'qux'
|
47
|
+
expect(page_object).to have_received(:submit!)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'performs the submission inferring the fields to fill in' do
|
51
|
+
page_object.implicit_sign_in!('foo@bar.com', 'qux')
|
52
|
+
|
53
|
+
expect(page_object.email_field.value).to eq 'foo@bar.com'
|
54
|
+
expect(page_object.password_field.value).to eq 'qux'
|
55
|
+
expect(page_object).to have_received(:submit!)
|
56
|
+
end
|
33
57
|
end
|
34
58
|
end
|
35
59
|
|
data/spec/fixtures/form.html
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tedium
|
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
|
- Stefano Verna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: site_prism
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- spec/fixtures/form.html
|
165
165
|
- spec/fixtures/record.html
|
166
166
|
- spec/fixtures/select.html
|
167
|
+
- spec/fixtures/submitted_form.html
|
167
168
|
- spec/spec_helper.rb
|
168
169
|
- tedium.gemspec
|
169
170
|
homepage: https://github.com/cantierecreativo/tedium
|
@@ -206,4 +207,5 @@ test_files:
|
|
206
207
|
- spec/fixtures/form.html
|
207
208
|
- spec/fixtures/record.html
|
208
209
|
- spec/fixtures/select.html
|
210
|
+
- spec/fixtures/submitted_form.html
|
209
211
|
- spec/spec_helper.rb
|