I was wondering if there's a way of grouping Protractor's scenarios into contexts like it's possible in Capybara?
For example, if I was writing tests for post privacy settings, I could have context for user that is not logged in and context for logged in user that divides into different scenarios based on relation between the users. Another example:
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 allows me to make the specs DRY, because I can add a before block inside it that contains steps that are repeating for scenarios inside the context. Is it possible with Protractor?