QA@IT
«回答へ戻る

OmniAuth.config.mock_auth[:facebook]

139
     @item = FactoryGirl.create(:item)
     @user.items << @item
     OmniAuth.config.test_mode = true
-    OmniAuth.config.mock_auth[:user] = FactoryGirl.attributes_for(:user)
+    OmniAuth.config.mock_auth[:facebook] = FactoryGirl.attributes_for(:user)
 
   end
 

以下の通りでいけました。ありがとうございました。


require 'spec_helper'

describe "Shelves" do
  before(:each) do
    @user = FactoryGirl.create(:user)
    @item = FactoryGirl.create(:item)
    @user.items << @item
    OmniAuth.config.test_mode = true
    OmniAuth.config.mock_auth[:facebook] = FactoryGirl.attributes_for(:user)

  end

  describe "GET /shelves" do
    context "when logged in as a valid user," do
      it "should show the items of current user" do
        get "/auth/facebook"
        visit shelves_path
        page.should have_content(@item.name)
      end
    end
  end
end
以下の通りでいけました。ありがとうございました。

``` ruby

require 'spec_helper'

describe "Shelves" do
  before(:each) do
    @user = FactoryGirl.create(:user)
    @item = FactoryGirl.create(:item)
    @user.items << @item
    OmniAuth.config.test_mode = true
    OmniAuth.config.mock_auth[:facebook] = FactoryGirl.attributes_for(:user)

  end

  describe "GET /shelves" do
    context "when logged in as a valid user," do
      it "should show the items of current user" do
        get "/auth/facebook"
        visit shelves_path
        page.should have_content(@item.name)
      end
    end
  end
end
```

回答を投稿

以下の通りでいけました。ありがとうございました。


require 'spec_helper'

describe "Shelves" do
  before(:each) do
    @user = FactoryGirl.create(:user)
    @item = FactoryGirl.create(:item)
    @user.items << @item
    OmniAuth.config.test_mode = true
    OmniAuth.config.mock_auth[:user] = FactoryGirl.attributes_for(:user)

  end

  describe "GET /shelves" do
    context "when logged in as a valid user," do
      it "should show the items of current user" do
        get "/auth/facebook"
        visit shelves_path
        page.should have_content(@item.name)
      end
    end
  end
end
以下の通りでいけました。ありがとうございました。

``` ruby

require 'spec_helper'

describe "Shelves" do
  before(:each) do
    @user = FactoryGirl.create(:user)
    @item = FactoryGirl.create(:item)
    @user.items << @item
    OmniAuth.config.test_mode = true
    OmniAuth.config.mock_auth[:user] = FactoryGirl.attributes_for(:user)

  end

  describe "GET /shelves" do
    context "when logged in as a valid user," do
      it "should show the items of current user" do
        get "/auth/facebook"
        visit shelves_path
        page.should have_content(@item.name)
      end
    end
  end
end
```