Sha256: 775372405ce8e282f7b60068587f10a33330ac6e2e65a231fab5e50d01ea85ac

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

require "spec/spec_helper"

module RR
  describe DoubleInsertion, :shared => true do
    it "sets up object and method_name" do
      @double_insertion.object.should === @object
      @double_insertion.method_name.should == @method_name.to_sym
    end
  end

  describe DoubleInsertion, "#initialize where method_name is a symbol" do
    it_should_behave_like "RR::DoubleInsertion"

    before do
      @space = Space.new
      @object = Object.new
      @method_name = :foobar
      @object.methods.should_not include(@method_name.to_s)
      @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
    end
  end

  describe DoubleInsertion, "#initialize where method_name is a string" do
    it_should_behave_like "RR::DoubleInsertion"

    before do
      @space = Space.new
      @object = Object.new
      @method_name = 'foobar'
      @object.methods.should_not include(@method_name)
      @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
    end
  end

  describe DoubleInsertion, "#initialize where method does not exist on object" do
    it_should_behave_like "RR::DoubleInsertion"

    before do
      @space = Space.new
      @object = Object.new
      @method_name = :foobar
      @object.methods.should_not include(@method_name.to_s)
      @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
    end

    it "object does not have original method" do
      @double_insertion.object_has_original_method?.should be_false
    end
  end

  describe DoubleInsertion, "#initialize where method exists on object" do
    it_should_behave_like "RR::DoubleInsertion"

    before do
      @space = Space.new
      @object = Object.new
      @method_name = :to_s
      @object.methods.should include(@method_name.to_s)
      @double_insertion = DoubleInsertion.new(@space, @object, @method_name)
    end

    it "has a original_method" do
      @double_insertion.object_has_original_method?.should be_true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rr-0.4.1 spec/rr/double/double_insertion_spec.rb
rr-0.4.0 spec/rr/double/double_insertion_spec.rb