David James
2007-Sep-25 15:20 UTC
[rspec-users] Testing for particular CSS (i.e. display: none)
I have a page that hides elements using CSS display: none. I don''t expect RSpec to test any changes made by Javascript; I just want to test how the page loads initially: what is visible and what is not. Can I test this in RSpec? Or do I need to use something like Selenium? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070925/8245f14b/attachment.html
David Chelimsky
2007-Sep-25 15:27 UTC
[rspec-users] Testing for particular CSS (i.e. display: none)
On 9/25/07, David James <davidj503 at gmail.com> wrote:> I have a page that hides elements using CSS display: none. > > I don''t expect RSpec to test any changes made by Javascript; I just want to > test how the page loads initially: what is visible and what is not.If the css is expressed in-line in the html, then you can do it like so (example assumes a div with id foo that should be hidden): response.should have_tag(''div#foo[style=?]'', /display:\s*none/) have_tag wraps asset_select, so have a look at the assert_select docs for more info Cheers, David> > Can I test this in RSpec? Or do I need to use something like Selenium? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David James
2007-Sep-25 15:56 UTC
[rspec-users] Testing for particular CSS (i.e. display: none)
Perfect. That''s really nifty. I''m also reading the comments in selector_assertions.rb in actionpack. On 9/25/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > On 9/25/07, David James <davidj503 at gmail.com> wrote: > > I have a page that hides elements using CSS display: none. > > > > I don''t expect RSpec to test any changes made by Javascript; I just want > to > > test how the page loads initially: what is visible and what is not. > > If the css is expressed in-line in the html, then you can do it like > so (example assumes a div with id foo that should be hidden): > > response.should have_tag(''div#foo[style=?]'', /display:\s*none/) > > have_tag wraps asset_select, so have a look at the assert_select docs > for more info-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070925/8d8f5a87/attachment.html