chop 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc848f74bcfa21d1caf3f92ba4dbadb50ef7e997
4
- data.tar.gz: 4fcee119a37213af484023b70ee200af27e25251
3
+ metadata.gz: 1135604264c973b4b42e5e47dba49d6887482a6d
4
+ data.tar.gz: 6fd23a8bc90f756d2e85be83f06791b7fea04384
5
5
  SHA512:
6
- metadata.gz: a917cfb02a2d1cdd17c7385d9efb73ff6fef248a91e101073c6a1ea52e4e55d2d17123503ce5076047945eb33ea4ad2766a227f683169c7188c2cb00389ce3f0
7
- data.tar.gz: 13b5f38fab386835e0993949d9f906ce19de928abaa9c8885cae3e344afa6554d36fdc8cbf8acc4b7937522ad541d58e0c41515d0a04adb3e249b684e326fc02
6
+ metadata.gz: ac643b6fdd779b76c2b240661eb6dd899d7540a6ce4f8645effc721eb0d2988f44ed993c4b4ab79b3df9a1ae90bcd520a1129526604a393e91d36286d5a23483
7
+ data.tar.gz: 332ebe3878804ffba6f134036b7f048415fe4d1416c617c2a31360fe21124a3db0749aed3a4058d0d030b210bb95e6a6b6f29e6348916793135189a763731763
data/README.md CHANGED
@@ -14,12 +14,13 @@ end
14
14
 
15
15
  ## Usage
16
16
 
17
- Chop monkeypatches Cucumber tables with two new methods:
17
+ Chop monkeypatches Cucumber tables with three new methods:
18
18
 
19
19
  * `#build!`: Creates ActiveRecord instances. Also supports FactoryGirl.
20
20
  * `#diff!`: Enhances existing method to also accept a CSS selector. Currently supports diffing `<table>`, `<dl>`, and `<ul>`.
21
+ * `#fill_in!`: Fills in a form on the current page.
21
22
 
22
- Both these methods accept blocks for customization.
23
+ All these methods accept blocks for customization.
23
24
 
24
25
  ### Block methods for `#build!`:
25
26
 
@@ -42,6 +43,10 @@ All these methods are implemented in terms of the following low-level methods, u
42
43
 
43
44
  TODO: Pending API overhaul.
44
45
 
46
+ ### Block methods for `#fill_in!`:
47
+
48
+ TODO: Does this make sense?
49
+
45
50
  ### Example
46
51
 
47
52
  ```gherkin
@@ -58,6 +63,12 @@ Given the following stories exist:
58
63
  | Example industry | example.jpg | Another headline |
59
64
 
60
65
  Given I am on the home page
66
+
67
+ When I fill in the following form:
68
+ | Name | NEW industry |
69
+ | Wall background | NEW_wall.jpg |
70
+ | Table background | NEW_table.jpg |
71
+
61
72
  Then I should see the following industries:
62
73
  | ANOTHER INDUSTRY |
63
74
  | EXAMPLE INDUSTRY |
@@ -83,11 +94,19 @@ end
83
94
  Given "the following stories exist:" do |table|
84
95
  table.create! factory_girl: "conversation_table/story" do
85
96
  belongs_to :industry, ConversationTable::Industry
97
+
86
98
  rename :image => :image_file
87
99
  file :image_file
100
+
101
+ # The previous two lines can also be expressed as:
102
+ file :image => :image_file
88
103
  end
89
104
  end
90
105
 
106
+ When "I fill in the following form:" do |table|
107
+ table.fill_in!
108
+ end
109
+
91
110
  Then "I should see the following industries:" do |table|
92
111
  table.diff! "dl"
93
112
  end
@@ -106,6 +125,7 @@ Load `chop` before `cucumber` in your Gemfile, and call the two methods directly
106
125
  ```ruby
107
126
  Chop.build! table, Users
108
127
  Chop.diff! table, "table"
128
+ Chop.fill_in! table
109
129
  ```
110
130
 
111
131
  ## Development
@@ -44,6 +44,10 @@ module Chop
44
44
  end
45
45
 
46
46
  def field attribute, default: ""
47
+ if attribute.is_a?(Hash)
48
+ rename attribute
49
+ attribute = attribute.values.first
50
+ end
47
51
  transformation do |attributes|
48
52
  attributes[attribute.to_s] = yield(attributes.fetch(attribute.to_s, default))
49
53
  end
@@ -58,7 +62,13 @@ module Chop
58
62
  end
59
63
  end
60
64
 
61
- def file *keys, path: "features/support/fixtures"
65
+ def file *keys
66
+ if keys.last.is_a?(Hash) && keys.length > 1
67
+ options = keys.pop
68
+ path = options[:path]
69
+ end
70
+ path ||= "features/support/fixtures"
71
+
62
72
  keys.each do |key|
63
73
  field key do |file|
64
74
  File.open(File.join(path, file)) if file.present?
@@ -66,7 +76,15 @@ module Chop
66
76
  end
67
77
  end
68
78
 
69
- def files *keys, path: "features/support/fixtures", delimiter: " "
79
+ def files *keys
80
+ if keys.last.is_a?(Hash) && keys.length > 1
81
+ options = keys.pop
82
+ path = options[:path]
83
+ delimiter = options[:delimiter]
84
+ end
85
+ path ||= "features/support/fixtures"
86
+ delimiter ||= " "
87
+
70
88
  keys.each do |key|
71
89
  field key do |paths|
72
90
  paths.split(delimiter).map do |file|
@@ -1,3 +1,3 @@
1
1
  module Chop
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel