[rspec-users] Cucumber tables

James Byrne lists at ruby-forum.com
Fri May 15 13:01:01 EDT 2009


I do not know if I am doing something wrong or not, but I am seeing 
evidence that feature tables in normal scenarios do not actually do 
anything.

# feature statement

    And we do have a forex rate for "USD" on "2009-03-31" of "0.8666"
      | "USD" | "2009-04-01" | "0.8555" |
      | "USD" | "2009-04-05" | "0.8444" |
    Then the number of forex rates should be 3

# step definition

Then /do have a forex rate for "([^\"]*)" on "([^\"]*)" of "([^\"]*)"/ \
  do |code,date,rate,table|
  my_rate = CurrencyExchangeRate.new
    my_rate.currency_code_base        = 'CAD'
    my_rate.currency_code_quote       = code
    my_rate.currency_exchange_rate    = rate
    my_rate.currency_exchange_source  = 'features test'
    my_rate.currency_exchange_type    = 'TEST'
    my_rate.effective_from            = date
    my_rate.save!
end

Then /the number of forex rates should be (\d+)/ do |count|
  CurrencyExchangeRate.count.should ==(count)
end

But, the results of this are:

    And we do have a forex rate for "USD" on "2009-03-31" of "0.8666"
        # features/app/models/currency_exchange_rates/step_definitions
            /currency_exchange_rates_steps.rb:8
      | "USD" | "2009-04-01" | "0.8555" |
      | "USD" | "2009-04-05" | "0.8444" |

    Then the number of forex rates should be 3
        # features/app/models/currency_exchange_rates/step_definitions
            /currency_exchange_rates_steps.rb:81
      expected: "3",
           got: 1 (using ==)
      Diff:
      @@ -1,2 +1,2 @@
      -3
      +1
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list