On 9/1/07, Andrew WC Brown <[EMAIL PROTECTED]> wrote:
> After a quick google search:
>
> http://www.slideshare.net/viget/mockfight-flexmock-vs-mocha

In fairness - there is something lacking in the slide set - it
suggests that mocha supports parameter matchers and flexmock does not.
In fact, flexmock does. You can do this:

mock.should_receive(:message).with(String).once

and it will pass if the mock receives the message w/ a String. In
mocha, you have to say:

mock.expects(:message).with(kind_of(String))

Flexmock compares args using ===, which is why this works implicitly.

Similarly, mocha, flexmock, and rspec can all take an argument matcher
- an object that responds to == and gives you the right answer. So,
you can do this w/ any of these frameworks:

class LessThan
  def initialize(threshold)
    @threshold = threshold
  end

  def ==(other)
    other < @threshold
  end
end

def less_than(expected)
  LessThan.new(expected)
end

mock.expects(:message).with(less_than(3))
mock.should_receive(:message).with(less_than(3))

Cheers,
David

>
> I have no problem using a external mocking framework but its the choosing.
> convention over configuration.
>
>
>
> On 9/1/07, rupert <[EMAIL PROTECTED]> wrote:
> >
> > On 1 Sep 2007, at 18:16, Andrew WC Brown wrote:
> >
> > > My question is what would you recommend for Mocking?
> > >
> > > Mocha or FlexMock?
> >
> > Personally, I've not got a clue as all I've used to date is the rspec
> > mocking framework.  I've had a quick look at Mocha and it seems
> > pretty good, but haven't looked into FlexMock at all yet.
> >
> > +1 to anyone who's used both these can comment on the differences!
> >
> >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
>
>
>
> --
> Monsterbox Productions
> putting small businesses on-line
>
> 1319 Victoria Avenue East
> Thunder Bay, Ontario P7C 1C3
> Canada
>
> Andrew WC Brown
> web-developer and owner
> [EMAIL PROTECTED]
> P: 807-626-9009
>  F: 807-624-2705
> _______________________________________________
> 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

Reply via email to