Skip to content

Instantly share code, notes, and snippets.

@charlietanksley
Created June 3, 2011 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charlietanksley/1006839 to your computer and use it in GitHub Desktop.
Save charlietanksley/1006839 to your computer and use it in GitHub Desktop.
First pass at a RubySpec
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