When you spec runs (and your stub! is called) the method has already been called, so your stub will never catch anything.
- Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Thu, Aug 20, 2009 at 5:03 PM, BallaBall<ba...@sogetthis.com> 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 > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users