当我想测试属性是否 / 无法使用 RSpec访问时,我正在这样做
class Foo
attr_accesible :something_else
end
describe Foo do
it('author should not be accessible') {lambda{described_class.new(:author=>true)}.should raise_error ActiveModel::MassAssignmentSecurity::Error}
it('something_else should be accessible'){lambda{described_class.new(:something_else=>true)}.should_not raise_error ActiveModel::MassAssignmentSecurity::Error}
end
有更好的方法吗?
...谢谢