method
attr_readonly
attr_readonly(*attributes)
public
Register or
log in
to add new notes.
THAiSi -
August 5, 2011
0 thanks
Speccing read_only requirements
To test if an attribute is defined readonly:
class MyModel < ActiveRecord::Base attr_readonly :important_type_thingie end #RSpec describe MyModel do its('class.readonly_attributes') { should include "important_type_thingie" } it "should not update the thingie" do m = create :my_model, :important_type_thingie => 'foo' m.update_attributes :important_type_thingie => 'bar' m.reload.important_type_thingie.should eql 'foo' end end


