diff --git a/lib/pickle/parser/matchers.rb b/lib/pickle/parser/matchers.rb index dd7a9718..18b1d668 100644 --- a/lib/pickle/parser/matchers.rb +++ b/lib/pickle/parser/matchers.rb @@ -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 diff --git a/spec/pickle/parser/matchers_spec.rb b/spec/pickle/parser/matchers_spec.rb index dd053f3b..4b514b2c 100644 --- a/spec/pickle/parser/matchers_spec.rb +++ b/spec/pickle/parser/matchers_spec.rb @@ -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