[rspec-users] Cucumber ".should contain(expected) does but fails anyway

James Byrne lists at ruby-forum.com
Wed Apr 22 10:52:37 EDT 2009


This is the step definition:

When /the xml document should have the Bank of Canada title/ do
  expected = '<title>Bank of Canada: Noon Foreign Exchange
Rates</title>'
  fx_doc = ForexCASource.new(@xchg_source)
  puts fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title')
  fx_doc.xpath('//rdf:RDF/xmlns:channel/xmlns:title').should
contain(expected)
end

When I exercise the feature I see this:

    When the currency exchange retrieval script runs
      #
features/app/models/currency_exchange_rates/step_definitions/currency_exchange_rates_steps.rb:9

<title>Bank of Canada: Noon Foreign Exchange Rates</title> <= from puts

    Then the xml document should have the Bank of Canada title
      #
features/app/models/currency_exchange_rates/step_definitions/currency_exchange_rates_steps.rb:13

      expected the following element's content to include
"<title>Bank of Canada: Noon Foreign Exchange Rates</title>":

      Bank of Canada: Noon Foreign Exchange Rates
(Spec::Expectations::ExpectationNotMetError)
      ./features/app/models/currency_exchange_rates/step_definitions/currency_exchange_rates_steps.rb:17:in
`/the xml document should have the Bank of Canada title/'
      features/app/models/currency_exchange_rates/currency_exchange_rates.feature:10:in
`Then the xml document should have the Bank of Canada title'

1 scenario
1 failed step
2 passed steps

Now, other than the double quotes surrounding the comparison string in
the failure message there is no difference between what I expected and
what was returned.  Nonetheless the specification failed?  What am I
doing wrong?
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list