ruby on rails - In a controller spec, how to find a specific tag in the generated view? -
i know integration tests preferred need ran in controller test, i'm testing gem injecting html code in view, xhr can't run in feature spec (if can, please explain me how :) )
so rspec controller tests can assert selector present (with capybara) :
response.body.should have_selector('#foobar')
has_selector?
call all
method capybara find selector.
what want last child of body , assert id in particular.
afaik it's not possible have_selector.
what :
all('body:first-child').first.id.should == '#foobar'
however, capybara dsl, defined (more or less):
def all(*args) page.all(*args) end
and page empty unless use visit
it's integrations specs.
how can use capybara all
method inside rspec controller test ?
i can't test right after googling seems trick
def page capybara::node::simple.new(response.body) end
Comments
Post a Comment