Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug with accessors defined in modules (fixes #388)
Accessors defined in modules were not being inherited by classes that included the module. This commit fixes that bug by adding accessors to the donate list which a module keeps track of.
- Loading branch information
1 parent
4639b80
commit 36b4f94
Showing
2 changed files
with
20 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
require 'spec_helper' | ||
|
||
module AttrAccessorSpec | ||
module M | ||
attr_accessor :foo | ||
end | ||
|
||
class C | ||
include M | ||
end | ||
end | ||
|
||
describe "Module#attr_accessor" do | ||
it "can be passed a splat of arguments" do | ||
eval "class OpalAttrAccessorSpec; attr_accessor *%w{foo bar baz}; end" | ||
OpalAttrAccessorSpec.new.foo.should be_nil | ||
end | ||
|
||
describe "inside a module" do | ||
it "defines methods that get donated to a class when included" do | ||
obj = AttrAccessorSpec::C.new | ||
obj.foo = 100 | ||
obj.foo.should == 100 | ||
end | ||
end | ||
end |