[rspec-users] How to write a spec file for a helper

Pat Maddox pat.maddox at gmail.com
Mon Apr 13 11:26:27 EDT 2009

On Mon, Apr 13, 2009 at 8:17 AM, David Chelimsky <dchelimsky at gmail.com> wrote:
> On Mon, Apr 13, 2009 at 12:09 PM, Salil Gaikwad <lists at ruby-forum.com> wrote:
>> How to write a spec file for a following helper
>> module ArtistsHelper
>> def round_to(x)
>>    (self * 10**x).round.to_f / 10**x
>> end
>> end
> in spec/helpers/artists_helper_spec.rb:
> describe AristsHelper do
>  it "rounds to ...." do
>    helper.round_to(xxx).should == yyy
>  end
> end

That's what I was going to say, but I'm not sure that it's a Rails
helper...the calculation rounds self.  So I'm a bit confused.

If this is a module that you're using to extend the behavior of
Numeric classes, just mix it in somewhere and write examples for the
class that got the mixin.


More information about the rspec-users mailing list