Reputation: 129
I have following code like this in 'artists_helpers' class.
def round_to(x)
(self * 10**x).round.to_f / 10**x
end
Similarly, in the artist_helper_spec.rb, I have code like this.
describe ArtistsHelper do
it "should return a two digits after decimal" do
mock=12.234
mock.round_to(2).should == 12.23
end
end
How do I write script to make this function to test.
The problem is that, I dont get value of ':self' variable in helpers, when running rspec test.
Is their any other links which are helpful ?
Upvotes: 1
Views: 1152