Sha256: cb520b203b59f61bd5c8bfbc5c75c7f4853ac85ac261a58d7e1f2bfdc1d50d7f

Contents?: true

Size: 855 Bytes

Versions: 39

Compression:

Stored size: 855 Bytes

Contents

class RespondToSpecs
  def self.bar
    'done'
  end

  def undefed_method
    true
  end

  undef undefed_method

  def some_method
    :foo
  end
end

describe "Kernel.respond_to?" do
  it "indicates if a singleton object responds to a particular message" do
    RespondToSpecs.respond_to?(:bar).should == true
    RespondToSpecs.respond_to?(:baz).should == false
  end
end

describe "Kernel#respond_to?" do
  before :each do
    @a = RespondToSpecs.new
  end

  it "returns true if a method exists" do
    @a.respond_to?(:some_method).should be_true
  end

  it "indicates if an object responds to a message" do
    @a.respond_to?(:undefed_method).should be_false
  end

  it "returns false if a method exists, but is marked with a '$$stub' property" do
    `#{@a}.$some_method.$$stub = true`
    @a.respond_to?(:some_method).should be_false
  end
end

Version data entries

39 entries across 39 versions & 3 rubygems

Version Path
opal-0.10.6 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.6.beta spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.5 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.4 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.3 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.2 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.1 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.0 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.0.rc2 spec/opal/core/kernel/respond_to_spec.rb
opal-0.9.4 spec/opal/core/kernel/respond_to_spec.rb
opal-0.9.3 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.0.rc1 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.0.beta5 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.0.beta4 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.0.beta3 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.0.beta2 spec/opal/core/kernel/respond_to_spec.rb
opal-0.10.0.beta1 spec/opal/core/kernel/respond_to_spec.rb
opal-0.9.2 spec/opal/core/kernel/respond_to_spec.rb
opal-0.9.0 spec/opal/core/kernel/respond_to_spec.rb
opal-0.9.0.rc1 spec/opal/core/kernel/respond_to_spec.rb