Sha256: 3205e246e461d7165d749c90dbd9d7005cbdbee4fbf4e468c573bc40aaafff6c

Contents?: true

Size: 823 Bytes

Versions: 4

Compression:

Stored size: 823 Bytes

Contents

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

module LazyDoc
  describe Commands::ExtractCommand do
    context 'acts like a Command' do
      subject(:command) { Commands::ExtractCommand.new('attribute to extract') }

      it_behaves_like 'the Command interface'
    end

    it 'returns an array of the extracted attribute' do
      extract = Commands::ExtractCommand.new(:name)

      names = [{'name' => 'Brian'}, {'name' => 'Chris'}, {'name' => 'Mary'}]
      extracted_names = extract.execute(names)

      expect(extracted_names).to eq(['Brian', 'Chris', 'Mary'])
    end

    it 'returns the original value when there is no specified attribute to extract' do
      extract = Commands::ExtractCommand.new(nil)

      extracted_value = extract.execute('foo')

      expect(extracted_value).to eq('foo')
    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/extract_command_spec.rb
lazy_doc-0.3.0 spec/lib/lazy_doc/commands/extract_command_spec.rb
lazy_doc-0.2.1 spec/lib/lazy_doc/commands/extract_command_spec.rb
lazy_doc-0.1.0 spec/lib/lazy_doc/commands/extract_command_spec.rb