Created
May 22, 2013 01:12
-
-
Save marocchino/5624554 to your computer and use it in GitHub Desktop.
included 타이밍에 변경한걸 되돌리기 힘들어서 결국 매번 새로만들기로 했어요.
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
module Yahoo | |
self.included(base) | |
base.messages << :yahoo | |
end | |
end |
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
require 'spec_helper' | |
describe Yahoo do | |
let(:yahoo_included_test_object) do | |
class_with(Yahoo).new | |
end | |
let(:test_object) do | |
TestBase.new | |
end | |
it { yahoo_included_test_object.class.messages.should include(:yahoo)} | |
it { test_object.class.messages.should_not include(:yahoo)} | |
end |
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
class TestBase | |
def self.messages | |
@messages ||= [] | |
end | |
end | |
def class_with(*modules) | |
Class.new(TestBase) do | |
include modules | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment