Skip to content

Instantly share code, notes, and snippets.

@fantgeass
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fantgeass/56d31f56ba2924cce0a5 to your computer and use it in GitHub Desktop.
Save fantgeass/56d31f56ba2924cce0a5 to your computer and use it in GitHub Desktop.
test-environment-code
--color
--require spec_helper
--format documentation
group :development, :test do
gem 'rspec-rails', '~> 3.1.0'
gem 'factory_girl_rails', '~> 4.4.1'
end
group :test do
gem 'capybara', '~> 2.4.3'
gem 'capybara-webkit', '~> 1.3.0'
gem 'webmock', '~> 1.18.0'
gem 'database_cleaner', '~> 1.3.0'
gem 'faker', '~> 1.4.3'
gem 'shoulda-matchers', '~> 2.7.0', require: false
gem 'shoulda-callback-matchers', '~> 1.1.1'
end
require 'rails_helper'
<% module_namespacing do -%>
RSpec.describe <%= class_name %>, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
describe 'Associations' do
# associations
end
describe 'Validations' do
# validations
end
describe 'Scopes' do
# scopes
end
end
<% end -%>
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
require 'capybara/rspec'
require 'webmock/rspec'
require 'shoulda/matchers'
# Uncomment if you always want to require all support files at once
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
ActiveRecord::Migration.maintain_test_schema!
Capybara.javascript_driver = :webkit
WebMock.disable_net_connect!(allow_localhost: true)
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with :truncation
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
config.infer_spec_type_from_file_location!
end
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.disable_monkey_patching!
config.filter_run :focus
config.run_all_when_everything_filtered = true
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