Skip to content

Commit

Permalink
Added handling of ruby integer syntax (eg. 2_000_000)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Apr 27, 2010
1 parent e630f14 commit bc5d7ab
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion History.txt
@@ -1,13 +1,17 @@
== 0.2.9 - 27 Apr 2010

* 1 minor improvement
* 3 minor improvements
* Fixed problem with verifying model attribute using strings with escaped quotes [Michael MacDonald]
* Added handling for positive and negative floats [Michael MacDonald, #railscamp7]
* Added handling of ruby integer syntax (e.g. 1_000_000) [Ian White]


== 0.2.8 - 5 Apr 2010

* 1 minor improvement
* 'Then show me the email' works as expected now [#18]


== 0.2.7 - 5 Apr 2010

* 1 minor improvement
Expand Down
4 changes: 3 additions & 1 deletion features/pickle/create_from_active_record.feature
Expand Up @@ -24,11 +24,13 @@ Feature: I can easily create models from my blueprints
Scenario: I create positive and negative users
Given a user exists with name: "Fred", attitude_score: +5.42
And another user exists with name: "Ethel", attitude_score: -10
Then 2 users should exist
And another user exists with name: "Buddha", attitude_score: 2_000_000
Then 3 users should exist
And the 1st user should be a positive person
And the 2nd user should not be a positive person
And the 1st user's attitude_score should be 5.42
And the 2nd user's attitude_score should be -10
And the 3rd user's attitude_score should be 2_000_000

Scenario: I create nil values
Given a user exists with name: "Fred", attitude_score: nil
Expand Down
2 changes: 1 addition & 1 deletion lib/pickle/parser/matchers.rb
Expand Up @@ -22,7 +22,7 @@ def match_label
end

def match_value
"(?:\"#{match_quoted}\"|nil|true|false|[+-]?\\d+(?:\\.\\d+)?)"
"(?:\"#{match_quoted}\"|nil|true|false|[+-]?[0-9_]+(?:\\.\\d+)?)"
end

def match_field
Expand Down
2 changes: 1 addition & 1 deletion rails_generators/pickle/templates/pickle_steps.rb
Expand Up @@ -79,7 +79,7 @@
case expected
when 'nil', 'true', 'false'
actual_value.send(expectation, send("be_#{expected}"))
when /^[+-]?\d+(\.\d+)?$/
when /^[+-]?[0-9_]+(\.\d+)?$/
actual_value.send(expectation, eql(expected.to_f))
else
actual_value.to_s.send(expectation, eql(eval(expected)))
Expand Down

0 comments on commit bc5d7ab

Please sign in to comment.