Forum: RSpec [cucumber] Use of Scenario Outline for validation stuff ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
164578b8d21de6e92453bbbfa17260ba?d=identicon&s=25 Jérémy Kaz (jerefrer)
on 2009-04-28 11:11
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 ?
- Do you think it's a good use of Scenario Outline ? Or you think I
should have split it into 2 different scenarios (1 with working stuff, 1
with validation errors)

I hope I'm clear. If I'm not, here's an example code of what I'm talking
about :Scenario Outline: Create a VAT
****************************************************************************************************
Given I am logged in as a SuperAdmin user
When I go to the VATs page
And I follow "New VAT"
And I fill in "vat_caption" with "<caption>"
And I fill in "vat_value" with "<value>"
And I press "Créer"
Then I should see "<message>"
And the VAT "<caption>" should be present in the VAT list
<==================== What it's all about, works if VAT added, but
shouldn't be interpreted if VAT not added

Examples:
  | caption | value | message |
  | Normal | 19.6 | VAT Normal well created |
  | | 19.6 | You are supposed to fill the caption field |
  | Normal | | You are supposed to fill the VAT field |
  | Normal | test | You are supposed to fill the VAT field with a
numeric value |
****************************************************************************************************
164578b8d21de6e92453bbbfa17260ba?d=identicon&s=25 Jérémy Kaz (jerefrer)
on 2009-04-28 11:15
Sorry about bad formating, I pasted it and haven't checked ...

Well, you may have understood that the "<====" thing is pointing to the
'And the VAT "<caption>" ...' line, the 1st col of 2nd line in the
examples is a blank one, and the last line is cut into 2
164578b8d21de6e92453bbbfa17260ba?d=identicon&s=25 Jérémy Kaz (jerefrer)
on 2009-04-28 11:23
Aheeeem .... Please someone delete this post, I didn't see my post is
already present on the topic list, coming from the rubyforge rspec
mailing list I guess.

My apologies anyway ...
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 Aslak Hellesøy (aslakhellesoy)
on 2009-04-28 11:50
(Received via mailing list)
> Sorry about bad formating, I pasted it and haven't checked ...
>
> Well, you may have understood that the "<====" thing is pointing to the
> 'And the VAT "<caption>" ...' line, the 1st col of 2nd line in the
> examples is a blank one, and the last line is cut into 2


Sorry, I'm a little lost here. Was this supposed to be a reply to an
existing thread? Which one? Please use your email program's reply
button, or
your mails will appear outside the thread.

Aslak
164578b8d21de6e92453bbbfa17260ba?d=identicon&s=25 Jérémy Kaz (jerefrer)
on 2009-04-28 12:13
Aslak Hellesøy wrote:
>> Sorry about bad formating, I pasted it and haven't checked ...
>>
>> Well, you may have understood that the "<====" thing is pointing to the
>> 'And the VAT "<caption>" ...' line, the 1st col of 2nd line in the
>> examples is a blank one, and the last line is cut into 2
>
>
> Sorry, I'm a little lost here. Was this supposed to be a reply to an
> existing thread? Which one? Please use your email program's reply
> button, or
> your mails will appear outside the thread.
>
> Aslak

This is not a reply to an existing thread, but a mistakenly reposted
thread. The original one is here :
http://www.ruby-forum.com/topic/185132#new

My apologies again.
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 Aslak Hellesøy (aslakhellesoy)
on 2009-04-28 12:20
(Received via mailing list)
On Tue, Apr 28, 2009 at 11:11 AM, Jérémy Kaz <lists@ruby-forum.com>
wrote:

> 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 ?


No


>
> - Do you think it's a good use of Scenario Outline ? Or you think I


I think Scenario Outline is appropriate here. Take a look at RailsCast
#159
- I think it describes what you need.
http://railscasts.com/episodes/159-more-on-cucumber
48641c4be1fbe167929fb16c9fd94990?d=identicon&s=25 Mark Wilden (Guest)
on 2009-04-28 16:25
(Received via mailing list)
On Tue, Apr 28, 2009 at 2:11 AM, Jérémy Kaz <lists@ruby-forum.com>
wrote:


>
In the examples, make the caption something like "impossible". Then in
the
last step, don't bother looking in the list if the caption has that
value.
Perhaps even make sure the list is empty under those conditions.

///ark
This topic is locked and can not be replied to.