aboutsummaryrefslogtreecommitdiffstats
path: root/spec/concerns/configurable_spec.rb
blob: 822f572c1d54f240126c145a5e14b17357faadb3 (plain)
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
RSpec.describe Configurable do

  subject do
    Class.new do
      include Configurable
    end
  end

  let( :something ){ double('something') }

  it 'can be configured' do
    expect{ subject.config.anything }.to raise_error(NoMethodError)

    subject.config.something = something

    expect( subject.config.something ).to eq(something)
    expect( subject.new.send(:config).something ).to eq(something)
    expect( subject.new.send(:config).something ).to eq(something)
  end

  it 'can be configured with a block' do

    subject.config do | c |
      c.something = something 
    end

    expect( subject.config.something ).to eq(something)
    expect( subject.new.send(:config).something ).to eq(something)
    expect( subject.new.send(:config).something ).to eq(something)
  end
end