Skip to content

Commit

Permalink
added match_value
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Aug 25, 2010
1 parent 03d9d7a commit 19dd0db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/pickle/parser/matchers.rb
Expand Up @@ -48,6 +48,10 @@ def match_field
/(?:\w+\: [^,]+(?=$|,))/
end

def match_value
/(?:nil|true|false|[+-]?[0-9]+(?:\.\d+)?)/
end

def match_fields
/#{match_field.source}(?:, #{match_field.source})*/
end
Expand Down
3 changes: 3 additions & 0 deletions spec/pickle/parser/matchers_spec.rb
Expand Up @@ -34,6 +34,9 @@

its(:match_pickle_ref) { should match_all 'a user', 'a user: "fred"', 'the 2nd user', 'the super_admin', '"fred"' }
its(:match_pickle_ref) { should_not match_any 'another person:', 'another person: ', 'an admin user', 'a 2nd user', '' }

its(:match_value) { should match_all '1', '2.56', 'true', 'false', '-67.7', 'nil' }
its(:match_value) { should_not match_any '1 1', '2_2.56', 'truthy', '`rm -rf`', 'exec' }

describe "with config.factories = ['admin user', 'funky thing']" do
before do
Expand Down

0 comments on commit 19dd0db

Please sign in to comment.