Have_tag missing assert_select outside of controller/view tests

Hi,

I’m trying to write an example that uses response.should have_tag(‘div’)
outside of a Rails view test. I read somewhere that as long as you
have an instance variable named @response and it respondes to .body
with some HTML, it should work, but I get this failure:

undefined method `assert_select’ for
#<ActiveSupport::TestCase::Subclass_1:0x103

Also, has anyone cooked this up to work with Sinatra, or are you
restricted to using Rails? Seems that some Nokogiri wiz could work up
a substitute for ActiveSupport.

Thanks,
Ed

Ed Howland


http://twitter.com/ed_howland

On Wed, Feb 17, 2010 at 12:47 PM, Ed Howland [email protected]
wrote:

Hi,

I’m trying to write an example that uses response.should have_tag(‘div’)
outside of a Rails view test. I read somewhere that as long as you
have an instance variable named @response and it respondes to .body
with some HTML, it should work, but I get this failure:

have_tag is on its way to its death. It won’t exist in rspec-rails-2,
though I hesitate to deprecate it in rspec-rails-1.x since many folks
won’t be able to upgrade directly anyhow.

I’d recommend using webrat’s have_selector instead.

Thanks, David.

I hope that is less/non dependent on Rails/ActiveSupport. It seems to
depend on Nokogiri, and hopefully uses some duck-typeable response
object. I guess they use response_body.

I’ve concocted a strange brew of RSpec, Johnson and envjs. It can
already
execute normal Javascript methods, jQuery, and AJAX calls. The only
missing piece is the assert_select-like framework:

it “should make an ajax call and format some content” do
click_async “a#edit”
response.should have_selector(‘div’) # this last part, I need
end

I don’t know if anyone else is working on this front, but it is
getting us closer to having a pure Ruby/non-browser spec framework

Cheers,
Ed

Ed Howland
http://greenprogrammer.wordpress.com
http://twitter.com/ed_howland

Thanks for the advice,

Webrat’s have_select or does work with any object that responds to
:body. so I’ve now got it working with Steven P.'s Env.js port to
Johnson w/TraceMonkey.

RSpec on Javascript w/o a browser. Sweet.

Cheers,
Ed

Ed Howland
http://greenprogrammer.wordpress.com
http://twitter.com/ed_howland

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs