cucumber_factory 1.14.0 → 1.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/Gemfile.cucumber-2.4.lock +1 -1
- data/lib/cucumber/factory.rb +7 -4
- data/lib/cucumber_factory/version.rb +1 -1
- data/spec/cucumber_factory/steps_spec.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bccae277bb1c545da7f91a887837f4a930b4848b71c7508f1a56b18d4bce755
|
4
|
+
data.tar.gz: 14169c7d0c43ad800364a9765bf644558a6920b57293ce1f6dcab4de5a9179ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5a2fdfc5b6eb970617dca9f769f58e197ac12eb0903db3d3b171040cd85b2da8027d7a620dfbdfaceddafe521eb5e271126820699eb93380e94b2057e5e0101
|
7
|
+
data.tar.gz: 6a88c46c19ed150fb39c9df5bfa25b799e8b9e36d0e338c12fae0ffacb5edc50d209df7abc0caae82625af2456818a59265f19d1dcefd35b370efe6f66070bb8
|
data/lib/cucumber/factory.rb
CHANGED
@@ -151,8 +151,11 @@ module Cucumber
|
|
151
151
|
elsif matches_fully?(value, VALUE_STRING)
|
152
152
|
value = unquote(value)
|
153
153
|
value = get_named_record(world, value) || transform_value(world, value)
|
154
|
+
elsif matches_fully?(value, VALUE_INTEGER)
|
155
|
+
value = value.to_s
|
156
|
+
value = get_named_record(world, value) || transform_value(world, value)
|
154
157
|
else
|
155
|
-
raise Error, "Cannot set association #{model_class}##{attribute} to #{value}.
|
158
|
+
raise Error, "Cannot set association #{model_class}##{attribute} to #{value}."
|
156
159
|
end
|
157
160
|
else
|
158
161
|
value = resolve_scalar_value(world, model_class, attribute, value)
|
@@ -203,9 +206,9 @@ module Cucumber
|
|
203
206
|
end
|
204
207
|
|
205
208
|
def remember_record_names(world, record, attributes)
|
206
|
-
|
207
|
-
for
|
208
|
-
set_named_record(world,
|
209
|
+
rememberable_values = attributes.values.select { |v| v.is_a?(String) || v.is_a?(Fixnum) }
|
210
|
+
for value in rememberable_values
|
211
|
+
set_named_record(world, value.to_s, record)
|
209
212
|
end
|
210
213
|
end
|
211
214
|
|
@@ -133,6 +133,12 @@ describe 'steps provided by cucumber_factory' do
|
|
133
133
|
payment.comment.should == 'Thanks for lending'
|
134
134
|
end
|
135
135
|
|
136
|
+
it "should allow to set an explicit primary key" do
|
137
|
+
invoke_cucumber_step('there is a payment with the ID 2')
|
138
|
+
payment = Payment.last
|
139
|
+
payment.id.should == 2
|
140
|
+
end
|
141
|
+
|
136
142
|
it "should allow to name records and set a belongs_to association to that record by refering to that name" do
|
137
143
|
invoke_cucumber_step('"Some Prequel" is a movie with the title "Before Sunrise"')
|
138
144
|
invoke_cucumber_step('there is a movie with the title "Limitless"')
|
@@ -151,6 +157,14 @@ describe 'steps provided by cucumber_factory' do
|
|
151
157
|
movie.prequel.should == prequel
|
152
158
|
end
|
153
159
|
|
160
|
+
it "should allow to set a belongs_to association to a previously created record by refering to their explicitely set primary keys" do
|
161
|
+
invoke_cucumber_step('there is a movie with the ID 123')
|
162
|
+
invoke_cucumber_step('there is a movie with the title "Before Sunset" and the prequel 123')
|
163
|
+
movie = Movie.find_by_title!('Before Sunset')
|
164
|
+
prequel = Movie.find(123)
|
165
|
+
movie.prequel.should == prequel
|
166
|
+
end
|
167
|
+
|
154
168
|
it "should allow to set a belongs_to association to a previously created record by saying 'above'" do
|
155
169
|
invoke_cucumber_step('there is a user with the name "Jane"')
|
156
170
|
invoke_cucumber_step('there is a user with the name "John"')
|