Error loading jQuery object in Rails4 / PhantomJS / Rspec / Capybara

I keep getting an error with PhantomJS finding jQuery. Seems like on circle it can’t load the javascript. Perhaps its looking in the wrong location? I ma using a CDN (allows both HTTP and HTTPS). This is working locally.

I don’t know how to see the locations of assets files PhantomJS is trying to load on circle. Here is the error message:

   One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).

   ReferenceError: Can't find variable: jQuery
   ReferenceError: Can't find variable: jQuery
       at in global code
 # /home/ubuntu/.rvm/gems/ruby-2.2.2/gems/poltergeist-1.8.1/lib/capybara/poltergeist/browser.rb:347:in `command'
 # /home/ubuntu/.rvm/gems/ruby-2.2.2/gems/poltergeist-1.8.1/lib/capybara/poltergeist/browser.rb:34:in `visit'
 # /home/ubuntu/.rvm/gems/ruby-2.2.2/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:95:in `visit'
 # /home/ubuntu/.rvm/gems/ruby-2.2.2/gems/capybara-2.5.0/lib/capybara/session.rb:232:in `visit'
 # /home/ubuntu/.rvm/gems/ruby-2.2.2/gems/capybara-2.5.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
 # ./spec/features/dashboard_controller_feature_spec.rb:21:in `block (3 levels) in <top (required)>'


    - foreman run rake db:create db:schema:load
    - sudo apt-get update; sudo apt-get install libicu52
    - curl --output /home/ubuntu/bin/phantomjs-2.0.1-linux-x86_64-dynamic
    - chmod a+x /home/ubuntu/bin/phantomjs-2.0.1-linux-x86_64-dynamic
    - sudo ln -s --force /home/ubuntu/bin/phantomjs-2.0.1-linux-x86_64-dynamic /usr/local/bin/phantomjs 

In spec_helper.rb

require ‘capybara/poltergeist’

Capybara.javascript_driver = :poltergeist

also here is an example of one of the tests:

context "no orders are associated to campaign" do
	  it "views empty state orders page ", js: true  do

	    visit "/dashboard/#{}/orders"

	    expect(page).to have_css "", text: "ORDERS", wait: 5

	    expect(page).to have_css "td.dataTables_empty", text: "No data available in table", wait: 10



Looks like this may be an issue when using CDN and jQuery


More details here as well: (where I found the link to the issue)

Thanks for the reply. I had seen the stackoverflow article previously. Is there an example of how I pass those params to phantomJS? I searched on how to do that with circle.yml but couldn’t find anything that was phantomJS specific.

Is there a way to pass ‘–ssl-protocol=any’ to PhantomJS through circle.yml ir antoher way?

Thanks, Tom

Looks like you can pass options to PhantomJS using phantomjs_options

See the customization section.


Thanks for the help. It is using http for the assets