Sha256: b77bb94b709d3e756ef888d046eca67ce09552a27f1a4e6d1491ef253323e5a9

Contents?: true

Size: 475 Bytes

Versions: 2

Compression:

Stored size: 475 Bytes

Contents

class Basket

  attr_reader :items
  def initialize shopping_list
    @items = parse(shopping_list)
  end

  def parse shopping_list
    shopping_list.lines[1..-1].collect { |item|
      item.chomp.to_sym
    }
  end
end

describe Basket do

  describe '#initialize' do
    it 'takes a shopping list' do

      shopping_list=<<LIST
list
apple
carrot
LIST

      basket = described_class.new(shopping_list)
      expect(basket.items).to eq([:apple, :carrot])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitehub-0.4.2 spec/basket_spec.rb
sitehub-0.4.1 spec/basket_spec.rb