开发者

Using Capybara along with Devise?

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 => 'bob@golden.com', :password => 'iPassword')
  end

  it "signs me in" do

    visit new_user_session_path

    fill_in 'user[email]', :with => 'bob@golden.com'
    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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜