should include calls chomp for a String value #130

Closed
rchampourlier opened this Issue Apr 1, 2012 · 2 comments

2 participants

@rchampourlier

I encountered this issue and found http://stackoverflow.com/questions/9756505/rspec-should-include-tries-to-chomp-an-array

In my case, the issue happens with rspec 2.9.0 / rspec-rails 2.9.0, with Rails 3.0.12 when I use the include matcher for a String attribute.

Here is the concerned code:

Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
  current_email.default_part_body.to_s.should include(text)
end

... the step in the feature:

step %{I should see "changer de mot de passe" in the email body}

... which was raising:

undefined method `chomp' for ["changer de mot de passe"]:Array (NoMethodError)
  ./features/step_definitions/email_steps.rb:110:in `/^(?:I|they) should see "([^"]*?)" in the email body$/'
@myronmarston
RSpec member

I believe the underlying issue has already been fixed:

e4d8dcb

Can you try pinning your gemfile to rspec-expectations master branch on github and see if the issue is fixed?

@rchampourlier

This is indeed corrected in rspec-expectations/master.

Tested it with this in my Gemfile:

gem 'rspec-rails', '~> 2.9'
gem 'rspec-expectations', :git => "https://github.com/rspec/rspec-expectations.git", :branch => 'master'

And thanks for the ultra-fast answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment