bernat / best_in_place

A RESTful unobtrusive jQuery Inplace-Editor and a helper as a Rails Gem
http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/
1.2k stars 570 forks source link

Test_Helpers are deprecated #600

Open limsammy opened 6 years ago

limsammy commented 6 years ago

So as other users have mentioned the bip_select, bip_area, etc. methods from the TestHelpers module are broken. I figured out it's a CapybaraDriver error. I rebuilt the test_helpers module included in best_in_place manually and get the following error (Stack trace included):

1) Admin can edit task inline admin visits task manager (tasks#index) admin can edit fields in place
     Failure/Error:
           execute_script <<-JS
             $("##{id} input[name='#{attr}']").val('#{escape_javascript new_value.to_s}');
             $("##{id} form").submit();
           JS

     Capybara::NotSupportedByDriverError:
       Capybara::Driver::Base#execute_script
     # /Users/sam/.rvm/gems/ruby-2.4.1/gems/capybara-2.18.0/lib/capybara/driver/base.rb:38:in `execute_script'
     # /Users/sam/.rvm/gems/ruby-2.4.1/gems/capybara-2.18.0/lib/capybara/session.rb:616:in `execute_script'
     # /Users/sam/.rvm/gems/ruby-2.4.1/gems/capybara-2.18.0/lib/capybara/dsl.rb:50:in `block (2 levels) in <module:DSL>'
     # ./app/helpers/js_spec_helper.rb:8:in `bip_text'
     # ./spec/features/admin/admin_can_edit_a_task_inline_spec.rb:27:in `block (3 levels) in <top (required)>

I then attempted a solution I found on SO and added :js => true to my it block in RSpec: it "user can edit fields in place", :js => true do....

And that triggers Selenium, opens Firefox, navigates to the right page, but isn't able to edit any fields.

If anyone has fixed this, please let me know! I believe it to be an issue with the current JS being executed by the test_helper. You can find the source for that here: https://github.com/bernat/best_in_place/blob/e262821006d9f295e9992340114ff4f3895add51/lib/best_in_place/test_helpers.rb