【发布时间】:2016-11-01 02:03:36
【问题描述】:
我的应用程序有一些与 capybara 相关的功能规格。现在我有一个我正在尝试测试的模态。模态使用Javascript。但是当我运行我的规格时。我得到这个非常奇怪的错误。在这里。
错误
Failure/Error: page.driver.browser.set_cookie("account_id=#{account_id}")
TypeError:
no implicit conversion of Symbol into Integer
# /Users/intern/.rvm/gems/ruby-2.3.1/gems/poltergeist-1.11.0/lib/capybara/poltergeist/browser.rb:313:in `[]'
# /Users/intern/.rvm/gems/ruby-2.3.1/gems/poltergeist-1.11.0/lib/capybara/poltergeist/browser.rb:313:in `set_cookie'
# ./spec/support/_request_macros.rb:20:in `set_current_account'
# ./spec/features/manage_accounts_spec.rb:101:in `block (3 levels) in <top (required)>'
# /Users/intern/.rvm/gems/ruby-2.3.1/gems/rspec-wait-0.0.9/lib/rspec/wait.rb:46:in `block (2 levels) in <top (required)>'
这是正在破坏的文件
def set_current_account(account_id)
page.driver.browser.set_cookie("account_id=#{account_id}")
end
这是我的测试
测试
it "redirects to the previous account if a user accesses an account they are not on" do
third_account = create(:account, name: "Third Account", users: [user])
set_current_account(third_account.id)
visit root_path
expect(current_account).to eq(third_account.id)
user.accounts.delete(account1)
click_on "Test Account"
expect(current_path).to eq(snitches_path)
expect(page).to have_content("You don't have access to that account!")
expect(current_account).to eq(third_account.id)
expect(page).to have_content("Third Account")
end
我在上面的上下文中有 js:true。
我真的不知道出了什么问题。希望你们中的一些人更熟悉水豚和 javascript 测试。让我知道你的想法
【问题讨论】:
标签: javascript ruby-on-rails ruby capybara