tedium 0.0.1 → 0.0.2

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: 258164c5ea7bfe3aa42b680ae6d6a2443a96d9c1
4
- data.tar.gz: 8e9d628b16f9645b89200f7b8ff0e6e983f82ddd
3
+ metadata.gz: 40026ddb3d89f0c51494434b3fe167775c509a3f
4
+ data.tar.gz: ca15f4b60a8ac79a3d83f6290d900f31509425c3
5
5
  SHA512:
6
- metadata.gz: cd72b84371b4180094a5fdce5492729a012463d442e222c2ec8d17cbf7d73e11ccb8c20e03e7f60f9a806e3e77bdd972f243a3dc224fb86d36f4bd8241d659f0
7
- data.tar.gz: 745577fab02b9c49ccf801499709a63d104e95ec4c96a747d5c1ec31dad25f78e9c4df8a902be4af21ebeb82f6e6cf5164839240501c06b961639feba19d2776
6
+ metadata.gz: 909797fff65e5be7cbb1661a81e0891a33d2a49bb0e3d048d31c0ddd30cfd369314c5350d505b67882ed4bd7a5c9e6c0c5f990af01970cff4b15772fed187e8d
7
+ data.tar.gz: 84b1b77f8bbcfd590f353c39cf4536eb4991431eb0cbd1d8816be797c3b63a5158cc7849f4b2585e4dffc760b4f17c2c85e9cc4100f5b43a120fdf7a296399a8
@@ -0,0 +1,10 @@
1
+ # v0.0.2
2
+
3
+ * add `datetime_field` DSL method to manage Rails `datetime_select` HTML
4
+ * `:option_with_value_or_label` selector converts to string the passed value
5
+ * `#has_record?` redefinition using `.element` SitePrism DSL (which gives us all the other helpers)
6
+
7
+ # v0.0.1
8
+
9
+ * First release!
10
+
@@ -0,0 +1,40 @@
1
+ # Contributing
2
+
3
+ We love pull requests. Here's a quick guide:
4
+
5
+ 1. Fork the repo.
6
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
7
+ to know that you have a clean slate: `bundle && rake`
8
+ 3. Add a test for your change. Only refactoring and documentation changes
9
+ require no new tests. If you are adding functionality or fixing a bug, we need
10
+ a test!
11
+ 4. Make the test pass.
12
+ 5. Make sure your changes adhere to the [thoughtbot Style
13
+ Guide](https://github.com/thoughtbot/guides/tree/master/style)
14
+ 6. Push to your fork and submit a pull request.
15
+ 7. At this point you're waiting on us. We like to at least comment on, if not
16
+ accept, pull requests within three business days (and, typically, one business
17
+ day). [We may suggest some changes or improvements or
18
+ alternatives](https://github.com/thoughtbot/guides/tree/master/code-review).
19
+
20
+ ## Increase your chances of getting merged
21
+
22
+ Some things that will increase the chance that your pull request is accepted,
23
+ taken straight from the Ruby on Rails guide:
24
+
25
+ * Use Rails idioms and helpers
26
+ * Include tests that fail without your code, and pass with it
27
+ * Update the documentation: that surrounding your change, examples elsewhere,
28
+ guides, and whatever else is affected by your contribution
29
+ * Syntax:
30
+ * Two spaces, no tabs.
31
+ * No trailing whitespace. Blank lines should not have any space.
32
+ * Make sure your [source files end with newline
33
+ characters](http://stackoverflow.com/questions/729692/why-should-files-end-with-a-newline#answer-729725).
34
+ * Prefer `&&`/`||` over `and`/`or`.
35
+ * `MyClass.my_method(my_arg)` not `my_method( my_arg )` or
36
+ `my_method my_arg`.
37
+ * `a = b` and not `a=b`.
38
+ * Follow the conventions you see used in the source already.
39
+ * And in case we didn't emphasize it enough: *We love tests!*
40
+
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in tedium.gemspec
4
3
  gemspec
4
+
5
+ gem 'coveralls', require: false
6
+
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Tedium
2
2
 
3
3
  [![Build Status](https://travis-ci.org/cantierecreativo/tedium.png?branch=master)](https://travis-ci.org/cantierecreativo/tedium)
4
+ [![Coverage Status](https://coveralls.io/repos/cantierecreativo/tedium/badge.png)](https://coveralls.io/r/cantierecreativo/tedium)
4
5
 
5
- Remove the tedium of formulaic form filling with SitePrism and Capybara. Tedium allows you to specify a set of fields and actions to be performed rather than procedurally calling Capybara’s DSL methods on SitePrism elements.
6
+ Remove the tedium of formulaic form filling with [SitePrism](https://github.com/natritmeyer/site_prism) and [Capybara](https://github.com/jnicklas/capybara). Tedium allows you to specify a set of fields and actions to be performed rather than procedurally calling Capybara’s DSL methods on SitePrism elements.
6
7
 
7
8
  ## Usage
8
9
 
@@ -58,6 +59,16 @@ Declares the presence of a `date_select` set of selects within the page. Once a
58
59
 
59
60
  You can access to the specific year select element with `date_of_birth_field.year_element` method (the same applies also for month and day selects).
60
61
 
62
+ ### datetime_field
63
+
64
+ ```ruby
65
+ datetime_field(name, attribute_name = name)
66
+ ```
67
+
68
+ Similar to `date_field`, it declares the presence of a `datetime_select` set of selects within the page.
69
+
70
+ You can access to the specific hour and minute select elements with `.hour_element` and `.minute_element` method.
71
+
61
72
  ### submit_button
62
73
 
63
74
  ```ruby
@@ -105,10 +116,23 @@ end
105
116
  action(name, role = name)
106
117
  ```
107
118
 
108
- Declares the presence of an action button/link within the page. Once a `:sign_out` action is declared, the page object will define a `#sign_out_element` method, which will return the corresponding Capybara node and a `#sign_out!` method, which will click on the element.
119
+ Declares the presence of an action button/link within the page. Once a `:sign_out` action is declared, the page object will define a `#sign_out_element` method, which will return the corresponding Capybara node and a `#sign_out!` method, which will perform a click on the element.
109
120
 
110
121
  The selector relies on a `role` attribute present in the action element (see `submit_button` for details). If the role attribute differs from the name you want to give to the page object action, provide it as a second argument.
111
122
 
123
+ ```html
124
+ <a href="/session" data-method="delete" role="sign-out">Sign out</a>
125
+ ```
126
+ ```ruby
127
+ class DashboardPage < SitePrism::Page
128
+ action :sign_out
129
+ end
130
+
131
+ page = DashboardPage.load
132
+ page.sign_out_element # => <Capybara::Node::Element ...>
133
+ page.sign_out! # clicks on the link
134
+ ```
135
+
112
136
  ### actions
113
137
 
114
138
  ```ruby
@@ -117,9 +141,9 @@ actions(*names)
117
141
 
118
142
  If you need to declare multiple actions at once, you can use this batch method.
119
143
 
120
- ### Changes to the Capybara node element #set method
144
+ ## Changes to the Capybara node element #set method
121
145
 
122
- In order to fill in text inputs, selects and checkboxes using the same API, Tedium extends the default `Capybara::Node::Element#set` behaviour, so that it will select the first option matching either the its value or its text:
146
+ In order to be able to fill in text inputs, selects and checkboxes using the same API, Tedium slightly extends the default `Capybara::Node::Element#set` behaviour. If the element is a select, the first option with a value or text that matches the provided value will be selected:
123
147
 
124
148
  ```html
125
149
  <select>
@@ -134,9 +158,9 @@ page.find_first('select').set('Option 2')
134
158
  page.find_first('select').set('2')
135
159
  ```
136
160
 
137
- ### has_record?
161
+ ## has_record?
138
162
 
139
- Every SitePrism page inherits the `has_record?(record)` method, useful in conjunction with the [Rails `div_for` helper](http://devdocs.io/rails/actionview/helpers/recordtaghelper#method-i-div_for):
163
+ Every SitePrism page inherits the `has_record?(record)` method, 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):
140
164
 
141
165
  ```erb
142
166
  <%= div_for(@person, class: "foo") do %>
@@ -145,6 +169,6 @@ Every SitePrism page inherits the `has_record?(record)` method, useful in conjun
145
169
  ```
146
170
 
147
171
  ```ruby
148
- expect(page).to have_record(@person) # this PASSes
172
+ expect(page).to have_record(@person) # green!
149
173
  ```
150
174
 
@@ -66,6 +66,7 @@ Capybara.add_selector :option_with_value_or_label do
66
66
  label 'option with value or label'
67
67
 
68
68
  xpath do |value|
69
+ value = value.to_s
69
70
  XPath.descendant(:option)[XPath.text.equals(value) | XPath.attr(:value).equals(value)]
70
71
  end
71
72
  end
@@ -1,4 +1,5 @@
1
1
  require "tedium/virtual_date_element"
2
+ require "tedium/virtual_datetime_element"
2
3
 
3
4
  module Tedium
4
5
  module SitePrism
@@ -17,6 +18,12 @@ module Tedium
17
18
  end
18
19
  end
19
20
 
21
+ def datetime_field(name, attribute_name = name)
22
+ define_method "#{name}_field" do
23
+ VirtualDateTimeElement.new(root_element_or_page, attribute_name)
24
+ end
25
+ end
26
+
20
27
  def submit_button(role = nil)
21
28
  element :submit_button, :submit_button, role
22
29
 
@@ -1,8 +1,8 @@
1
1
  module Tedium
2
2
  module SitePrism
3
3
  module HasRecord
4
- def has_record?(record)
5
- element_exists?(:record, record)
4
+ def self.included(base)
5
+ base.element :record, :record
6
6
  end
7
7
  end
8
8
  end
@@ -1,3 +1,4 @@
1
1
  module Tedium
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
4
+
@@ -0,0 +1,16 @@
1
+ class VirtualDateTimeElement < VirtualDateElement
2
+ def set(datetime)
3
+ super datetime
4
+ hour_element.set(datetime.hour.to_s.rjust(2, '0'))
5
+ minute_element.set(datetime.min.to_s.rjust(2, '0'))
6
+ end
7
+
8
+ def hour_element
9
+ token_element('4i')
10
+ end
11
+
12
+ def minute_element
13
+ token_element('5i')
14
+ end
15
+ end
16
+
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Given a SitePrism page object with a datetime field' do
4
+ let(:page_object) { page_object_klass.new }
5
+
6
+ let(:page_object_klass) do
7
+ Class.new(SitePrism::Page) do
8
+ datetime_field :start_at
9
+ end
10
+ end
11
+
12
+ before do
13
+ visit 'datetime'
14
+ end
15
+
16
+ it 'fills up all the tokens' do
17
+ page_object.start_at_field.set Time.new(2014, 05, 22, 9, 30)
18
+
19
+ expect(page_object.start_at_field.year_element.value).to eq '2014'
20
+ expect(page_object.start_at_field.month_element.value).to eq '5'
21
+ expect(page_object.start_at_field.day_element.value).to eq '22'
22
+ expect(page_object.start_at_field.hour_element.value).to eq '09'
23
+ expect(page_object.start_at_field.minute_element.value).to eq '30'
24
+ end
25
+ end
26
+
@@ -0,0 +1,144 @@
1
+ <select name="event[start_at(1i)]">
2
+ <option value="2020">2020</option>
3
+ <option value="2019">2019</option>
4
+ <option value="2018">2018</option>
5
+ <option value="2017">2017</option>
6
+ <option value="2016">2016</option>
7
+ <option value="2015">2015</option>
8
+ <option value="2014">2014</option>
9
+ </select>
10
+ <select name="event[start_at(2i)]">
11
+ <option value="1">January</option>
12
+ <option value="2">February</option>
13
+ <option value="3">March</option>
14
+ <option value="4">April</option>
15
+ <option value="5">May</option>
16
+ <option value="6">June</option>
17
+ <option value="7">July</option>
18
+ <option value="8">August</option>
19
+ <option value="9">September</option>
20
+ <option value="10">October</option>
21
+ <option value="11">November</option>
22
+ <option value="12">December</option>
23
+ </select>
24
+ <select name="event[start_at(3i)]">
25
+ <option value="1">1</option>
26
+ <option value="2">2</option>
27
+ <option value="3">3</option>
28
+ <option value="4">4</option>
29
+ <option value="5">5</option>
30
+ <option value="6">6</option>
31
+ <option value="7">7</option>
32
+ <option value="8">8</option>
33
+ <option value="9">9</option>
34
+ <option value="10">10</option>
35
+ <option value="11">11</option>
36
+ <option value="12">12</option>
37
+ <option value="13">13</option>
38
+ <option value="14">14</option>
39
+ <option value="15">15</option>
40
+ <option value="16">16</option>
41
+ <option value="17">17</option>
42
+ <option value="18">18</option>
43
+ <option value="19">19</option>
44
+ <option value="20">20</option>
45
+ <option value="21">21</option>
46
+ <option value="22">22</option>
47
+ <option value="23">23</option>
48
+ <option value="24">24</option>
49
+ <option value="25">25</option>
50
+ <option value="26">26</option>
51
+ <option value="27">27</option>
52
+ <option value="28">28</option>
53
+ <option value="29">29</option>
54
+ <option value="30">30</option>
55
+ <option value="31">31</option>
56
+ </select>
57
+ <select name="event[start_at(4i)]">
58
+ <option value="00">00</option>
59
+ <option value="01">01</option>
60
+ <option value="02">02</option>
61
+ <option value="03">03</option>
62
+ <option value="04">04</option>
63
+ <option value="05">05</option>
64
+ <option value="06">06</option>
65
+ <option value="07">07</option>
66
+ <option value="08">08</option>
67
+ <option value="09">09</option>
68
+ <option value="10">10</option>
69
+ <option value="11">11</option>
70
+ <option value="12">12</option>
71
+ <option value="13">13</option>
72
+ <option value="14">14</option>
73
+ <option value="15">15</option>
74
+ <option value="16">16</option>
75
+ <option value="17">17</option>
76
+ <option value="18">18</option>
77
+ <option value="19">19</option>
78
+ <option value="20">20</option>
79
+ <option value="21">21</option>
80
+ <option value="22">22</option>
81
+ <option value="23">23</option>
82
+ </select>
83
+ <select name="event[start_at(5i)]">
84
+ <option value="00">00</option>
85
+ <option value="01">01</option>
86
+ <option value="02">02</option>
87
+ <option value="03">03</option>
88
+ <option value="04">04</option>
89
+ <option value="05">05</option>
90
+ <option value="06">06</option>
91
+ <option value="07">07</option>
92
+ <option value="08">08</option>
93
+ <option value="09">09</option>
94
+ <option value="10">10</option>
95
+ <option value="11">11</option>
96
+ <option value="12">12</option>
97
+ <option value="13">13</option>
98
+ <option value="14">14</option>
99
+ <option value="15">15</option>
100
+ <option value="16">16</option>
101
+ <option value="17">17</option>
102
+ <option value="18">18</option>
103
+ <option value="19">19</option>
104
+ <option value="20">20</option>
105
+ <option value="21">21</option>
106
+ <option value="22">22</option>
107
+ <option value="23">23</option>
108
+ <option value="24">24</option>
109
+ <option value="25">25</option>
110
+ <option value="26">26</option>
111
+ <option value="27">27</option>
112
+ <option value="28">28</option>
113
+ <option value="29">29</option>
114
+ <option value="30">30</option>
115
+ <option value="31">31</option>
116
+ <option value="32">32</option>
117
+ <option value="33">33</option>
118
+ <option value="34">34</option>
119
+ <option value="35">35</option>
120
+ <option value="36">36</option>
121
+ <option value="37">37</option>
122
+ <option value="38">38</option>
123
+ <option value="39">39</option>
124
+ <option value="40">40</option>
125
+ <option value="41">41</option>
126
+ <option value="42">42</option>
127
+ <option value="43">43</option>
128
+ <option value="44">44</option>
129
+ <option value="45">45</option>
130
+ <option value="46">46</option>
131
+ <option value="47">47</option>
132
+ <option value="48">48</option>
133
+ <option value="49">49</option>
134
+ <option value="50">50</option>
135
+ <option value="51">51</option>
136
+ <option value="52">52</option>
137
+ <option value="53">53</option>
138
+ <option value="54">54</option>
139
+ <option value="55">55</option>
140
+ <option value="56">56</option>
141
+ <option value="57">57</option>
142
+ <option value="58">58</option>
143
+ <option value="59">59</option>
144
+ </select>
@@ -1,3 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
1
4
  require 'capybara/dsl'
2
5
  require 'tedium'
3
6
  require 'pry'
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_dependency 'site_prism'
26
+ spec.add_dependency 'site_prism', '>= 2.6'
27
27
  spec.add_dependency 'activesupport'
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.3"
@@ -32,6 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "pry"
33
33
  spec.add_development_dependency "actionpack"
34
34
  spec.add_development_dependency "activemodel"
35
- spec.add_development_dependency "launchy"
36
35
  end
37
36
 
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.1
4
+ version: 0.0.2
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-02 00:00:00.000000000 Z
11
+ date: 2014-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: site_prism
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2.6'
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
- version: '0'
26
+ version: '2.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: launchy
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - '>='
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - '>='
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
125
  description: "Removes the tedium of form filling with SitePrism by allowing you\n
140
126
  \ to specify a set of fields, actions and submissions rather than \n procedurally
141
127
  calling Capybara’s DSL methods.\n"
@@ -147,6 +133,8 @@ extra_rdoc_files: []
147
133
  files:
148
134
  - .gitignore
149
135
  - .travis.yml
136
+ - CHANGELOG.md
137
+ - CONTRIBUTING.md
150
138
  - Gemfile
151
139
  - LICENSE.txt
152
140
  - README.md
@@ -160,8 +148,10 @@ files:
160
148
  - lib/tedium/site_prism/root_element_or_page.rb
161
149
  - lib/tedium/version.rb
162
150
  - lib/tedium/virtual_date_element.rb
151
+ - lib/tedium/virtual_datetime_element.rb
163
152
  - spec/features/fill_in_checkboxes_spec.rb
164
153
  - spec/features/fill_in_dates_spec.rb
154
+ - spec/features/fill_in_datetimes_spec.rb
165
155
  - spec/features/fill_in_form_spec.rb
166
156
  - spec/features/have_record_spec.rb
167
157
  - spec/features/perform_actions_spec.rb
@@ -169,6 +159,7 @@ files:
169
159
  - spec/fixtures/action.html
170
160
  - spec/fixtures/checkbox.html
171
161
  - spec/fixtures/date.html
162
+ - spec/fixtures/datetime.html
172
163
  - spec/fixtures/followed.html
173
164
  - spec/fixtures/form.html
174
165
  - spec/fixtures/record.html
@@ -202,6 +193,7 @@ summary: Simplify form filling with SitePrism
202
193
  test_files:
203
194
  - spec/features/fill_in_checkboxes_spec.rb
204
195
  - spec/features/fill_in_dates_spec.rb
196
+ - spec/features/fill_in_datetimes_spec.rb
205
197
  - spec/features/fill_in_form_spec.rb
206
198
  - spec/features/have_record_spec.rb
207
199
  - spec/features/perform_actions_spec.rb
@@ -209,6 +201,7 @@ test_files:
209
201
  - spec/fixtures/action.html
210
202
  - spec/fixtures/checkbox.html
211
203
  - spec/fixtures/date.html
204
+ - spec/fixtures/datetime.html
212
205
  - spec/fixtures/followed.html
213
206
  - spec/fixtures/form.html
214
207
  - spec/fixtures/record.html