Matt Wynne
2009-Apr-23 17:22 UTC
[rspec-users] About the use of Scenario Outline for validation stuff
On 23 Apr 2009, at 17:03, J?r?my FRERE wrote:> Hi there ! > I was wondering if the way I test the validation of my forms is > right or not. So here''s a little example : > Imagine you have a form with some validations designed to create > some object. You want to test it using Scenario Outline and > Examples. So you fill in the fields using <value>, and press the > create button. Then you "should see" (using webrat) the <message> > telling you > - that the object has been well created > - that some field isn''t well filled > > And after that, in the objects list, you "should see" the created > object in the list > > Assuming that the object has been created, you will see it in the > list BUT if it has NOT been created, you won''t. And, in my case, it > will end in an error > > So my questions are : > - Is it possible, using some trick, to use some conditions inside > the .feature file ?Don''t forget you don''t have to just use the subsitutions for field values - you can change any of the text in a step. So it''s pretty easy to negate things: And the VAT "<caption>" <might> be present in the VAT list Examples: | caption | value | message | might | | Normal | 19.6 | VAT Normal well created | should | | | 19.6 | You are supposed to fill the caption field | should not | | Normal | | You are supposed to fill the VAT field | should not | | Normal | test | You are supposed to fill the VAT field with a numeric value | should not | Matt Wynne http://blog.mattwynne.net http://www.songkick.com