Sha256: 8b39dafb2ba34327ee201440677f5116564075e24a7c1a8a33bec4f44637de3f

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 KB

Contents

require 'ronin/code/reference'

require 'spec_helper'
require 'code/classes/thing'

describe Code::Reference do
  before(:all) do
    @object = Thing.new
    @ref = Code::Reference.new(@object)
  end

  it "should provide direct access to the referenced object" do
    @ref.value.should == @object
  end

  it "should be a kind of Reference" do
    @ref.kind_of?(Code::Reference).should == true
    @ref.is_a?(Code::Reference).should == true
    @ref.instance_of?(Code::Reference).should == true
  end

  it "should have the class of the referenced object" do
    @ref.class.should == Thing
  end

  it "should be a kind of the referenced object type" do
    @ref.kind_of?(Thing).should == true
    @ref.is_a?(Thing).should == true
    @ref.instance_of?(Thing).should == true
  end

  it "should be equal to itself" do
    @ref.eql?(@ref).should == true
    @ref.should == @ref
    @ref.should === @ref
  end

  it "should be equal to the referenced object" do
    @ref.eql?(@object).should == true
    @ref.should == @object
    @ref.should === @object
  end

  it "should respond to Reference methods" do
    @ref.respond_to?(:value).should == true
  end

  it "should respond to the methods of the referenced object" do
    @ref.respond_to?(:exposed).should == true
  end

  it "should relay method calls to the referenced object" do
    @ref.exposed.should == 1
  end

  it "should raise a NoMethodError when trying to call a protected or private method" do
    lambda { @ref.not_exposed }.should raise_error(NoMethodError)
  end

  it "should inspect the referenced object when inspect is called" do
    @ref.inspect.should == '#<Thing: stuff>'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-0.3.0 spec/code/reference_spec.rb
ronin-0.2.4 spec/code/reference_spec.rb