Skip to content

Instantly share code, notes, and snippets.

@yhordi
Created April 17, 2017 22:09
Show Gist options
  • Save yhordi/2c6184aa580fd1d01591a4c21cdd647e to your computer and use it in GitHub Desktop.
Save yhordi/2c6184aa580fd1d01591a4c21cdd647e to your computer and use it in GitHub Desktop.
Helpful test config stuff
require 'rails_helper'
describe 'Article', js: true do
it 'can see the newly create article' do
visit new_article_path
fill_in 'Title', with: 'HAM'
fill_in 'Body', with: 'Thank you, CornMan.'
click_on 'Create Article'
expect(page).to have_content('CornMan')
end
end
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.0.2'
gem 'pg', '~> 0.18'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
gem 'faker'
gem 'byebug', platform: :mri
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'rspec-rails'
gem 'rails-controller-testing'
gem 'capybara'
gem 'selenium-webdriver'
gem 'database_cleaner'
gem 'chromedriver-helper'
gem 'simplecov'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
# Below is the thing you need to get selenium to work with crhome
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
# Below here is the code you need to get your database cleaner to work with capybara
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each, :js => true) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
# end database cleaner stuff
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
end
require 'simplecov'
SimpleCov.start 'rails'
# Everything below this is standard, with comments removed.
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.shared_context_metadata_behavior = :apply_to_host_groups
config.disable_monkey_patching!
if config.files_to_run.one?
config.default_formatter = 'doc'
end
config.profile_examples = 10
config.order = :random
Kernel.srand config.seed
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment