On Fri, May 15, 2009 at 11:35 AM, James Byrne <li...@ruby-forum.com> wrote:

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

They're actually unrelated.  Most of my table matchers have no other regex
in the expression

You're not seeing anything else with the table data because you're not doing
anything with the table data.

 Given /the following data rates/ do |table|
    table.hashes.each do |row|
       puts row["code"]
    end
  end




> --


> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
// anything worth taking seriously is worth making fun of
// http://blog.devcaffeine.com/
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to