Displaying 3 results from an estimated 3 matches for "capfutureresidu".
Did you mean:
capfutureresidual
2006 Dec 21
3
Speccing private class methods
Hi
How can I specify that a private method of a class gets called? If
you run the code below, only spec (1) passes. Spec (2) is what I
found causing problems in my code, and class (3) is my failed attempt
to work around it. (3 really puzzles me - why is a private class
method not accessible via send?)
Another problem is that stub! makes public methods, which changes the
behaviour of
2006 Dec 18
2
should_receive and multiple return values
...bands (Jan-Feb, Mar-Aug, Sep-
Dec) so I wrote a method (registration_date_to_band_year_and_month)
takes a date and returns two return values, the year and month of the
band.
I thought this would work:
specify "should turn the provided registration date into a CAP
band" do
CapFutureResidual.should_receive
(:registration_date_to_band_year_and_month).with(Date.new(2003, 9,
30)).and_return(2003, 9)
CapFutureResidual.should_receive
(:registration_date_to_band_year_and_month).with(Date.new(2005, 3,
1)).and_return(2005, 3)
controller.parse_parameters(
{ :capid2614...
2006 Dec 15
3
Partial mock when a complex return value is required
...And here is the offending spec:
specify "should prefetch the future residuals" do
TODO: ask rspec team about duplicating this logic to get a nice
error message
@derivatives_by_id[26149].should_not_receive
(:cap_future_residuals_for_registration_date).and_return(
CapFutureResidual.find_all_by_derivative_id_and_registration_year_and_re
gistration_month(26149, 2003, 9)
)
end
Sorry for the car finance jargon!!!
How can I get round this? Here is my attempt at an alternative spec
- is this better or worse?
specify "should prefetch the future residuals&quo...