sinclair bain
2007-Aug-02 20:15 UTC
[rspec-users] Do the :attributes and :content matchers work
[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
end
which does just this.
Can anyone help please ?
Cheers!
sinclair
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/rspec-users/attachments/20070802/c3ed6209/attachment.html
David Chelimsky
2007-Aug-02 20:18 UTC
[rspec-users] Do the :attributes and :content matchers work
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!'' ) > endhave_tag wraps the assert_select API. Basically, your hash (:content => ...) is being ignored. What you want to say is: response.should have_tag(''div.bug'', ''There is no content!'') That should fail. Please report back. Thanks, David> > 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 > > 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 >
David Chelimsky
2007-Aug-02 20:24 UTC
[rspec-users] Do the :attributes and :content matchers work
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'') > endUgh. 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 >