0

Rails アプリで rspec を使用しており、gem を更新しました。テストを実行すると、次のメッセージが表示されます。

Accessing shared_examples defined across contexts is deprecated.
Please declare shared_examples within a shared context, or at the top level.
This message was generated at: /home/flo/RoR/letroquet/spec/requests/user_show_page_spec.rb:50:in `block (3 levels) in <top (required)>'

ここにuser_show_page_spec.rbがあります

describe "show user page" do

  subject { page }

  let(:user) { FactoryGirl.create(:user) }
  let(:current_page) { user_path(user) }

  describe "aside info" do

    describe "when not signed-in" do
      before { visit current_page }

      it { should have_selector('h1', text: user.name) }

      it_should_behave_like "another user products count" # This is the 50th line
    end
  end
end

そしてここでspec/support/users/info.rb

require 'spec_helper'

describe "products count" do
  subject { page }

  shared_examples_for "another user products count" do
    before { visit current_page }

    it { should have_selector('b', text: t('product.owned.count', count: user.transactions.current.ownership.count)) }
    it { should have_selector('li', text: t('product.givable.count', count: user.products.owned.givable.count)) }
    it { should have_selector('li', text: t('product.sharable.count', count: user.products.owned.sharable.count)) }
    it { should have_selector('li', text: t('product.borrowed.count', count: user.products.borrowed.count)) }

    it { should have_selector('li', text: t('product.given.count', count: user.products.given.count)) }
    it { should have_selector('li', text: t('product.returned.count', count: user.products.returned.count)) }

  end
end

テストファイルを変更する方法を教えてください。

4

1 に答える 1