It's interesting that this thread has started because I just ran into 
this problem.

The error I got was:

NoMethodError in 'Signup she be a valid mac address'
protected method `normalize_mac' called for #<Signup:0x408c0434>
./spec/models/signup_spec.rb:10:


Here's the spec:

describe Signup do
  before(:each) do
    @signup = Signup.new
  end

  it "she be a valid mac address" do
     @signup.mac_address = "00-11-22-33-44-55-66"
     normalized = @signup.normalize_mac(@signup.mac_address)
     @signup.mac_address.should == normalized
  end
end


I have a model that has mac_address attribute.  In the before 
validation, I wanted to make the mac address have colons(:) instead of 
whatever the user typed in which could have spaces between, dashes, 
nothing at all.

My thought was to just remove all of those special characters validate 
it against a regex then if it passed the regex check produce the mac 
address with the colons included.

And, if I understand it properly, Pat's statement is saying that I 
really shouldn't be protecting that method...which would fix my problem.

So my question is then, how do you know when to use protected and 
private or do I just do what Rick suggested and use send?

I just realized this isn't really an rspec question...so I'll just move along.

Mike B.

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to