Sha256: 196a07449dc891dc4a6749b9656fdde4f26bec3c4f76bac988d9b1d6aca96ac5

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

module SampleForBaseIdentifier
  describe Bogus::BaseClassIdentifier do
    module Foo
      def foo; end
    end

    module Bar
      include Foo
      def bar; end
    end

    module Baz
      def baz; end
    end

    module OtherModule
    end

    class SuperBase
    end

    class BaseClass < SuperBase
      include Bar
      def x; end
    end

    class SubClass < BaseClass
      include Baz
      def y; end
    end

    class OtherClass
    end

    class BarInstance
      include Bar
    end

    def self.it_returns_the_same_value_as_a_regular_instance
      klasses = [Foo, Bar, Baz, OtherModule,
        SuperBase, BaseClass, SubClass, OtherClass]
      klasses.each do |klass|
        it "returns the same for is_a?(#{klass})" do
          expected = instance.is_a?(klass)
          actual = Bogus::BaseClassIdentifier.base_class?(copied_class, klass)
          actual.should == expected
        end
      end
    end

    context "with copied module" do
      let(:copied_class) { Bar }
      let(:instance) { BarInstance.new }

      it_returns_the_same_value_as_a_regular_instance
    end

    context "with copied class" do
      let(:copied_class) { SubClass }
      let(:instance) { SubClass.new }

      it_returns_the_same_value_as_a_regular_instance
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bogus-0.1.4 spec/bogus/fakes/base_class_identifier_spec.rb