mercredi 10 octobre 2018

Rails: Testing Google Distance Calculation with Minitest + Capybara

I'm trying to write a system test for a shipping cost calculation (uses Google Distance Matrix API). My current tests don't work. I don't know how I would test this.

Demo image of the UI: Calculate shipping costs by distance

After you click the button the shipping costs will be updated via JavaScript in <td id="shipping_costs">39.28</td>

My current test (which doesn't work):

test "should calculate the correct shipping costs" do
  fill_in('postcode_delivery', with: '2100')
  fill_in('postcode_pickup', with: '1010')
  click_button('Calculate shipping')
  assert page.has_selector?('#shipping_costs', text: '39.28')
end

Aucun commentaire:

Enregistrer un commentaire