From acbf1ed680245710d527f4a972ce9d3fb5aa99f3 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 19 Feb 2014 13:12:52 +1100 Subject: [PATCH] Refactor fragile spec to use has_field? and has_select? in an attempt to make it more reliable in CI --- spec/features/admin/order_cycles_spec.rb | 32 +++++++++--------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/spec/features/admin/order_cycles_spec.rb b/spec/features/admin/order_cycles_spec.rb index 8f2c1b2a34..5cadd11a29 100644 --- a/spec/features/admin/order_cycles_spec.rb +++ b/spec/features/admin/order_cycles_spec.rb @@ -189,24 +189,20 @@ feature %q{ end # And the suppliers should have fees - page.find('#order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_id option[selected=selected]'). - text.should == oc.suppliers.first.name - page.find('#order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_fee_id option[selected=selected]'). - text.should == oc.suppliers.first.enterprise_fees.first.name + page.should have_select 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_id', selected: oc.suppliers.first.name + page.should have_select 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_fee_id', selected: oc.suppliers.first.enterprise_fees.first.name - page.find('#order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_id option[selected=selected]'). - text.should == oc.suppliers.last.name - page.find('#order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_fee_id option[selected=selected]'). - text.should == oc.suppliers.last.enterprise_fees.first.name + page.should have_select 'order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_id', selected: oc.suppliers.last.name + page.should have_select 'order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_fee_id', selected: oc.suppliers.last.enterprise_fees.first.name # And I should see the distributors page.should have_selector 'td.distributor_name', :text => oc.distributors.first.name page.should have_selector 'td.distributor_name', :text => oc.distributors.last.name - page.find('#order_cycle_outgoing_exchange_0_pickup_time').value.should == 'time 0' - page.find('#order_cycle_outgoing_exchange_0_pickup_instructions').value.should == 'instructions 0' - page.find('#order_cycle_outgoing_exchange_1_pickup_time').value.should == 'time 1' - page.find('#order_cycle_outgoing_exchange_1_pickup_instructions').value.should == 'instructions 1' + page.should have_field 'order_cycle_outgoing_exchange_0_pickup_time', with: 'time 0' + page.should have_field 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'instructions 0' + page.should have_field 'order_cycle_outgoing_exchange_1_pickup_time', with: 'time 1' + page.should have_field 'order_cycle_outgoing_exchange_1_pickup_instructions', with: 'instructions 1' # And the distributors should have products page.all('table.exchanges tbody tr.distributor').each do |row| @@ -219,15 +215,11 @@ feature %q{ end # And the distributors should have fees - page.find('#order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_id option[selected=selected]'). - text.should == oc.distributors.first.name - page.find('#order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_fee_id option[selected=selected]'). - text.should == oc.distributors.first.enterprise_fees.first.name + page.should have_select 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_id', selected: oc.distributors.first.name + page.should have_select 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_fee_id', selected: oc.distributors.first.enterprise_fees.first.name - page.find('#order_cycle_outgoing_exchange_1_enterprise_fees_0_enterprise_id option[selected=selected]'). - text.should == oc.distributors.last.name - page.find('#order_cycle_outgoing_exchange_1_enterprise_fees_0_enterprise_fee_id option[selected=selected]'). - text.should == oc.distributors.last.enterprise_fees.first.name + page.should have_select 'order_cycle_outgoing_exchange_1_enterprise_fees_0_enterprise_id', selected: oc.distributors.last.name + page.should have_select 'order_cycle_outgoing_exchange_1_enterprise_fees_0_enterprise_fee_id', selected: oc.distributors.last.enterprise_fees.first.name end