Skip to content

Commit

Permalink
Initial module specs
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Sep 22, 2012
1 parent 381fd9d commit d6352f2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec/core/module/alias_method_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AliasMethodSpec
def foo; 'foo'; end
alias_method :bar, :foo
end

describe "Module#alias_method" do
it "makes a copy of the method" do
AliasMethodSpec.new.bar.should == 'foo'
end
end
11 changes: 11 additions & 0 deletions spec/core/module/ancestors_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module ModuleAncestorsSpec
class A; end
class B < A; end
end

describe "Module#ancestors" do
it "returns a list of modules in self (including self)" do
ModuleAncestorsSpec::B.ancestors.include?(ModuleAncestorsSpec::B).should == true
ModuleAncestorsSpec::B.ancestors.include?(ModuleAncestorsSpec::A).should == true
end
end
14 changes: 14 additions & 0 deletions spec/core/module/append_features_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module AppendFeaturesSpec
class Klass; end

def self.append_features(mod)
ScratchPad.record mod
end
end

describe "Module#append_features" do
it "gets called when self is included in another module/class" do
AppendFeaturesSpec::Klass.include AppendFeaturesSpec
ScratchPad.recorded.should == AppendFeaturesSpec::Klass
end
end

0 comments on commit d6352f2

Please sign in to comment.