将水豚与 Devise 一起使用?

发布于 2024-12-02 10:05:30 字数 864 浏览 0 评论 0原文

我正在尝试使用 Capybara 为我的应用程序+设备编写登录集成测试。

到目前为止,这是我所得到的:

require 'spec_helper'

describe "the signup process", :type => :request do
  before :each do
    @user_1 = Factory.create(:user, :email => '[email protected]', :password => 'iPassword')
  end

  it "signs me in" do

    visit new_user_session_path

    fill_in 'user[email]', :with => '[email protected]'
    fill_in 'user[password]', :with => 'iPassword'

    click_link_or_button 'Sign In'

  end


end

这一切都过去了。这里的问题是它没有检查用户是否已登录(cookie?)以及 URL 是否正确重定向?

我如何将这些详细信息添加到此测试中?另外,对于无效登录,我如何测试以确保闪光警报设置正确?

谢谢

I'm trying to write a Sign in integration test for my app + devise by using Capybara.

Here is what I have so far:

require 'spec_helper'

describe "the signup process", :type => :request do
  before :each do
    @user_1 = Factory.create(:user, :email => '[email protected]', :password => 'iPassword')
  end

  it "signs me in" do

    visit new_user_session_path

    fill_in 'user[email]', :with => '[email protected]'
    fill_in 'user[password]', :with => 'iPassword'

    click_link_or_button 'Sign In'

  end


end

This is passing. Problem here is that it isn't checking that the user was signed in (cookie?) and that the url redirected correctly?

How can I add those details to this test? Also for an invalid login, how can I test to make sure the flash alert was set correctly?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

于我来说 2024-12-09 10:05:30

在 click_link_or_button“登录”后添加:

current_path.should == 'your path'
page.should have_content("Signed in successfully.")

/support/devise.rb

RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller
end

After click_link_or_button 'Sign In' add:

current_path.should == 'your path'
page.should have_content("Signed in successfully.")

/support/devise.rb

RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文