diff --git a/.gitignore b/.gitignore index 050c9d95c..800086114 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ /log/* !/log/.keep /tmp + +/spec/examples.txt \ No newline at end of file diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..83e16f804 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/Gemfile b/Gemfile index e8196f051..84005e07a 100644 --- a/Gemfile +++ b/Gemfile @@ -41,5 +41,6 @@ group :development, :test do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' + gem 'rspec-rails', '~> 3.0' end diff --git a/Gemfile.lock b/Gemfile.lock index 50a2a2b08..441af5fa2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,6 +51,7 @@ GEM coffee-script-source (1.9.1.1) columnize (0.9.0) debug_inspector (0.0.2) + diff-lcs (1.2.5) erubis (2.7.0) execjs (2.5.2) globalid (0.3.5) @@ -103,6 +104,23 @@ GEM thor (>= 0.18.1, < 2.0) rake (10.4.2) rdoc (4.2.0) + rspec-core (3.3.1) + rspec-support (~> 3.3.0) + rspec-expectations (3.3.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-mocks (3.3.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-rails (3.3.2) + actionpack (>= 3.0, < 4.3) + activesupport (>= 3.0, < 4.3) + railties (>= 3.0, < 4.3) + rspec-core (~> 3.3.0) + rspec-expectations (~> 3.3.0) + rspec-mocks (~> 3.3.0) + rspec-support (~> 3.3.0) + rspec-support (3.3.0) sass (3.4.16) sass-rails (5.0.3) railties (>= 4.0.0, < 5.0) @@ -146,6 +164,7 @@ DEPENDENCIES jbuilder (~> 2.0) jquery-rails rails (= 4.2.3) + rspec-rails (~> 3.0) sass-rails (~> 5.0) sdoc (~> 0.4.0) spring diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 000000000..0c86b5c6f --- /dev/null +++ b/bin/rspec @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('rspec-core', 'rspec') diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 000000000..972bb3bba --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,12 @@ +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' +ActiveRecord::Migration.maintain_test_schema! + +RSpec.configure do |config| + config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 000000000..d0b233102 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,35 @@ +RSpec.configure do |config| + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +end