Sha256: dccef1499d472b88cecc4fd73bfadcfe41418cd5203583769f658450802184b2
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
require 'spec_helper' describe SimpleService::Command do class ValidCommand < SimpleService::Command expects :foo, :bar returns :bar, :baz def execute context.merge!( bar: 'modified', baz: 'blah' ) end end class NoExecuteDefinedCommand < SimpleService::Command end describe '#execute' do context 'when #returns is not empty' do it 'returns the correct keys from the context' do expect( ValidCommand.new(foo: 'blah', bar: 'meh').execute ).to eql(bar: 'modified', baz: 'blah') end end context 'raises error' do it 'when command does not define an execute method' do expect { NoExecuteDefinedCommand.new.execute }.to raise_error( SimpleService::ExecuteNotDefinedError, 'NoExecuteDefinedCommand - does not define an execute method' ) end end end describe 'context' do it 'defines getters for each expected key' do expect( ValidCommand.new(foo: 'blah', bar: 'meh') ).to respond_to :foo end it 'defines setters for each expected key' do command = ValidCommand.new(foo: 'blah', bar: 'meh') command.foo = 'changed' command.bar = 'changed' expect(command.context).to eql({ foo: 'changed', bar: 'changed' }) end it 'getter updates @context' do command = ValidCommand.new(foo: 'blah', bar: 'meh') command.foo = 'changed' expect(command.context).to eql({ foo: 'changed', bar: 'meh'}) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_service-1.0.2 | spec/lib/command_spec.rb |
simple_service-1.0.1 | spec/lib/command_spec.rb |