Last active
August 29, 2015 14:07
-
-
Save joemsak/e07c8a8d53a23103360d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We'll create our rails app, called 'resource_library' | |
cd ~/code | |
rvm use 2.1.2 | |
gem update rails | |
rails new resource_library | |
# Please note my rails default template | |
# http://github.com/joemsak/rails-template/tree/master/default.rb | |
cd resource_library | |
# open this directory in your favorite text editor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open the Gemfile and edit it for the test group like so: | |
group :test do | |
# debugging | |
gem "pry-rails", "~> 0.3.2" | |
gem "launchy", "~> 2.4.2" | |
# unit tests, integration tests | |
gem "rspec-rails", "~> 3.0.2" | |
gem "capybara-webkit", "~> 1.2.0" | |
# utilities | |
gem "database_cleaner", "~> 1.3.0" | |
gem "factory_girl_rails", "~> 4.4.1" | |
# record responeses from remote services | |
gem 'vcr', '~> 2.9.3' | |
gem 'webmock', '~> 1.19.0' | |
# load rails env faster for RSpec | |
gem "spring-commands-rspec", "~> 1.0.2" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run these commands in Terminal to install gems, setup the database, and install RSpec | |
bundle | |
rake db:create db:migrate | |
rails g rspec:install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make edits to the TWO RSpec helper files | |
# RSpec 3 now uses a Spec Helper | |
# for tests that don't need Rails loaded | |
# and a Rails Helper for tests that do | |
# spec/spec_helper.rb | |
RSpec.configure do |config| | |
config.filter_run :focus | |
config.run_all_when_everything_filtered = true | |
if config.files_to_run.one? | |
config.default_formatter = 'doc' | |
end | |
config.order = :random | |
Kernel.srand config.seed | |
config.expect_with :rspec do |expectations| | |
expectations.syntax = :expect | |
end | |
config.mock_with :rspec do |mocks| | |
mocks.syntax = :expect | |
mocks.verify_partial_doubles = true | |
end | |
end | |
# We'll add Capybara-Webkit, | |
# Database Cleaner, and VCR to Rails Helper | |
# spec/rails_helper.rb | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'capybara/rspec' | |
require 'vcr' | |
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } | |
ActiveRecord::Migration.maintain_test_schema! | |
Capybara.javascript_driver = :webkit | |
RSpec.configure do |config| | |
config.fixture_path = "#{::Rails.root}/spec/fixtures" | |
config.use_transactional_fixtures = false | |
config.infer_spec_type_from_file_location! | |
config.before(:suite) do | |
DatabaseCleaner.strategy = :truncation | |
begin | |
DatabaseCleaner.start | |
ensure | |
DatabaseCleaner.clean | |
end | |
end | |
config.before(:each) do | |
DatabaseCleaner.start | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
end | |
end | |
VCR.configure do |c| | |
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes' | |
c.hook_into :webmock | |
c.ignore_localhost = true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Let's make sure it all works | |
# and then make our initial commit | |
spring rspec | |
# This should show 0 examples, 0 failures, and with no errors | |
git init | |
git add . | |
git commit -m "Initial commit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment