Skip to content

Instantly share code, notes, and snippets.

@domagude
Created November 8, 2017 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domagude/eb3ade07c5454522e038937eaec04979 to your computer and use it in GitHub Desktop.
Save domagude/eb3ade07c5454522e038937eaec04979 to your computer and use it in GitHub Desktop.
require "rails_helper"
RSpec.feature "Create a new post", :type => :feature do
let(:user) { create(:user) }
before(:each) { sign_in user }
shared_examples 'user creates a new post' do |branch|
scenario 'successfully' do
create(:category, name: 'category', branch: branch)
visit send("#{branch}_posts_path")
find('.new-post-button').click
fill_in 'post[title]', with: 'a' * 20
fill_in 'post[content]', with: 'a' * 20
select 'category', from: 'post[category_id]'
click_on 'Create a post'
expect(page).to have_selector('h3', text: 'a' * 20)
end
end
include_examples 'user creates a new post', 'hobby'
include_examples 'user creates a new post', 'study'
include_examples 'user creates a new post', 'team'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment