I’m trying to write a failure test for updating a model, but the
flash[:error].should =~ /Name can’t be blank/i
As Paul pointed out correctly flash[:error] == nil, thus your spec
works quite correctly. All you have to do now is to set flash[:error]
appropriately, in your case I guess that this should be done by means
of ActiveRecord/ActiveModel validations.
Are you sure that you have the necessary validation in your Task model?
HTH
Robert
–
The 1,000,000th fibonacci number contains ‘42’ 2039 times; that is
almost 30 occurrences more than expected (208988 digits).
N.B. The 42nd fibonacci number does not contain ‘1000000’ that is
almost the expected 3.0e-06 times.
the question you need to ask is: is flash[:error] a variable within the
scope that you’re working ? … I suspect that it’s not, although I
could be
wrong.
with that in mind, does anyone know of a way of determining which
variables
are accessible via rspec on each (MVC) layer ?, Is it a simple case of
‘what’s accessible in the controller is accessible in the controller
spec’
(for example) ?, or is it more complicated ?
the question you need to ask is: is flash[:error] a variable within the
scope that you’re working ? … I suspect that it’s not, although I could be
wrong.
with that in mind, does anyone know of a way of determining which variables
are accessible via rspec on each (MVC) layer ?, Is it a simple case of
‘what’s accessible in the controller is accessible in the controller spec’
(for example) ?, or is it more complicated ?
cheers
On Mon, Nov 22, 2010 at 9:55 PM, Robert D. [email protected]
wrote:
Paul, it was a little bit tricky to answer this because of the top
post, most of us are not used to that. So please if you can, do rather
bottom post or inline post.
That said, I am not sure what you mean by flash[:error] being a
variable?
As the trace shows flash[:error] is nil, from this alone, we can
follow that flash points to an object which responds to the #[]
message. In our case it replies to [:error] with nil. However in the
given context we know that flash is a Hash representing well, the
flash. I am not an expert to tell you where in the rspec setup this is
mocked, but this should not be the problem in our case.
That said I would be happy to learn more about that mechanism.
Cheers
R.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.