Thank you. But then what should be the work around for this with Capybara? I was leaning toward using capybara...
Actually, do you recommend webrat over capybara? I just want one with good documentation and stick with one for the sake of getting used to the syntax. Now... One last thing. I notice that when I try webrat, has_content? no longer works. I'm guessing has_content? is specific to Capybara... is "should contain" the equivalent in webrat? Thanks again. On Jun 13, 11:02 am, David Chelimsky <[email protected]> wrote: > On Jun 13, 8:36 am, daze <[email protected]> wrote: > > > > > > > > > > > I'm going through The RSpec Book, and (specifically around page 333) I > > encountered a problem. Basically, whenever I use "should > > have_selector" in a nested form, it silently passes when it SHOULD > > fail. > > > I've been copying the code exactly as from the book. Now, there is > > one major difference - I'm using Capybara while the book is using > > Webrat. Why? I've had bigger problems with Webrat. In fact, when I > > switch to Webrat by putting it in the Gemfile, I get this unidentified > > method error in which has_selector isn't recognized (which is doubly > > odd because this happens where I call have_selector...) > > > Anyway, here's the code: > > > -------new.html.erb_spec.rb------- > > > require 'spec_helper' > > > describe "messages/new.html.erb" do > > > let(:message) do > > mock_model("Message").as_new_record.as_null_object > > end > > > before do > > assign :message, message > > end > > > it "renders a form to create a message" do > > render > > rendered.should have_selector("form", > > :method => "post", > > :action => messages_path > > ) do |form| > > form.should have_selector("input", :type => "submit") # this > > should be failing right now!!! > > end > > end > > > # this should be failing right now!!! > > it "renders a text field for the message title" do > > message.stub(:title => "the title") > > render > > rendered.should have_selector("form") do |form| > > form.should have_selector("input", > > :type => "submit", > > :name => "message[title]", > > :value => "the title" > > ) > > end > > end > > > # this should be failing right now!!! > > it "renders a text area for the message text" do > > message.stub(:text => "the message") > > render > > rendered.should have_selector("form") do |form| > > form.should have_selector("textarea", > > :name => "message[text]", > > :content => "the message" > > ) > > end > > end > > end > > > -----new.html.erb------ > > > <%= form_for @message do |f| %> > > > # nothing is in here, so those nested "should have_selector" > > statements should fail > > > <% end %> > > > Thanks in advance! > > The examples in the book use webrat, which has a has_selector matcher > that supports nesting. The capybara have_selector matcher does not > support nesting (yet). You don't get any feedback because Ruby lets > you pass a block to any method, and leaves it to the method to handle > it or ignore it. In this case it's being ignored. > > HTH, > David -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

