Cleanup new tests

Stephen Paul Weber created

Change summary

test/test_sim_order.rb | 49 +++++++++++++------------------------------
1 file changed, 15 insertions(+), 34 deletions(-)

Detailed changes

test/test_sim_order.rb 🔗

@@ -25,62 +25,49 @@ class SIMOrderTest < Minitest::Test
 	end
 
 	def test_for_enough_balance
-		customer = Minitest::Mock.new
-		customer.expect(:balance, 60)
-
-		result = execute_command do
-			SIMOrder.for(customer, price: @price, plan: @plan_name)
-		end
-		assert_kind_of SIMOrder, result
-		assert_mock customer
+		assert_kind_of(
+			SIMOrder,
+			SIMOrder.for(customer(balance: 60), price: @price, plan: @plan_name)
+		)
 	end
-	em :test_for_enough_balance
 
 	def test_for_insufficient_balance_with_top_up
-		customer = Minitest::Mock.new
-		customer.expect(:balance, 40)
+		customer = customer(balance: 40)
 
 		LowBalance::AutoTopUp.stub(
 			:for,
 			OpenStruct.new(can_top_up?: true),
 			[customer, @price]
 		) do
-			result = execute_command do
+			assert_kind_of(
+				SIMOrder::WithTopUp,
 				SIMOrder.for(customer, price: @price, plan: @plan_name)
-			end
-			assert_kind_of SIMOrder::WithTopUp, result
-			assert_mock customer
+			)
 		end
 	end
-	em :test_for_insufficient_balance_with_top_up
 
 	def test_for_insufficient_balance_please_top_up
-		customer = Minitest::Mock.new
-		customer.expect(:balance, 40)
+		customer = customer(balance: 40)
 
 		LowBalance::AutoTopUp.stub(
 			:for,
 			OpenStruct.new(can_top_up?: false),
 			[customer, @price]
 		) do
-			result = execute_command do
+			assert_kind_of(
+				SIMOrder::PleaseTopUp,
 				SIMOrder.for(customer, price: @price, plan: @plan_name)
-			end
-			assert_kind_of SIMOrder::PleaseTopUp, result
-			assert_mock customer
+			)
 		end
 	end
-	em :test_for_insufficient_balance_please_top_up
 
 	def test_complete_nil_nick
-		customer = Minitest::Mock.new
-		customer.expect(:balance, 100)
+		customer = Minitest::Mock.new(customer("123", balance: 100))
 		customer.expect(
 			:stanza_from,
 			EMPromise.resolve(nil),
 			[Blather::Stanza::Message]
 		)
-		customer.expect(:customer_id, "123")
 
 		SIMOrder::DB.expect(
 			:transaction,
@@ -140,7 +127,7 @@ class SIMOrderTest < Minitest::Test
 		assert_equal(
 			:test_result,
 			execute_command(blather: blather) { sim_order.complete(order_form) }
-  )
+		)
 
 		assert_mock Transaction::DB
 		assert_mock SIMOrder::DB
@@ -151,18 +138,12 @@ class SIMOrderTest < Minitest::Test
 	em :test_complete_nil_nick
 
 	def test_complete_nick_present
-		customer = Minitest::Mock.new
-		customer.expect(:balance, 100)
+		customer = Minitest::Mock.new(customer("123", balance: 100))
 		customer.expect(
 			:stanza_from,
 			EMPromise.resolve(nil),
 			[Blather::Stanza::Message]
 		)
-		customer.expect(
-			:customer_id,
-			"123",
-			[]
-		)
 		Transaction::DB.expect(
 			:exec,
 			nil,