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' ) %>");