1

I have a problem executing my rails app feature files headless. I use phantom as webkit and poltergeist as javascript driver.

My feature starts like this:

@javascript
  Scenario: Create a customer
    Given I am on the "/customers" page
    When I click on element having id "new_customer"
    Then I should see "Customer data"

The message I get running it is:

Then I should see "Customer data"

features/step_definitions/feature_steps.rb:16

  expected to find text "Customer data" in "LOGOTIMAX :: adminTicketsProjectsCustomersUsermanagementProfileSettingsLog out Listing Customers Show entriesSearch: Id Name 1 Heine 2 IKEA 3 Coca Cola 4 Lufthansa AG 5 Daimler AGShowing 1 to 5 of 5 entriesPrevious1Next New Customer TIMAX - Ruby on Rails application by UniCorp BLOGJIRA" (RSpec::Expectations::ExpectationNotMetError)

It seems as if the partial where the text "Customer data" should be displayed does not get rendered by phantom. When I do the same by hand in my browser, it works. Here are the other corresponding files: customers/index.html.erb:

<h1>Listing Customers</h1>
<div class="grid">
  <div class="row cells3 ">
    <div class="cell" id="customers_list">
      <%= render partial: 'customers/list', locals: { customers: @customers } %>
    </div>
    <div class="cell colspan2 " id="current_customer"></div>
  </div>
</div>

<br>

<%= link_to 'New Customer', new_customer_path, class: "button", id: "new_customer", remote: true %>

customers_controller.rb (new)

  def new
    respond_to do |format|
      format.js {render layout: false}
    end
  end

customers/new.html.erb

<h1>New Customer</h1>
<p>Customer data</p>
<%= render 'form' %>

customers/new.js.erb

$("#current_customer").html("<%= escape_javascript(render partial: 'customers/new' ) %>");
mahu
  • 297
  • 1
  • 3
  • 14
  • Can you look into the `test.log` and see if the `new` action gets called in the cucumber test or not? – Matouš Borák May 16 '16 at 12:03
  • When I have the @javascript tag before the scenario, nothing is written to the test.log. If I remove this tag, I get an Error on the Console: ActionController::UnknownFormat (ActionController::UnknownFormat) and in the test.log: Processing by CustomersController#new as HTML [1m[35mUser Load (0.6ms)[0m SELECT `users`.* FROM `users` WHERE `users`.`id` = ? LIMIT 1 [["id", 1]] Completed 406 Not Acceptable in 17ms (ActiveRecord: 0.6ms) - so without the javascript tag, the new action gets called, but phantom cannot render it – mahu May 16 '16 at 12:47
  • Do you perhaps have a separate `cucumber.log`? Is there anything interesting there? – Matouš Borák May 16 '16 at 13:11
  • I executed the files with --backtrace, but there is no other interesting information included... does poltergeist support, what I have posted above? – mahu May 17 '16 at 18:51

0 Answers0