Ohhh so when the model is first loaded it has already run the method
im trying to stub?

On Aug 20, 2:00 pm, Maurício Linhares <[email protected]>
wrote:
> When you spec runs (and your stub! is called) the method has already
> been called, so your stub will never catch anything.
>
> -
> Maurício 
> Linhareshttp://codeshooter.wordpress.com/|http://twitter.com/mauriciojr
>
>
>
> On Thu, Aug 20, 2009 at 5:03 PM, BallaBall<[email protected]> wrote:
> > I have some model with the following validation:
>
> >  validates_inclusion_of :value,
> >    :in => I18n.available_locales.map(&:to_s)
>
> > I would think that I would be able to stub out that method in a test
> > like so:
>
> > it "should accepted any available locale as a value" do
> >      I18n.stub!(:available_locales).and_return(['abc'])
>
> >      my_model = MyModel.new( :value => 'abc' )
>
> >      my_model.should have(:no).errors_on(:value)
> > end
>
> > But it keeps failing. It looks like the I18n inside the model is not
> > being stubbed correctly?!?! What am I doing wrong?
> > _______________________________________________
> > rspec-users mailing list
> > [email protected]
> >http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> [email protected]http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to