0

この友情機能の仕様を、Capybara、Rspec、FactoryGirls on Rails を使用して渡そうとしています。

なんらかの理由で、私はいつもこのエラーで失敗しています。テストを実行した後、セッションが破棄されていないようです。

  1) Friendships user requests friendship signed in POST /:username/friendships requests friendship
     Failure/Error: page.should have_content 'Successfully requested friendship.'
       expected there to be text "Successfully requested friendship." in "× You are already signed in. meeter Messages Notifications Settings Settings Logout Explore Dates nearby Suggestions You Messages Notifications Friends Publish Help No ideas found with your criteria."
     # ./spec/features/friendships_spec.rb:32:in `block (5 levels) in <top (required)>'

完全な仕様

require 'spec_helper'

include Warden::Test::Helpers
Warden.test_mode!

describe "Friendships" do 

  before(:each) do 
    @user = FactoryGirl.create(:user, :male)
    @friend = FactoryGirl.create(:user, :female)
  end

  describe "GET /:username/friendships" do 
    pending "display friendships"
  end

  context "user requests friendship" do

    context "signed in" do

      after(:each) do 
        Warden.test_reset! 
      end

      describe "POST /:username/friendships" do 
        it "requests friendship" do 
          login_as(@user, scope: :user)
          visit user_path(@friend)
          click_button 'Request Friendship'
          page.should have_content 'Successfully requested friendship.'
          logout(@user)
        end
        pending "friend receives confirmation notification"
      end

      describe "POST /:username/friendships/cancels" do
        pending "cancels a friendship request sent"
      end

    end

    context "not signed in" do 

      describe "POST /:username/friendships" do 
        it "requests friendship" do 
          visit user_path(@friend)
          click_button 'Request Friendship'
          page.should have_content 'You need to sign in first to continue.'
        end
      end
    end

  end

これを渡す方法はありますか?

4

0 に答える 0