Sha256: e361dcc32d6701861ac143241e609ee20c1b35728b50f24e7eb68ae0c6d6c01a

Contents?: true

Size: 861 Bytes

Versions: 8

Compression:

Stored size: 861 Bytes

Contents

require "spec_helper"

module Nyanko
  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

8 entries across 8 versions & 1 rubygems

Version Path
nyanko-0.0.9 spec/nyanko/unit/extender_spec.rb
nyanko-0.0.8 spec/nyanko/unit/extender_spec.rb
nyanko-0.0.7 spec/nyanko/unit/extender_spec.rb
nyanko-0.0.6 spec/nyanko/unit/extender_spec.rb
nyanko-0.0.5 spec/nyanko/unit/extender_spec.rb
nyanko-0.0.4 spec/nyanko/unit/extender_spec.rb
nyanko-0.0.3 spec/nyanko/unit/extender_spec.rb
nyanko-0.0.1 spec/nyanko/unit/extender_spec.rb