Hayden
Hayden

Reputation: 163

RSpec error: 'but it does not respond to `include?`'

I am running the following rspec test

expect(City.first.city_openings('2014-05-01', '2014-05-05')).to include(@listing2,@listing3)

I am getting this result

enter image description here

This is confusing to me because it seems that my result does in fact include the right values. But rspec says that my result "does not respond to include?" Any ideas on how to fix this? I don't see much about it anywhere.

Upvotes: 2

Views: 3084

Answers (1)

Florian Wininger
Florian Wininger

Reputation: 153

Your method city_openings return true and not a array. TrueClass is not iterable with include? method.

See the documentation here

https://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/include-matcher

https://relishapp.com/rspec/rspec-expectations/v/3-7/docs/built-in-matchers/match-matcher

Upvotes: 6

Related Questions