small medium large xlarge

Generic-user-small
25 Jul 2017, 10:27
John Yeates (8 posts)

When I run the tests on pp211-212, I get the following:

E

Error:
OrdersTest#test_cheque_routing_number:
Capybara::ElementNotFound: Unable to find select box "pay_type"
    test/system/orders_test.rb:15:in `block in <class:OrdersTest>'


bin/rails test test/system/orders_test.rb:4

The screenshot that Capybara saves shows the pay_type select box is visible.

PayTypeSelector/index.jsx has this in it:

          <label htmlFor="pay_type">Pay type</label>
          <select id="pay_type" onChange={this.onPayTypeSelected} name="order[pay_type]">

so I can’t see where this could be going wrong (note I changed the htmlFor in the to match what the id of the is :)

I’ve tried setting Capybara.default_max_wait_time = 10 in test_helper.rb but it just makes me wait longer before it fails.

Does anybody have any ideas why it’s not seeing a control that’s blatantly there?

Generic-user-small
25 Jul 2017, 10:40
John Yeates (8 posts)

Despite the fact that the Capybara docs say you can search by name, id or label of the select box, only using the name seems to work. Replacing the line in the test with select 'Cheque', from: 'order[pay_type]' fixes the issue. But how come searching by id or label don’t work when the docs say they do?

Dmfcb_pragsmall
25 Jul 2017, 14:26
David Copeland (427 posts)

That’s odd. The code is tested when the book is built, so it should work. Capybara often falls victim to odd timing issues.

I’ve added this to our errata and will look into it before the next beta.

Generic-user-small
26 Jul 2017, 09:22
John Yeates (8 posts)

Thanks — I’m also having problems at page 231, where the tests have started failing with

Error:
OrdersTest#test_cheque_routing_number:
ActionView::Template::Error: undefined method `javascript_pack_tag' for #<#<Class:0x007fc4cf5ac120>:0x007fc4cf59d878>
Did you mean?  javascript_path
               javascript_tag
    app/views/orders/new.html.erb:8:in `_app_views_orders_new_html_erb__1793964980887965413_70241634575120'

even though webpack-dev-server is running. Do you have any idea what could be going on there?

Dmfcb_pragsmall
26 Jul 2017, 11:50
David Copeland (427 posts)

That sounds like you don’t have webpacker installed. Webpacker provides that helper. If you do believe it’s installed, can you post your in-progress app somewhere, e.g. github?

Generic-user-small
26 Jul 2017, 13:19
John Yeates (8 posts)

Thanks — the bizarre thing is that it’s running fine in dev, and the webpacker gem isn’t in the development group…

The code’s up on Bitbucket

You must be logged in to comment