【发布时间】:2016-08-08 17:57:14
【问题描述】:
我想知道是否有一种方法可以像在 Capybara 中那样将 Protractor 的场景分组到上下文中?
例如,如果我正在为帖子隐私设置编写测试,我可以为未登录的用户提供上下文,为登录的用户提供上下文,根据用户之间的关系划分为不同的场景。 另一个例子:
feature 'allows user to share' do
let!(:post) { create :post }
before do
create :feed_post, user: user, post: post
app.sign_in user
end
context 'with comment' do
subject { feed.share_modal }
before { feed.posts.first.share_post }
scenario { is_expected.to have_content t('social_sharing.new.title') }
scenario { is_expected.to have_button t('social_sharing.new.action') }
context 'sharing with a comment' do
before do
feed.share_modal.comment_on_share 'a nice comment'
feed.share_modal.submit_share_form
feed.wait_until_share_modal_invisible
end
scenario 'closes the modal' do
expect(feed).to have_no_share_modal
end
scenario 'shows shared message' do
expect(feed.posts.first)
.to have_content "#{user.name} shared #{post.user.name.possessive} post"
expect(feed.posts.first).to have_content 'a nice comment'
end
end
end
end
Context 允许我将规范设为 DRY,因为我可以在其中添加一个 before 块,其中包含针对上下文中的场景重复的步骤。量角器可以吗?
【问题讨论】:
-
你是在问about specs vs suites吗?
标签: protractor