Sha256: bac8b58ced31b23570023b8843578fef0abcdff780b3fddcee545c74f7378a89

Contents?: true

Size: 1.45 KB

Versions: 182

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/common_concern'

RSpec.describe ::EacRubyUtils::CommonConcern do
  let(:instance) do
    described_class.new do
      self.valor = 'changed'
    end
  end

  let(:stub_module) do
    ::Module.new do
      module ClassMethods # rubocop:disable RSpec/LeakyConstantDeclaration
        def my_class_method
          'class'
        end
      end

      module InstanceMethods # rubocop:disable RSpec/LeakyConstantDeclaration
        def my_instance_method
          'from_module'
        end
      end
    end
  end

  let(:stub_class) do
    ::Class.new do
      class << self
        attr_accessor :valor
      end

      def my_instance_method
        'from_class'
      end
    end
  end

  let(:stub_class_instance) { stub_class.new }

  before do
    instance.setup(stub_module)
  end

  context 'when included' do
    before do
      stub_class.include stub_module
    end

    it { expect(stub_class_instance.my_instance_method).to eq('from_class') }
    it { expect(stub_class_instance.class.my_class_method).to eq('class') }
    it { expect(stub_class_instance.class.valor).to eq('changed') }
  end

  context 'when prepended' do
    before do
      stub_class.prepend stub_module
    end

    it { expect(stub_class_instance.my_instance_method).to eq('from_module') }
    it { expect(stub_class_instance.class.my_class_method).to eq('class') }
    it { expect(stub_class_instance.class.valor).to eq('changed') }
  end
end

Version data entries

182 entries across 182 versions & 3 rubygems

Version Path
eac_tools-0.76.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.76.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.75.2 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.75.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.75.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.74.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.74.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.73.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.72.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.70.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.70.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.69.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.69.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.68.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.67.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.67.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.66.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.65.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.65.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb
eac_tools-0.64.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb