我在我的 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
你能告诉我我必须如何更改我的测试文件吗?