On Jan 10, 2008 12:25 PM, Jarkko Laine <[EMAIL PROTECTED]> wrote:
> Also, this line of code is a bit smelly:
>
> >> normalized = @signup.normalize_mac(@signup.mac_address)
>
> Since normalize_mac is an instance method in the Signup class, there's
> no point passing the mac_address as a parameter; the method can simply
> call the mac_address method directly. If you want to make it more
> general-purpose, it doesn't sound like it should be an instance method
> anymore.
Right, you could pull this into a MacAddress class, and use that:
describe MacAddress, " for 00-11-22-33-44-55" do
it "should normalize to 00:11:22:33:44:55" do
MacAddress.new("00-11-22-33-44-55").to_s.should == "00:11:22:33:44:55"
end
end
Then you can just do
@signup.mac_address = MacAddress.new "00-11-22-33-44-55"
and you don't really need to test that, of course, since it's just a setter.
Pat
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users