Sha256: 1ce0e451fe16cd0425e27f898989cac3dc487139ce205a7a5b9165d0c11c877e

Contents?: true

Size: 832 Bytes

Versions: 4

Compression:

Stored size: 832 Bytes

Contents

require 'spec_helper'

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

      def self.bar(bam)
      end

      def self.hello
      end
    end

    let(:class_methods) { ClassMethods.new(SampleClass) }

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

    it "returns the instance methods by name" do
      class_methods.get(:bar).should ==
        SampleClass.method(:bar)
    end

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

      SampleClass.should_not respond_to(:hello)
    end

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

      SampleClass.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/class_methods_spec.rb
bogus-0.0.4 spec/bogus/class_methods_spec.rb
bogus-0.0.3 spec/bogus/class_methods_spec.rb
bogus-0.0.3.rc.2 spec/bogus/class_methods_spec.rb