Hello everybody
I’m having some problems with RSpec.
- When using something like “I should see ‘some text’”
that text is set on a flash message in the controller and displayed by
= flash[:notice] in the layout view, so the relevant part of my view
says, in haml:
.notice
= flash[:notice]
The rspec evaluation for that says:
response.should have_text(“blah”)
The spec fails saying that the text “blah” cannot be found on the
response, shows the HTML code that rspec got and, in fact, the text is
not there.
But, if I run the application, the text is shown, even when I run the
application on test mode (RAILS_ENV=test script/server)
I don’t know what can be the difference, it seems that the testing
execution of RSpec is not the same that the application execution.
- When using something like "response.redirected_to.should == “/login”
The RSpec execution is not redirected, the response object has the
status “200 OK”, but if I run the application in that circumstances,
it gets redirected.
It seems like I’m missing something, I’ve used this things
successfully in the past and I don’t know what can be wrong now.
I’m using rspec 1.2.9 and rspec-rails 1.2.9., both set up on the
config/environments/test.rb via config.gem “rspec”, :lib => false,
:version => “>= 1.2.9”
If you need the code, I can “pastie” it, but I don’t know if it will
add noise to the problem description.
Thanx a lot in advance.
–
Leonardo M…
There’s no place like ~