Using Rails 2 and rspec-rails 2.0.1. I have the following view spec: require ''spec_helper'' describe "bookmarkers/show.html.haml" do include BookmarkersHelper before(:each) do @bookmarker = mock_model(Bookmarker) @bookmarker.stub!(:host_id).and_return("1") assign(:bookmarker, @bookmarker) view.stub! (:edit_object_path).and_return(edit_bookmarker_path(@bookmarker)) view.stub!(:collection_path).and_return(bookmarkers_path) end it "should render attributes in <p>" do render rendered.should contain("1") end end When I run /usr/bin/ruby -S bundle exec rspec "./spec/views/ bookmarkers/show.html.haml_spec.rb" I get: F Failures: 1) bookmarkers/show.html.haml should render attributes in <p> Failure/Error: rendered.should contain("1") undefined method `contain'' for #<RSpec::Core::ExampleGroup::Nested_1:0x7f6ea999e390> # ./spec/views/bookmarkers/show.html.haml_spec.rb:19 Finished in 0.10042 seconds 1 example, 1 failure Where can I find the definition of "contain" or "contains?" Also here is my Gemfile: group :development, :test do gem "rspec", "~>2.0.0" gem "rspec-rails", ">= 2.0.1" end Thanks. Stephen Veit
Using Rails 2 and rspec-rails 2.0.1. I have the following view spec: require ''spec_helper'' describe "bookmarkers/show.html.haml" do include BookmarkersHelper before(:each) do @bookmarker = mock_model(Bookmarker) @bookmarker.stub!(:host_id).and_return("1") assign(:bookmarker, @bookmarker) view.stub! (:edit_object_path).and_return(edit_bookmarker_path(@bookmarker)) view.stub!(:collection_path).and_return(bookmarkers_path) end it "should render attributes in <p>" do render rendered.should contain("1") end end When I run /usr/bin/ruby -S bundle exec rspec "./spec/views/ bookmarkers/show.html.haml_spec.rb" I get: F Failures: 1) bookmarkers/show.html.haml should render attributes in <p> Failure/Error: rendered.should contain("1") undefined method `contain'' for #<RSpec::Core::ExampleGroup::Nested_1:0x7f6ea999e390> # ./spec/views/bookmarkers/show.html.haml_spec.rb:19 Finished in 0.10042 seconds 1 example, 1 failure Where can I find the definition of "contain" or "contains?" Also here is my Gemfile: group :development, :test do gem "rspec", "~>2.0.0" gem "rspec-rails", ">= 2.0.1" end Thanks. Stephen Veit
On Oct 18, 2010, at 3:27 PM, Stephen Veit wrote:> Using Rails 2 and rspec-rails 2.0.1.rspec-rails-2 does not support rails-2. Please use rspec-rails-1.3.3 for rails-2. HTH, David
On Oct 18, 3:41?pm, David Chelimsky <dchelim... at gmail.com> wrote:> On Oct 18, 2010, at 3:27 PM, Stephen Veit wrote: > > > Using Rails 2 and rspec-rails 2.0.1. > > rspec-rails-2 does not support rails-2. Please use rspec-rails-1.3.3 for rails-2. > > HTH, > David > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-usersI meant to type "Rails 3". I am using Rails 3 and rspec-rails 2.0.1.
On Oct 18, 2010, at 3:27 PM, Stephen Veit wrote:> Using Rails 2 and rspec-rails 2.0.1. > > I have the following view spec: > > > require ''spec_helper'' > > describe "bookmarkers/show.html.haml" do > include BookmarkersHelper > > before(:each) do > @bookmarker = mock_model(Bookmarker) > @bookmarker.stub!(:host_id).and_return("1") > > assign(:bookmarker, @bookmarker) > > view.stub! > (:edit_object_path).and_return(edit_bookmarker_path(@bookmarker)) > view.stub!(:collection_path).and_return(bookmarkers_path) > end > > it "should render attributes in <p>" do > render > rendered.should contain("1") > end > end > > > When I run /usr/bin/ruby -S bundle exec rspec "./spec/views/ > bookmarkers/show.html.haml_spec.rb" I get: > > > F > > Failures: > 1) bookmarkers/show.html.haml should render attributes in <p> > Failure/Error: rendered.should contain("1") > undefined method `contain'' for > #<RSpec::Core::ExampleGroup::Nested_1:0x7f6ea999e390> > # ./spec/views/bookmarkers/show.html.haml_spec.rb:19 > > Finished in 0.10042 seconds > 1 example, 1 failure > > Where can I find the definition of "contain" or "contains?" > > Also here is my Gemfile: > > group :development, :test do > gem "rspec", "~>2.0.0" > gem "rspec-rails", ">= 2.0.1" > end > > Thanks. > > Stephen Veitcontain is a Webrat matcher (also Capybara, but Capybara matchers do not work in view specs), so you need to add that to your Gemfile: gem "webrat", ">= 0.7.2.beta.2" HTH, David
I also ran into this today. Not sure where the "contain" matcher is, looked in rspec-rails and rspec-expectations, but came up empty. (Rails 3.0.0 / Rspec 2.0.0) -- matt On Oct 18, 2010, at 5:53 PM, Stephen Veit wrote:> > On Oct 18, 3:41 pm, David Chelimsky <dchelim... at gmail.com> wrote: >> On Oct 18, 2010, at 3:27 PM, Stephen Veit wrote: >> >>> Using Rails 2 and rspec-rails 2.0.1. >> >> rspec-rails-2 does not support rails-2. Please use rspec- >> rails-1.3.3 for rails-2. >> >> HTH, >> David >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > > I meant to type "Rails 3". > > I am using Rails 3 and rspec-rails 2.0.1. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On Oct 19, 2010, at 4:11 PM, Matthew Van Horn wrote:> I also ran into this today. Not sure where the "contain" matcher is, looked in rspec-rails and rspec-expectations, but came up empty. > (Rails 3.0.0 / Rspec 2.0.0)Webrat and Capybara each have a contain() matcher. Trick is that Capybara matchers are not available in view specs, so for those you''ve gotta use Webrat (if you want contain()).> -- matt > > On Oct 18, 2010, at 5:53 PM, Stephen Veit wrote: > >> >> On Oct 18, 3:41 pm, David Chelimsky <dchelim... at gmail.com> wrote: >>> On Oct 18, 2010, at 3:27 PM, Stephen Veit wrote: >>> >>>> Using Rails 2 and rspec-rails 2.0.1. >>> >>> rspec-rails-2 does not support rails-2. Please use rspec-rails-1.3.3 for rails-2. >>> >>> HTH, >>> David >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users >> >> >> I meant to type "Rails 3". >> >> I am using Rails 3 and rspec-rails 2.0.1. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users