This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
Finding the Cost to Ship Packages Via UPS or FedEx | ||
---|---|---|
Code | Expected | Actual |
require 'rubygems' require 'shipping' ship = Shipping::Base.new( :fedex_url => 'https://gatewaybeta.fedex.com/GatewayDC', :fedex_account => '123456789', :fedex_meter => '387878', :ups_account => '7B4F74E3075AEEFF', :ups_user => 'username', :ups_password => 'password', :sender_zip => 10001 # It's shipped from Manhattan. ) ship.weight = 2 # It weighs two pounds. ship.city = 'Portland' ship.state = 'OR' ship.zip = 97202 ship.ups.price |
8.77 | 0.0 |
ship.fedex.price |
5.49 | 5.49 |
ship.ups.valid_address? |
true | false |
fedex_url: https://gatewaybeta.fedex.com/GatewayDC fedex_account: 1234556 fedex_meter: 387878 ups_account: 7B4F74E3075AEEFF ups_user: username ups_password: password ship = Shipping::FedEx.new(:prefs => "#{RAILS_ROOT}/config/shipping.yml") ship.sender_zip = 10001 ship.zip = 97202 ship.state = 'OR' ship.weight = 2 ship.price > ship.discount_price |
true |
Error! (Exception?) Here's stdout: SyntaxError: compile error (irb):19: parse error, unexpected ':', expecting $ fedex_url: https://gatewaybeta.fedex.com/GatewayDC ^ from (irb):19 SyntaxError: compile error (irb):20: parse error, unexpected ':', expecting $ fedex_account: 1234556 ^ from (irb):20 SyntaxError: compile error (irb):21: parse error, unexpected ':', expecting $ fedex_meter: 387878 ^ from (irb):21 SyntaxError: compile error (irb):22: parse error, unexpected ':', expecting $ ups_account: 7B4F74E3075AEEFF ^ from (irb):22 SyntaxError: compile error (irb):23: parse error, unexpected ':', expecting $ ups_user: username ^ from (irb):23 SyntaxError: compile error (irb):24: parse error, unexpected ':', expecting $ ups_password: password ^ from (irb):24 NameError: uninitialized constant RAILS_ROOT from (irb):25 NoMethodError: undefined method `price' for #<Shipping::Base:0xb796be9c> from (irb):30 |