1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Merge pull request #110 from tmaier/issue-8

Refactor #kind_of? specs for Draper::Base and alias :is_a? :kind_of?
This commit is contained in:
Steve Klabnik 2012-01-05 10:08:37 -08:00
commit 0fe648c305
2 changed files with 21 additions and 6 deletions

View file

@ -155,6 +155,7 @@ module Draper
def kind_of?(klass)
super || model.kind_of?(klass)
end
alias :is_a? :kind_of?
def respond_to?(method, include_private = false)
super || (allow?(method) && model.respond_to?(method))

View file

@ -443,12 +443,6 @@ describe Draper::Base do
end
end
describe "decorator in cancan rules" do
it "should answer yes to kind_of? source class" do
subject.kind_of?(source.class).should == true
end
end
describe "#method_missing" do
context "when #hello_world is called for the first time" do
it "hits method missing" do
@ -465,4 +459,24 @@ describe Draper::Base do
end
end
end
describe "#kind_of?" do
context "pretends to be of kind of model class" do
it "#kind_of? decorator class" do
subject.should be_kind_of subject.class
end
it "#is_a? decorator class" do
subject.is_a?(subject.class).should be_true
end
it "#kind_of? source class" do
subject.should be_kind_of source.class
end
it "#is_a? source class" do
subject.is_a?(source.class).should be_true
end
end
end
end