Skip to content

Instantly share code, notes, and snippets.

@thePaulista
Last active May 30, 2016 03:52
Show Gist options
  • Save thePaulista/5f82ff7cfedde8f186c0800ba81aea70 to your computer and use it in GitHub Desktop.
Save thePaulista/5f82ff7cfedde8f186c0800ba81aea70 to your computer and use it in GitHub Desktop.
Mini test API test setup
-----------------------------
test_helper.rb for MINITEST
---------------------------------
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/pride'
require 'webmock' #fakes http request
require 'vcr'
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
VCR.configure do |config|
config.cassette_library_dir = 'test/cassettes'
config.hook_into :webmock
end
end
-------------------------
rails_helper setup for RSPEC
-------------------------
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
require "capybara/rails"
# Add additional requires below this line. Rails is not loaded until this point!
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
VCR.configure do |c|
c.cassette_library_dir = "spec/casettes"
c.hook_into :webmock
end
------------------------
spec_helper.rb
------------------------
require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start
require 'simplecov'
SimpleCov.start 'rails'
-------------------------
spec/support/factory_girl.rb
-------------------------------
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.before(:suite) do
begin
DatabaseCleaner.start
FactoryGirl.lint
ensure
DatabaseCleaner.clean
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment