Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't raise a NoMethod error for attributes with a falsy value.
Fixes a problem with the Attributes mixin where an attribute set with a falsy value such as false or nil, the model would not respond to the attribute reader.
- Loading branch information
Showing
3 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
require File.expand_path('../../start', __FILE__) | |||
|
|||
class Mole | |||
include Broach::Attributes | |||
end | |||
|
|||
describe "A class with Attributes" do | |||
before do | |||
@mole = Mole.new('name' => "Jerry", 'glasses' => false, 'description' => nil) | |||
end | |||
|
|||
it "returns it's attribute through accessor methods" do | |||
@mole.name.should == "Jerry" | |||
@mole.glasses.should.be.false | |||
@mole.description.should.be.nil | |||
end | |||
|
|||
it "does not respond to methods for attributes which haven't been set" do | |||
lambda { | |||
@mole.unknown | |||
}.should.raise(NoMethodError) | |||
end | |||
end |