support alternative stubbing frameworks #1

Closed
jfirebaugh opened this Issue May 24, 2010 · 3 comments

Comments

Projects
None yet
2 participants

validation.rb calls stub! directly, which prevents rspec_sequel_matchers from being used in any project that uses an alternative stubbing/mocking framework.

I'd like to use it, but I use mocha.

@ghost

ghost commented May 24, 2010

Ok. I've not used mocha yet, what should I use to be compatible to both rspec native stubbing and mocha? Pull request with working specs would be highly welcomed.

Looking at equivalent libraries for ActiveRecord, such as remarkable (http://github.com/remarkable/remarkable) and shoulda (http://github.com/thoughtbot/shoulda), it looks like they implement this by setting the attribute under test to an invalid value and then checking that #valid? returns false and #errors.on returns the expected value. I.e. they don't use stubbing at all.

Sorry for the issue report without a fork and pull request -- I'm pressed for time at the moment.

@ghost

ghost commented May 25, 2010

If you look at sequel source code, you'll see that they've already tested each validation method, so that you don't need to do it in each app. I dislike adding tests to already well tested code. Moreover testing different values is not without issue, it can easily give you a fake security feeling. I've seem there's an .expect method in mocha which seems to do the same as .should_receive and could perhaps be used. Unluckily I don't use mocha personally, but as said fell free to fork the project if you want to extend it's use for mocha, flex mock, etc.

jfirebaugh closed this Mar 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment