[rspec-users] Caveman Questions - how to use mock_model in script/console?

David Chelimsky dchelimsky at gmail.com
Fri Oct 5 13:10:36 EDT 2007


On 10/5/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> On 10/5/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > On 10/5/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
> > >
> > >
> > > On Sep 11, 2007, at 2:37 PM, Geoffrey Wiseman wrote:
> > > On 9/5/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > > > irb(main):001:0> require 'rubygems'
> > > > => true
> > > > irb(main):002:0> require 'spec'
> > > > => true
> > > > irb(main):003:0> include Spec::Matchers
> > > > => Object
> > > > irb(main):004:0> 5.should == 5
> > > > => nil
> > > > irb(main):005:0> 5.should be < 4
> > > > Spec::Expectations::ExpectationNotMetError: expected < 4,
> > > got 5
> > > >
> > >
> > > $ script/console
> > > Loading development environment.
> > > >> require 'rubygems'
> > > => []
> > > >> require 'spec'
> > > NameError: undefined method `failure_message' for class
> > > `Spec::Matchers::Have'
> > >         from
> > > /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4:in
> > > `alias_method'
> > >         from
> > > /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4
> > >         from
> > > /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
> > > `gem_original_require'
> > >
> > >
> > > David - I haven't seen a follow up to this post.  Could you guide me on the
> > > right direction?
> > >
> > > I see that in irb I can include Spec::Mocks::SpecMethods, which allows me
> > > mock 'something'.  How would I get access to mock_model?
> >
> > huh? I don't see how the except you quoted relates to mock model
>
> never mind
>
> gimme a few

Well - I see what the error is coming from. When you say require
'spec' in script/console it's loading up files in
vendor/rspec_on_rails before vendor/rspec. In this case, that's
causing an alias_method call to choke because there's no method to
alias.

So the trick is going to be to coerce script/console into loading
things in the right order.

>
> >
> > >
> > > Scott
> > >
> > >
> > > _______________________________________________
> > > rspec-users mailing list
> > > rspec-users at rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/rspec-users
> > >
> >
>


More information about the rspec-users mailing list