使用控制器

时间:2016-05-16 10:09:30

标签: ruby-on-rails poltergeist respond-to

我无法执行我的rails应用程序功能文件时遇到问题。我使用幻影作为webkit和poltergeist作为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)

似乎应该显示文本“客户数据”的部分不会被幻像呈现。当我在浏览器中手动执行相同操作时,它可以正常工作。 以下是其他相应的文件: 客户/ 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' ) %>");

0 个答案:

没有答案