[rspec-users] Running a specific row in cucumber example table
matt at mattwynne.net
Mon Oct 5 07:03:46 EDT 2009
On 5 Oct 2009, at 09:49, Zoltan Penzeli wrote:
>> I have no idea if this will work, but you could try to sense for the
>> table row you want to skip in a Before block, then call skip_invoke!
>> on it:
>> Before(scenario_or_example_row) do
>> if the_one_to_skip?(scenario_or_example_row)
Sorry, my example is bollocks. Try this instead:
Before do |scenario_or_example_row|
So the thing yielded to the Before block is the Scenario object if
you're in a Scenario, or the OutlineTable::ExampleRow if you're in an
outline table. You can call skip_invoke! on either of those objects to
tell them not to invoke their step definition.
> Well, this isn't really working (or I might forgot something to
> but from http://wiki.github.com/aslakhellesoy/cucumber/hooks - it
> that 'Before' is operating with tags (and hooks) - see
> This is in fact be useful, because we are able execute code before
> line of the properly tagged Scenario Outline... but... I still don't
> know the method/variable to access the _current line_ of the example
> So translated into the code, an example:
> Scenario Outline: file reader
> Given I read <file>
> Then I want to have <content>
> | file | content |
> | x.txt | Text |
> | y.txt | Other text |
> Before('@tagged') do
> # how to access current row???
> if row == $external_filename
> # how to properly skip current line???
> Given /I read (.+)/ do |fileName|
> #open and read fileName
> #fill @file_content
> Then /I want to have (.+)/ do |content|
> #assert 'content' against @file_content
> So we need something for 'row' and a proper way to skip the current
> I now that this example is not a good real life situation (it would be
> easier to use multiline step arguments), but we would like to use
> Cucumber driven by an external source (executing only one line from
> example table) AND maintaining the ability to run it independently
> I hope this cleared up the things a bit more...
> Thanks for your ideas!
> Posted via http://www.ruby-forum.com/.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users