Rails アプリの機能ファイルをヘッドレスで実行する際に問題があります。ファントムを Webkit として、ポルターガイストを JavaScript ドライバーとして使用します。
私の機能は次のように始まります:
@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"
実行中のメッセージは次のとおりです。
次に、「顧客データ」が表示されます
機能/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)
「顧客データ」というテキストが表示されるべきパーシャルがファントムによってレンダリングされていないようです。ブラウザで同じことを手動で行うと、機能します。他の対応するファイルは次のとおりです: 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 (新規)
def new
respond_to do |format|
format.js {render layout: false}
end
end
顧客/new.html.erb
<h1>New Customer</h1>
<p>Customer data</p>
<%= render 'form' %>
顧客/new.js.erb
$("#current_customer").html("<%= escape_javascript(render partial: 'customers/new' ) %>");