[rspec-users] Do the :attributes and :content matchers work

sinclair bain rspec.user at gmail.com
Thu Aug 2 16:15:41 EDT 2007

[Rails plugin 1.0.5]

I am looking for some guidance.
When working on a partial which looks like this

    <div class="bug" style="width: 100%;" />

I have some examples which should fail - I think - but do not:

     it   ' should fail' do
       response.should have_tag( 'div.bug', :content => 'There is no
content!' )

     it ' should fail since there is no bug attribute with a value of
"here"' do
       response.should have_tag( 'div', :attributes => {:bug => "here"} )
       response.should have_tag( 'div', :attributes => {:bug => "here",
:another_bug => 'there'} )

I am calling render :partial => '/bug/div' in the before :each block.

As I said I would expect this to fail but it does not.

I am trying this because in the


file there is an example

  describe "A view that includes a partial using :collection and
:spacer_template", :behaviour_type => :view  do

    before(:each) do
      render "view_spec/partial_collection_including_template"

    it "should render the partial w/ spacer_tamplate" do
      response.should have_tag('div', :content => 'Alice')
      response.should have_tag('hr', :attributes =>{:id => "spacer"})
      response.should have_tag('div', :content => 'Bob')


which does just this.

Can anyone help please ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070802/c3ed6209/attachment.html 

More information about the rspec-users mailing list