Sha256: 2880d5bb13b6d5a0e1b05cfccafc829301d0ab070f01a74444f9f47352dd9294

Contents?: true

Size: 747 Bytes

Versions: 5

Compression:

Stored size: 747 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe "VendingMachine class with fixtures loaded" do
  fixtures :vending_machines, :products
  
  before(:each) do
    @vm = VendingMachine.new(:location => "Cafeteria", :cash => 1000)
    @vm.save!
  end

  it "Create with location and cash" do
    loaded = VendingMachine.find(@vm.id)
    loaded.location.should eql("Cafeteria")
    loaded.cash.should equal 1000
  end
  
  it "Add rack" do
    @vm.add_product(20, "Water", 150)
    @vm.save!
    
    loaded = VendingMachine.find(@vm.id)
    loaded.products.length.should equal 1
    loaded.products[0].name.should eql("Water")
    loaded.products[0].price.should eql(150)
    loaded.products[0].inventory.should equal 20
  end

  
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
statemachine-2.3.0 rails_plugin/spec/models/vending_machine_spec.rb
statemachine-2.2.0 rails_plugin/spec/models/vending_machine_spec.rb
statemachine-2.1.0 rails_plugin/spec/models/vending_machine_spec.rb
statemachine-2.0.1 rails_plugin/spec/models/vending_machine_spec.rb
statemachine-2.0.0 rails_plugin/spec/models/vending_machine_spec.rb