Sha256: 9b9c825a7c4846b34f586f82d6cc8147dddce839e304b90ada8ba18ab1c66cc8

Contents?: true

Size: 891 Bytes

Versions: 4

Compression:

Stored size: 891 Bytes

Contents

require 'spec_helper'

module Bogus
  describe InstanceMethods do
    class SampleClass
      def foo(bar)
      end

      def hello
      end

      def self.bar(bam)
      end
    end

    let(:instance_methods) { InstanceMethods.new(SampleClass) }

    it "lists the instance methods" do
      instance_methods.all.should == [:foo, :hello]
    end

    it "returns the instance methods by name" do
      instance_methods.get(:foo).should ==
        SampleClass.instance_method(:foo)
    end

    it "removes methods by name" do
      instance_methods.remove(:hello)

      SampleClass.new.should_not respond_to(:hello)
    end

    it "defines instance methods" do
      instance_methods.define <<-EOF
      def greet(name)
        return "Hello, " + name + "!"
      end
      EOF

      instance = SampleClass.new

      instance.greet("Joe").should == "Hello, Joe!"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bogus-0.1.0 spec/bogus/instance_methods_spec.rb
bogus-0.0.4 spec/bogus/instance_methods_spec.rb
bogus-0.0.3 spec/bogus/instance_methods_spec.rb
bogus-0.0.3.rc.2 spec/bogus/instance_methods_spec.rb