File: builder_spec.rb

package info (click to toggle)
ruby-nenv 0.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 184 kB
  • sloc: ruby: 517; sh: 4; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 600 bytes parent folder | download | duplicates (4)
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
require 'nenv/builder'

RSpec.describe Nenv::Builder do
  describe '#build' do
    before do
      allow(ENV).to receive(:[]).with('FOO')
    end

    it 'returns a class with the given methods' do
      FooEnv = Nenv::Builder.build do
        create_method(:foo?)
      end
      FooEnv.new.foo?
    end

    context 'with duplicate methods' do
      it 'fails' do
        expect do
          FooEnv = Nenv::Builder.build do
            create_method(:foo?)
            create_method(:foo?)
          end
        end.to raise_error(Nenv::Environment::AlreadyExistsError)
      end
    end
  end
end