无法让 rails 5.1.5 通过水豚提交具体化 css 下拉值

Having trouble getting rails 5.1.5 to submit materialize css dropdown value via capybara

当 "selected" 时,我很难实现 css 下拉菜单以提交其值。我使用引号是因为我不确定我是否真的 select 正确地输入了值。

我正在与:

rails 5.1.5
capybara 2.18.0
rspec-rails 3.6.0

我目前的功能规范如下:

require 'rails_helper'

feature 'organization management', js: true do
  let(:organization) {create :organization}

  scenario 'a user can view an organization they created' do
    set_session organization.user

    visit root_path

    within '.nav-wrapper' do
      click_link 'Organizations'
      click_link 'New Organization'
    end

    expect(current_path).to eq new_organization_path

    fill_in 'organization[name]', with: Faker::Company.name
    fill_in 'organization[address1]', with: Faker::Address.street_address
    fill_in 'organization[city]', with: Faker::Address.city

    # Chose to use JS because I couldn't get select helper to work
    evaluate_script("$('input.select-dropdown').val('Maryland');")

    fill_in 'organization[zipcode]', with: Faker::Address.zip
    fill_in_trix_editor 'trix-editor', Faker::Lorem.paragraph

    click_button 'Create Organization'

    expect(current_path).to eq organization_path(Organization.last)

  end
end

单击创建按钮后,我看到未提交状态值:

Started POST "/organizations" for ::1 at 2018-05-02 13:49:13 -0400
Processing by OrganizationsController#create as HTML
  Parameters: {"utf8"=>"✓", "organization"=>{"name"=>"Spinka, Kautzer and Strosin", "address1"=>"4611 Mueller Ports", "address2"=>"", "city"=>"Madelynnland", "state"=>"", "zipcode"=>"19244-0263", "description"=>"<div>Earum saepe esse commodi. Autem nisi quis quia sed. Molestiae accusantium quaerat. Rerum quod sapiente dolorem laborum enim et autem.</div>"}, "commit"=>"Create Organization"}

我自己在浏览器中 运行 通过这个(在测试之外)并且一切正常。

我不知道为什么 select 助手根本不为我工作。

我从手动测试和 rspec 测试中注意到的唯一区别是在测试过程中 select 输入值时标签没有移动。 select编辑的值与保管箱的标签重叠。

当我手动 select 编辑一个值时,标签像往常一样移动。

任何关于我如何在功能测试中工作的想法或想法都将不胜感激。

谢谢

select 不起作用,因为用户没有与实际的 HTML