Re: [rspec-users] Mocking base class methods

2009-03-21 Thread Jeroen van Dijk
> > describe "count_by_params" do > > it "should pass all the params and options to #scope_by_params" do > > params = { :foo => 1, :bar => 2 } > > options = { :foo => 3, :bar => 4 } > > > > @base = ActiveRecord::Base > > @result = mock("query results", :count => 1) >

Re: [rspec-users] Mocking base class methods

2009-03-20 Thread Zach Dennis
2009/3/20 Jeroen van Dijk : > Huray, got it solved! Hopefully you'll agree with this solution (thanks to > mocha sorry) > > >   describe "count_by_params" do >     it "should pass all the params and options to #scope_by_params" do >   params  = { :foo => 1, :bar => 2 } >   options = { :foo

Re: [rspec-users] Mocking base class methods

2009-03-20 Thread Jeroen van Dijk
Huray, got it solved! Hopefully you'll agree with this solution (thanks to mocha sorry) describe "count_by_params" do it "should pass all the params and options to #scope_by_params" do params = { :foo => 1, :bar => 2 } options = { :foo => 3, :bar => 4 } @base = ActiveRec

Re: [rspec-users] Mocking base class methods

2009-03-19 Thread Jeroen van Dijk
Hi all, I'm having the same problem as Tobi and I wanted to try Tobi mock solution but unfortunately it does not work for me. Here is a trivial example I want to test: module ActiveRecord class Base def self.count_by_params(params = {}, options = {}) scoped_by_params(params).co

Re: [rspec-users] Mocking base class methods

2009-02-21 Thread Tobi
Zach Dennis wrote: > +1 to composition over inheritance here. Mocking at different layers > of an inheritance hierarchy sounds like trouble and screams to pull > that thing apart. Good point! I've already tried the composition approach. It solves the testabilitiy problems, but it doesn't feel rig

Re: [rspec-users] Mocking base class methods

2009-02-21 Thread Zach Dennis
On Sat, Feb 21, 2009 at 6:31 AM, Tobi wrote: > Hi! > > I need to write some wrapper classes, that derive from SWIG generated > proxy classes for some C/C++ extensions. > > The Ruby wrapper classes need to do a lot of 'super' calls to the base > classes generated by SWIG. > > The question is: Is th

[rspec-users] Mocking base class methods

2009-02-21 Thread Tobi
Hi! I need to write some wrapper classes, that derive from SWIG generated proxy classes for some C/C++ extensions. The Ruby wrapper classes need to do a lot of 'super' calls to the base classes generated by SWIG. The question is: Is there any way to make RSpec mock a base class and record/verify