'nil' not recognized as value in capture_field regex
-
miriam
- Tag cleared.
oops. didn't realize we were using markdown. sorry. take 2:
pickle version: 0.1.23
cucumber version: 0.4.4
rails version: 2.3.4I have a field on a user that can be nil, but the following step is not recognized in by pickle:
And user should exist with email: "bubba@example.com", token: nil # features/forgot_password.feature:383 scenarios (1 undefined, 2 passed)
26 steps (1 undefined, 25 passed)
0m0.432sYou can implement step definitions for undefined steps with these snippets:
Then /^user should exist with email: "([^"]*)", password_token: nil$/ do |arg1|
pending # express the regexp above with the code you wish you had endhowever, if I change the expected value of the 'token' field to a different type the regex succeeds. for example, these steps are all recognized:
And user should exist with email: "bubba@example.com", token: false # features/step_definitions/pickle_steps.rb:21 And user should exist with email: "bubba@example.com", token: "foo" # features/step_definitions/pickle_steps.rb:21<br/> And user should exist with email: "bubba@example.com", token: 1.5 # features/step_definitions/pickle_steps.rb:20<br/> And user should exist with email: "bubba@example.com", token: 100 # features/step_definitions/pickle_steps.rb:20 -
Ian White
- Assigned user set to Ian White
Thanks for the bug report.
Just wondering, how does your app behave if you use an empty string? Do you depend on .nil? rather than .blank? (which is the more common case to test against, since most AR attrs come via forms, and "" is the only way of specifying a 'nil' attribute)
-
miriam
Hi Ian -- thanks for fixing this!
In my app I can't use an empty string and nil interchangeably here. If a user submits a value for token, it must be non-blank. If it's blank it should fail validation. However the app is allowed to set the token to nil under certain circumstances. So to make validations work for these two cases I have :allow_nil => true, rather than :allow_blank, and token can never have the value '' even though it can be nil.
hope that made sense...
-
Ian White
(from [03dcf163f2382b67cee8b084bfde8885e417db20]) Added feature and spec for having nil as field value [#15 'nil' not recognized as value in capture_field regex] http://github.com/ianwhite/pickle/commit/03dcf163f2382b67cee8b084bf...
-
Ian White
- State changed from open to resolved
Hi, yes your use case makes sense.
Pickle 0.2.1 should sort you out. Reopen this ticket if you have probs.
Cheers,
Ian
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.