Sha256: 5d4dba30aa8ac8729951cbd9d274f7e3cc90a4e9e064575841ad1416dd34c8d4

Contents?: true

Size: 1.29 KB

Versions: 3

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)
          expect(actual).to eq 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

3 entries across 3 versions & 1 rubygems

Version Path
bogus-0.1.7 spec/bogus/fakes/base_class_identifier_spec.rb
bogus-0.1.6 spec/bogus/fakes/base_class_identifier_spec.rb
bogus-0.1.5 spec/bogus/fakes/base_class_identifier_spec.rb