我正在尝试在rspec中组合一个运行测试:
feature "Happy Path", js:true do
before(:all) do
@user = create(:user)
@object = create(:object, account: @object.account)
sign_in @user
visit root_path
end
describe "test" do
context "test" do
include_examples "it_will_expand_the_menu"
include_examples "it_will_navigate_to_the_object" do
let(:object) {@object.name}
end
end
end
并定义了共享示例:
shared_examples "it_will_expand_the_menu" do
it "expands menu" do
...
...
end
end
shared_examples "it_will_navigate_to_the_object" do
it "fills in the country" do
click_on object
end
end
此外,我已经覆盖了Capybara如下:
module Capybara
class << self
def reset_sessions!
nil
end
def use_default_driver
nil
end
end
class SpecHelper
def reset!
nil
end
end
class Session
def reset!
return nil
end
end
module Selenium
class Driver
def reset!
nil
end
end
module WebDriver
class Driver
def delete_all_cookies
nil
end
end
end
end
module Driver
class Base
def reset!
nil
end
def cleanup!
nil
end
def reset_session!
nil
end
end
end
module RackTest
class Driver
def reset!
nil
end
end
class Browser
def reset_host!
nil
end
def reset_cache!
nil
end
end
end
end
但是,我正在注定将在页面之间导航的操作之间。因此,在导航操作之后,测试将点击应用程序的初始登录屏幕。
发生了什么事?为什么Capybara会重置我的会话?我怎么能阻止它这样做呢?