Skip to content

Commit

Permalink
Testing exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Maddocks committed Oct 6, 2011
1 parent 3b9fdd0 commit f1015a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 15 additions & 5 deletions test/test_orders.rb
Expand Up @@ -72,36 +72,44 @@ def test_shipping_options
def test_shipping_options_address_fail
order = Ponoko::Order.new

assert_raises Ponoko::PonokoAPIError do
e = assert_raises Ponoko::PonokoAPIError do
order.shipping_options!
end

assert_equal "Order must have a Delivery Address", e.message
end

def test_make_an_order_with_no_params
order = Ponoko::Order.new

assert_raises Ponoko::PonokoAPIError do
e = assert_raises Ponoko::PonokoAPIError do
order.send!
end

assert_equal "Order must have a Shipping Option Code", e.message
end

def test_make_an_order_with_no_products
address = {"first_name" => "John", "last_name" => "Brown", "address_line_1"=>"27 Dixon Street", "address_line_2"=>"Te Aro", "city"=>"Wellington", "state"=>"na", "zip_or_postal_code"=>"6021", "country"=>"New Zealand", "phone_number" => "045678910"}
order = Ponoko::Order.new 'delivery_address' => address, 'shipping_option_code' => 'ups_ground'

assert_raises Ponoko::PonokoAPIError do
e = assert_raises Ponoko::PonokoAPIError do
order.send!
end

assert_equal "Order must have Products", e.message
end

def test_make_an_order_with_no_address
order = Ponoko::Order.new 'shipping_option_code' => 'ups_ground'
product = Ponoko::Product.new
order.add_product product

assert_raises Ponoko::PonokoAPIError do
e = assert_raises Ponoko::PonokoAPIError do
order.send!
end

assert_equal "Order must have a Delivery Address", e.message
end

def test_make_an_order_with_no_shipping_option
Expand All @@ -111,9 +119,11 @@ def test_make_an_order_with_no_shipping_option
product = Ponoko::Product.new
order.add_product product

assert_raises Ponoko::PonokoAPIError do
e = assert_raises Ponoko::PonokoAPIError do
order.send!
end

assert_equal "Order must have a Shipping Option Code", e.message
end

def test_make_an_order
Expand Down
4 changes: 3 additions & 1 deletion test/test_products.rb
Expand Up @@ -48,9 +48,11 @@ def test_make_a_product_missing_design
product = Ponoko::Product.new
assert product

assert_raises Ponoko::PonokoAPIError do
e = assert_raises Ponoko::PonokoAPIError do
product.send!
end

assert_equal "Product must have a design.", e.message
end

def test_make_a_product
Expand Down

0 comments on commit f1015a4

Please sign in to comment.