Sha256: aa3358fbfe2fea506edcca12c614fa907518b9e7e43c0dc7f25176e5dfea6b10

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

require 'spec_helper'

describe CallerClass do
  context 'call from the body of a class definition' do
    let(:a) do
      class A
        extend CallerClass

        caller_class
      end
    end

    it { expect(a).to eq('A') }
  end

  context 'call from the body of a nested class definition' do
    let(:b) do
      class B
        class BB
          extend CallerClass

          caller_class
        end
      end
    end

    it { expect(b).to eq('BB') }
  end

  context 'call from extended class' do
    let(:c) do
      module C
        include CallerClass

        def c
          caller_class
        end
      end

      class CC
        extend C

        c
      end
    end

    it { expect(c).to eq('CC') }
  end

  context 'call from module' do
    let(:d) do
      module D
        extend CallerClass

        caller_class
      end
    end

    it { expect(d).to be_nil }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caller_class-0.0.1 spec/caller_class_spec.rb