Created
June 3, 2011 18:15
-
-
Save charlietanksley/1006839 to your computer and use it in GitHub Desktop.
First pass at a RubySpec
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 File.expand_path('../../../spec_helper', __FILE__) | |
describe "Kernel#is_a?" do | |
it "returns true when object really is in that class" do | |
obj = String.new | |
obj.is_a?(String).should be_true | |
end | |
it "returns true when asked about a superclass" do | |
obj = String.new | |
obj.is_a?(Object).should be_true | |
end | |
it "returns false when the object is of another kind" do | |
obj = String.new | |
obj.is_a?(Fixnum).should be_false | |
end | |
it "returns false for a sub-class" do | |
obj = Object.new | |
obj.is_a?(String).should be_false | |
end | |
it "returns true when asked about a module that is mixed in" do | |
module M; end | |
class A | |
include M | |
end | |
obj = A.new | |
obj.is_a?(M).should be_true | |
end | |
it "returns false when asked about a module that is not mixed in" do | |
module Z; end | |
class A | |
end | |
obj = A.new | |
obj.is_a?(Z).should be_false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment