cucumber-blendle-steps 0.2.0 → 0.3.0

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: ae9aff26a47ddd90de157a577413b30863e9c58e
4
- data.tar.gz: 03ee88551e46bbc6d7f57e9275e08e4a194e45d5
3
+ metadata.gz: 7320de3eb5c6186e98321d606bbfb9ac0a1500de
4
+ data.tar.gz: 816e6291f8beb068bcc6782fb05aa9152d03e082
5
5
  SHA512:
6
- metadata.gz: 41f0c503695976c6de908c509b1823ef59c11515937a3a75e5b8bce22acbb63b09e0925ed2b5652811e852f651612b81d7ab3fcb211a7561d68c525c6d6df51b
7
- data.tar.gz: 6c9187be04dc39c1c6b25ffd2cd389fedd2e1803c26b7eb15c2eed76d83c331b0640daf39f681244cfb6010ab68d06687cc81ac0364954c7027183890aff5cbe
6
+ metadata.gz: 7fbcf0e02fdcf9dab18f63060894d3448322195524f8074344ed5b30cdf0bffa719a1671feafde5a8949730b2d956bcb901869cf35af83bd323f93291141ac7d
7
+ data.tar.gz: 836fa6d7b1268b8e5cb2ce312d57dd89b4578b4a37fc8ed35e44673f743fae3b8dc2dca1dee5fd032d65fea5252fedd93bf5b985ea654d655c18599744944988
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ **v0.3.0** – 2015-12-4
2
+
3
+ * add support for [type-casting model values](https://github.com/blendle/cucumber-blendle-steps/pull/2)
4
+
1
5
  **v0.2.0** – 2015-11-30
2
6
 
3
7
  * initial release
@@ -22,15 +22,15 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'hyperresource'
23
23
  spec.add_dependency 'json_spec'
24
24
  spec.add_dependency 'minitest'
25
- spec.add_dependency 'rspec-expectations'
26
25
  spec.add_dependency 'rack-test'
27
26
  spec.add_dependency 'rack'
27
+ spec.add_dependency 'rspec-expectations'
28
+ spec.add_dependency 'sequel'
28
29
 
29
30
  spec.add_development_dependency 'bundler'
30
31
  spec.add_development_dependency 'pry'
31
32
  spec.add_development_dependency 'rake'
32
33
  spec.add_development_dependency 'rubocop'
33
- spec.add_development_dependency 'sequel'
34
34
  spec.add_development_dependency 'sqlite3'
35
35
  spec.add_development_dependency 'webmachine'
36
36
  end
@@ -1,27 +1,48 @@
1
1
  require 'active_support/core_ext/hash/keys'
2
2
  require 'active_support/core_ext/object/blank'
3
3
  require 'active_support/core_ext/string/inflections'
4
+ require 'sequel'
4
5
 
5
- # rubocop:disable Lint/Eval
6
- # rubocop:disable Lint/UnusedBlockArgument
6
+ # rubocop:disable Lint/Eval,Metrics/LineLength,Lint/UselessAssignment
7
7
 
8
8
  Given(/^the following (\S+) exist:$/) do |object, table|
9
9
  table.hashes.each do |row|
10
- assert eval("#{object.singularize.capitalize}.create(row.symbolize_keys)")
11
- step %(the following #{object.singularize} should exist:), table([row.keys, row.values])
10
+ hash = parse_row(row)
11
+
12
+ assert eval("#{object.singularize.capitalize}.create(hash)")
13
+ step %(the following #{object.singularize} should exist:), table([hash.keys, hash.values])
12
14
  end
13
15
  end
14
16
 
15
- Then(/^the (\S+) with (\S+) "([^"]*)" should( not)? exist$/) do |object, attribute, negate, value|
17
+ Then(/^the (\S+) with (\S+)(?: \((\S+)\))? "([^"]*)" should( not)? exist$/) do |object, attribute, type, value, negate|
18
+ hash = parse_row("#{attribute} (#{type})" => value)
16
19
  assertion = negate ? 'blank?' : 'present?'
17
20
 
18
- assert eval("#{object.capitalize}.first(attribute.to_sym => value).#{assertion}")
21
+ assert eval("#{object.capitalize}.first(hash).#{assertion}"),
22
+ %(#{object.capitalize} not found \(#{attribute}: #{value}\))
19
23
  end
20
24
 
21
25
  Then(/^the following (\S+) should( not)? exist:$/) do |object, negate, table|
22
26
  assertion = negate ? 'blank?' : 'present?'
23
27
 
24
28
  table.hashes.each do |row|
25
- assert eval("#{object.capitalize}.first(row.symbolize_keys).#{assertion}")
29
+ hash = parse_row(row)
30
+
31
+ assert eval("#{object.capitalize}.first(hash).#{assertion}")
26
32
  end
27
33
  end
34
+
35
+ def parse_row(row)
36
+ hash = row.map do |attribute, value|
37
+ value = case attribute[/\s\((\w+)\)$/, 1]
38
+ when 'Array'
39
+ Sequel.pg_array(eval(value))
40
+ else
41
+ value
42
+ end
43
+
44
+ [attribute.to_s.split.first.to_sym, value]
45
+ end
46
+
47
+ Hash[hash]
48
+ end
@@ -4,6 +4,6 @@ module Cucumber
4
4
  # This module defines default steps used by all of Blendle Ruby projects.
5
5
  #
6
6
  module BlendleSteps
7
- VERSION = '0.2.0'
7
+ VERSION = '0.3.0'
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-blendle-steps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Mertz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-30 00:00:00.000000000 Z
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rspec-expectations
98
+ name: rack-test
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rack-test
112
+ name: rack
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rack
126
+ name: rspec-expectations
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,13 +137,13 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: bundler
140
+ name: sequel
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
- type: :development
146
+ type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: pry
154
+ name: bundler
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: rake
168
+ name: pry
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -179,7 +179,7 @@ dependencies:
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: rubocop
182
+ name: rake
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - ">="
@@ -193,7 +193,7 @@ dependencies:
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
- name: sequel
196
+ name: rubocop
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - ">="