Skip to content

Commit

Permalink
spec for calling a ruby bound function method without context + compa…
Browse files Browse the repository at this point in the history
…ring functions of the same ruby class
  • Loading branch information
kares committed Apr 13, 2012
1 parent 306df95 commit 74ebcca
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/redjs/spec/context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,25 @@ def foo(*args); args; end
@cxt.eval('obj.foo === obj.foo').should be(true)
end

it "recognizes functions on objects of the same class being equal" do
@class.class_eval do
def foo(*args); args; end
self
end
@cxt['one'] = @class.new
@cxt['two'] = @class.new
@cxt.eval('one.foo == two.foo').should be(true)
end

it "fails without the correct context passed to an object function" do
@class.class_eval do
def foo(*args); args; end
end
@cxt['obj'] = @class.new
@cxt.eval('var foo = obj.foo;')
lambda { @cxt.eval('foo()') }.should raise_error
end

it "can call a bound ruby method" do
five = class_eval do
def initialize(lhs)
Expand Down

0 comments on commit 74ebcca

Please sign in to comment.