Sha256: f372f4818a6532f792a724b7445add0299f208d18a767937b52bcb3a4a094b74

Contents?: true

Size: 818 Bytes

Versions: 4

Compression:

Stored size: 818 Bytes

Contents

require_relative '../../../spec_helper'

module LazyDoc
  describe Commands::FinallyCommand do
    let(:value) { 'hello world' }

    context 'acts like a Command' do
      subject(:command) { Commands::FinallyCommand.new(nil) }

      it_behaves_like 'the Command interface'
    end

    it 'transforms the supplied value with the supplied transformation' do
      transformation = lambda { |value| value.upcase }
      finally = Commands::FinallyCommand.new(transformation)

      final_value = finally.execute(value)

      expect(final_value).to eq('HELLO WORLD')
    end

    it 'uses a no op transformation when the supplied transformation is blank' do
      finally = Commands::FinallyCommand.new(nil)

      final_value = finally.execute(value)

      expect(final_value).to eq('hello world')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lazy_doc-0.4.0 spec/lib/lazy_doc/commands/finally_command_spec.rb
lazy_doc-0.3.0 spec/lib/lazy_doc/commands/finally_command_spec.rb
lazy_doc-0.2.1 spec/lib/lazy_doc/commands/finally_command_spec.rb
lazy_doc-0.1.0 spec/lib/lazy_doc/commands/finally_command_spec.rb