rails_generators/pickle/templates/pickle_steps.rb in pickle-0.2.1 vs rails_generators/pickle/templates/pickle_steps.rb in pickle-0.2.2
- old
+ new
@@ -68,6 +68,22 @@
end
# assert not model.predicate?
Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
-end
\ No newline at end of file
+end
+
+# model.attribute.should eql(value)
+# model.attribute.should_not eql(value)
+Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |name, attribute, expectation, expected|
+ actual_value = model(name).send(attribute)
+ expectation = expectation.gsub(' ', '_')
+
+ case expected
+ when 'nil', 'true', 'false'
+ actual_value.send(expectation, send("be_#{expected}"))
+ when /^-?[0-9_]+$/
+ actual_value.send(expectation, eql(expected.to_i))
+ else
+ actual_value.to_s.send(expectation, eql(expected))
+ end
+end