Module: Directive::SpecHelper::DSL

Defined in:
lib/directive/spec_helper/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



27
28
29
30
# File 'lib/directive/spec_helper/dsl.rb', line 27

def self.included(base)
  base.extend DSL
  super
end

Instance Method Details

#nested_config_option(config_name, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/directive/spec_helper/dsl.rb', line 8

def nested_config_option(config_name, &block)
  in_nested_config_stack(config_name) do |nested_stack|
    describe(config_name.to_s, caller: caller) do
      subject { nested_config }

      let(:parent_config) { parent_config_for_nested(nested_stack) }
      let(:nested_config) { parent_config.public_send(nested_stack.last) }

      it "defines nested config object #{config_name}" do
        expect(parent_config).to respond_to config_name
        expect(parent_config._nested_options).to include config_name.to_sym
        expect(parent_config.public_send(config_name)).to be_a Directive::ConfigObject
      end

      instance_eval(&block)
    end
  end
end