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

David Chelimsky dchelimsky at gmail.com
Thu Aug 2 16:24:04 EDT 2007


On 8/2/07, sinclair bain <rspec.user at gmail.com> wrote:
>  [Rails plugin 1.0.5]
>
>
>  Hi,
> 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!' )
>      end
>
>      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'} )
>       end
>
> 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
>
>
> <my_app>/vendor/plugins/rspec_on_rails/spec/rails/dsl/view_spec_spec.rb
>
> 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"
>     end
>
>     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')
>     end

Ugh. Those are holdovers from the old API and are only passing because
:content and :attributes are being ignored. I'm updating them in rspec
trunk to correctly reflect the API.

>
>   end
>
> which does just this.
>
> Can anyone help please ?
>
> Cheers!
> sinclair
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list