[rspec-users] Testing update, flash[:error]

Paul Nelligan nellboy at gmail.com
Mon Nov 22 17:26:11 EST 2010


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 Dober <robert.dober at gmail.com>wrote:

> On Mon, Nov 22, 2010 at 4:04 PM, Paul Nelligan <nellboy at gmail.com> wrote:
> > Hi Andrew
> > I suspect that flash[:error] is not a valid identifier,  and therefore is
> > returning a nil value.
> > Hope this is of use to you.
> > Paul
> >
> > On Mon, Nov 22, 2010 at 2:00 PM, Andrew Davis <lists at ruby-forum.com>
> wrote:
> >>
> >> Hello everyone,
> >>
> >> I'm trying to write a failure test for updating a model, but the
> >> flash[:error] seems to be causing a problem.
> >>
> >> All code can be found here:
> >> http://pastie.org/private/zcu0fpzbfbjbleocmf1bqw
> >>
> >> I've also tried using regular expressions, instead of:
> >>
> >> flash[:error].should == "Name can't be blank"
> >>
> >> I've tried:
> >>
> >> 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.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101122/e82bc955/attachment.html>


More information about the rspec-users mailing list