File: mixin_spec.rb

package info (click to toggle)
ruby-dry-container 0.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 236 kB
  • sloc: ruby: 976; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 735 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
RSpec.describe Dry::Container::Mixin do
  describe 'extended' do
    let(:klass) do
      Class.new { extend Dry::Container::Mixin }
    end
    let(:container) { klass }

    it_behaves_like 'a container'
  end

  describe 'included' do
    let(:klass) do
      Class.new { include Dry::Container::Mixin }
    end
    let(:container) { klass.new }

    it_behaves_like 'a container'

    context 'into a class with a custom .initialize method' do
      let(:klass) do
        Class.new do
          include Dry::Container::Mixin
          def initialize; end
        end
      end

      it 'does not fail on missing member variable' do
        expect { container.register :key, -> {} }.to_not raise_error
      end
    end
  end
end