spec/unit/yaks/runner_spec.rb in yaks-0.7.6 vs spec/unit/yaks/runner_spec.rb in yaks-0.7.7

- old
+ new

@@ -118,12 +118,32 @@ it 'should create a formatter based on class and options' do expect(formatter).to be_a Yaks::Format::JsonAPI expect(formatter.send(:options)).to eql(format_option: [:foo]) end + + it 'should memoize' do + expect(runner.formatter).to be runner.formatter + end end + describe '#env' do + describe 'when env is set in the options' do + let(:options) { { env: 123 } } + + it 'returns the env passed in' do + expect(runner.env).to be 123 + end + end + + describe 'when no env is given' do + it 'falls back to an empty hash' do + expect(runner.env).to eql({}) + end + end + end + describe '#insert_hooks' do let(:options) { { mapper: Yaks::Mapper } } let(:config) { Yaks::Config.new(&hooks) } describe 'before' do @@ -271,10 +291,26 @@ expect(runner.primitivizer.call(:foo)).to eql "foo" end end end - it 'should memoize' do - expect(runner.formatter).to be runner.formatter + describe '#hooks' do + before do + Yaks::Config::DSL.new(config) do + after(:map, :this_happens_after_map) + end + end + + it 'should contain the hooks from the config' do + expect(runner.hooks).to eql [[:after, :map, :this_happens_after_map, nil]] + end + + context 'with extra blocks in the options' do + let(:options) { { hooks: [[:foo]] } } + + it 'should combine the hooks' do + expect(runner.hooks).to eql [[:after, :map, :this_happens_after_map, nil], [:foo]] + end + end end end