Sha256: 67d618fe8ffa22684ef7738b2e4a9530997216093586ed1efaed058487bccc37

Contents?: true

Size: 861 Bytes

Versions: 7

Compression:

Stored size: 861 Bytes

Contents

require "spec_helper"

module Chanko
  module Unit
    describe Extender do
      before do
        stub_const("ExampleClass", Class.new)
      end

      it "extends instance methods" do
        Extender.new.expand(:ExampleClass) do
          def test
            "test"
          end
        end
        ExampleClass.new.test.should == "test"
      end

      it "extends class methods" do
        Extender.new.expand(:ExampleClass) do
          class_methods do
            def test
              "test"
            end
          end
        end
        ExampleClass.test.should == "test"
      end

      it "extends instance methods with prefix" do
        Extender.new("__prefix_").expand(:ExampleClass) do
          def test
            "test"
          end
        end
        ExampleClass.new.__prefix_test.should == "test"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chanko-2.0.6 spec/chanko/unit/extender_spec.rb
chanko-2.0.5 spec/chanko/unit/extender_spec.rb
chanko-2.0.4 spec/chanko/unit/extender_spec.rb
chanko-2.0.3 spec/chanko/unit/extender_spec.rb
chanko-2.0.2 spec/chanko/unit/extender_spec.rb
chanko-2.0.1 spec/chanko/unit/extender_spec.rb
chanko-2.0.0 spec/chanko/unit/extender_spec.rb