Sha256: e1132d6b23b52d3d2bb8163cfa9c4522d793d3d45f8c9dc27418314e226f5050

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe ShoppingList::List do

  list_subject = ShoppingList::List.new('list')
  list_subject2 = ShoppingList::List.new('test_list')

  context '#new' do
    it 'has a name' do
      list_subject.name.should == 'list'
    end

  end

  context '#list_to_hash' do
    it 'returns a hash of the item' do
      expected = {:items => $holding_list,
                  :location => File.expand_path('~/Dropbox/ShoppingList/list'),
                  :name => 'list'}
      list_subject.list_to_hash.should == expected

    end
  end

  context '#save' do
    it 'adds the items in $holding_list to specified file' do
      list_subject.save
      saved = YAML.load_file(File.open File.expand_path('~/Dropbox/ShoppingList/list'))
      expected = [{:name => 'notebook, three-ringed', :amount => 1, :store => 'Staples', :category => 'work supplies'},
                  {:name => 'pants', :amount => 2, :store => nil, :category => 'clothes'}]
      saved.collect { |i| i.to_hash }.should == expected

    end
  end

  context '#delete!' do
    it 'removes the specified item (by name) from the specified list' do
      list_subject2.save
      expect(list_subject2.delete!('pants', 'test_list')).to be_true
    end
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppinglist-0.0.5.pre spec/shoppinglist/list_spec.rb