Chad Ostrowski
2010-Nov-10 11:44 UTC
[rspec-users] undefined method `contain'' for #<RSpec::Core::ExampleGroup::Nested_1:0x10595b1a8>
Here''s my Gemfile: group :development, :test do> gem ''rspec-rails'', ''2.0.0'' > gem ''cucumber-rails'', ''0.3.2'' > gem ''capybara'', ''0.4.0.rc'' > endand here''s my spec: describe "welcome/index.html.haml" do> it "displays ''Problem Child'' in the header" do > render > rendered.should contain("Problem Child") > end > endThis results in the error given in the subject: Failures:> 1) welcome/index.html.haml displays ''Problem Child'' in the header > Failure/Error: rendered.should contain("Problem Child") > undefined method `contain'' for > #<RSpec::Core::ExampleGroup::Nested_1:0x10595b1a8>Does the "contain" matcher come with Webrat? Is that why the RSpec book seems to be lying to me? I''m trying to get the feel of RSpec and I love the idea of speccing views. I''ve been approximately following along with The RSpec Book. I''m using Capybara instead of Webrat because Webrat wasn''t playing well with Rails 3 (I forget the details). Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101110/cac35c3f/attachment-0001.html>
David Chelimsky
2010-Nov-10 16:03 UTC
[rspec-users] undefined method `contain'' for #<RSpec::Core::ExampleGroup::Nested_1:0x10595b1a8>
On Nov 10, 2010, at 5:44 AM, Chad Ostrowski wrote:> Here''s my Gemfile: > > group :development, :test do > gem ''rspec-rails'', ''2.0.0'' > gem ''cucumber-rails'', ''0.3.2'' > gem ''capybara'', ''0.4.0.rc'' > end > > and here''s my spec: > > describe "welcome/index.html.haml" do > it "displays ''Problem Child'' in the header" do > render > rendered.should contain("Problem Child") > end > end > > This results in the error given in the subject: > > Failures: > 1) welcome/index.html.haml displays ''Problem Child'' in the header > Failure/Error: rendered.should contain("Problem Child") > undefined method `contain'' for #<RSpec::Core::ExampleGroup::Nested_1:0x10595b1a8> > > Does the "contain" matcher come with Webrat? Is that why the RSpec book seems to be lying to me? I''m trying to get the feel of RSpec and I love the idea of speccing views. I''ve been approximately following along with The RSpec Book. I''m using Capybara instead of Webrat because Webrat wasn''t playing well with Rails 3 (I forget the details).The book says "these examples use Webrat" and you choose Capybara (a perfectly good option, but not for the examples in the book). Not sure who is lying to you, but it is not the book :) Webrat works fine for all of the examples in the book. I''d recommend using it to go through the book to get the feel for the process. Also, Capybara''s matchers are not available in view specs or helper specs (see https://github.com/rspec/rspec-rails/issues/closed#issue/242). HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101110/17700a13/attachment.html>