[rspec-users] Cucumber tables

James Byrne lists at ruby-forum.com
Fri May 15 11:35:53 EDT 2009


I cannot seem to locate any documentation on how to implement the new
table syntax otherwise I would not bother the list with this.

I wish to write something like this:

  And we do have a forex rate for the following currency code and date
        |code |    date    |  rate  |
        |"USD"|"2009-04-01"|"0.8555"|
        |"USD"|"2009-04-05"|"0.8444"|

Then /^we do have a forex (.+) for the following currency (.+) and
(.+)$/ \
  do |rate,code,date,table|
  # table is a Cucumber::Ast::Table
    puts rate
    puts code
    puts date
end

All I see from this is:
...
rate
code
date
    And we do have a forex rate for the following currency code and date
#
features/app/models/currency_exchange_rates/step_definitions/currency_exchange_rates_steps.rb:8
      | code  | date         | rate     |
      | "USD" | "2009-04-01" | "0.8555" |
      | "USD" | "2009-04-05" | "0.8444" |

I only get one iteration of output and that only displays the regex
matches found in the original string.

What is happening with the rest of the data? Is the table data keyed by
the headings or is it position dependent on the matcher order?  In other
words, does the data in the table have to be in the same order as the
regexp in the preceding clause.  If so, then why the table headings?
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list