2012-01-17 14 views
2

をテストしながら、私は=====================私は無効なパスワード工夫

Failures: 

    1) CreateFolders GET /projects new folder 
    Failure/Error: page.should have_content('Logged in') 
     expected there to be content "Logged in" in "Invalid email or password.\nSign in\nRemember me\nForgot your password?"                              
    # ./spec/requests/create_folders_spec.rb:17:in `block (3 levels) in <top (required)>' 

を参照してくださいテスト

describe "CreateFolders" do 
    describe "GET /projects" do 
    it "new folder", :js => true do 
     @user = FactoryGirl.create(:user) 
     visit projects_path 
     fill_in('user_Login', :with => @user.email) 
     fill_in('user_password', :with => @user.password) 
     click_button('Sign in') 
     page.should have_content('Logged in') 
    end 
    end 

を実行しよう==========================================開発デシベル、テストデシベル:======= は、3つのデータ・ベース・セットがあり、レールに

FactoryGirl.define do 
    factory :user do 
    email Faker::Internet.free_email 
    password 'password' 
    Name Faker::Name.first_name 
    Surname Faker::Name.last_name 
    Phone Faker::PhoneNumber.phone_number 
    Login Faker::Name.first_name 
    company {|user| user.association(:company) } 
    end 
end 
+0

のためのキュウリを使用する必要があります。私は、工場の後User.allを呼び出すとuser' – nmott

答えて

-2

あなたは `のためのあなたのファクトリの定義を投稿することができますが、この目標

@javascript 
    Scenario Outline: Show or not dasboard 
    Given the following user records 
     | email    | password | login | 
     | [email protected]  | password | admin | 

    When I am on the home page 
    And I fill in "user_email" with "<login>" 
    And I fill in "user_password" with "<password>" 
    And I press "Sign in" 
    Then I should <flash> 

    Examples: 
     | login   | password | flash       | 
     | [email protected] | password | see "Signed in successfully." | 
+2

キュウリとは何が関係していますか? rspecでこれをうまくやることができます。 – Senjai

2

を更新しましたproduction db、 新しいデータベースを開発用データベースに作成している可能性があります。開発用データベースで作成する必要があります。これは、テスト中にtest dbが使用されるためです。

新しいユーザーがテストデータベースに作成されていることを確認します。

あなただけの形式で符号をテストすることなく、認証が必要なページを訪問する必要がある場合は、ここでカピバラでそれを行うための簡単な方法は次のとおりです。https://github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara

私はこれが役立つことを願っています!

+0

は、私は、DBからレコードを取得します。リンクありがとうございました。しかし、 'Mysql2 :: Error:ロック待ちタイムアウトを超えました。トランザクションを再起動してみてください:UPDATE 'users' SET' last_sign_in_at' = '2012-01-17 13:52:11'、 'current_sign_in_at' = '2012-01-17 13:52:11'、' last_sign_in_ip' = '127.0。 0.1.0、 'current_sign_in_ip' = '127.0.0.1'、' sign_in_count' = 1、 'u​​pdated_at' = '2012-01-17 13:52:11' where users'.id' = 1''ユーザーがFactoryGirl.create(:user) login_as(user、:scope =>:user) ' –

0

私はあなたがテストにカピバラを使用していると仮定します。 fill_inをフィールド名ではなくラベル名に変更してみてください。たとえば:

fill_in "Login", :with => @user.email 
fill_in "Password", :with => @user.password 

これらのアプリのために異なる場合があります - ちょうど(あなたがprojects_pathに行くとき、あなたの画面に表示何でも)あなたのフィールドのラベルが実際に呼ばれているものは何でも代用します。また、ブラケットは必要ありません。