From c1f9d9789da90059f468ede0aed99fb7d3de0bb7 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Mon, 19 Aug 2013 12:29:26 +1000 Subject: [PATCH] Extract table test to private method --- spec/features/consumer/checkout_spec.rb | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/spec/features/consumer/checkout_spec.rb b/spec/features/consumer/checkout_spec.rb index f0a8ec903c..9cd7ee1925 100644 --- a/spec/features/consumer/checkout_spec.rb +++ b/spec/features/consumer/checkout_spec.rb @@ -81,10 +81,7 @@ feature %q{ click_button 'Add To Cart' # Then I should see a breakdown of my delivery fees: - table = page.find 'tbody#cart_adjustments' - rows = table.all 'tr' - - rows.map { |row| row.all('td').map { |cell| cell.text.strip } }.should == + checkout_fees_table.should == [['Product distribution by Edible garden for Fuji apples', '$1.00', ''], ['Product distribution by Edible garden for Garlic', '$2.00', '']] @@ -109,10 +106,7 @@ feature %q{ click_button 'Add To Cart' # Then I should see a breakdown of my delivery fees: - table = page.find 'tbody#cart_adjustments' - rows = table.all 'tr' - - rows.map { |row| row.all('td').map { |cell| cell.text.strip } }.should == + checkout_fees_table.should == [["Bananas - packing fee by supplier Supplier 1", "$3.00", ""], ["Bananas - transport fee by supplier Supplier 1", "$4.00", ""], ["Bananas - packing fee by distributor Distributor 1", "$7.00", ""], @@ -171,10 +165,7 @@ feature %q{ page.find("a#delete_line_item_#{line_item.id}").click # Then I should see fees for only the garlic - table = page.find 'tbody#cart_adjustments' - rows = table.all 'tr' - - rows.map { |row| row.all('td').map { |cell| cell.text.strip } }.should == + checkout_fees_table.should == [['Product distribution by Edible garden for Garlic', '$2.00', '']] page.should have_selector 'span.distribution-total', :text => '$2.00' @@ -366,4 +357,10 @@ feature %q{ ex3.variants << @product_4.master ex4.variants << @product_4.master end + + def checkout_fees_table + table = page.find 'tbody#cart_adjustments' + rows = table.all 'tr' + rows.map { |row| row.all('td').map { |cell| cell.text.strip } } + end end