Ensure that we are req'd after rspec in tests

Currently before running unit tests we are getting auto-required before
rspec-rails is getting required. This is bad because we need to wait
until rspec-rails is loaded before injecting Shoulda::Matchers::* into
the current RSpec context, otherwise matchers that clash with
rspec-rails (such as `render_template` will get overridden).

This is happening when creating and booting the Rails application.
Bundler will auto-require any gems in the Gemfile. One of these gems is
ourselves (via the `gemspec` line). Since there aren't any dependencies
in the gemspec, there's no need for us to be in the Gemfile.

This means that we no longer have to explicit `include` Rails
ActionController template assertions in the tests for `render_template`
as they should get included automatically for us.
This commit is contained in:
Elliot Winkler 2014-12-24 16:28:35 -05:00
parent d86fe2d1c0
commit a9ab35117b
18 changed files with 1 additions and 75 deletions

View File

@ -1,7 +1,5 @@
source 'https://rubygems.org'
gemspec
gem 'appraisal', '~> 1.0'
gem 'aruba'
gem 'bourne', '~> 1.3'

View File

@ -1,9 +1,3 @@
PATH
remote: .
specs:
shoulda-matchers (2.7.0)
activesupport (>= 3.0.0)
GEM
remote: https://rubygems.org/
specs:
@ -162,7 +156,6 @@ DEPENDENCIES
redcarpet
rspec-rails (>= 2.99.0)
shoulda-context (~> 1.2.0)
shoulda-matchers!
sqlite3
therubyrhino
watchr

View File

@ -24,5 +24,3 @@ gem "therubyrhino", :platform => :jruby
gem "strong_parameters"
gem "minitest", "~> 4.0"
gem "minitest-reporters"
gemspec :path => "../"

View File

@ -1,9 +1,3 @@
PATH
remote: ../
specs:
shoulda-matchers (2.7.0)
activesupport (>= 3.0.0)
GEM
remote: https://rubygems.org/
specs:
@ -170,7 +164,6 @@ DEPENDENCIES
redcarpet
rspec-rails (= 2.99.0)
shoulda-context (~> 1.2.0)
shoulda-matchers!
sqlite3
strong_parameters
therubyrhino

View File

@ -30,5 +30,3 @@ gem "sass-rails", "~> 3.1.5"
gem "coffee-rails", "~> 3.1.1"
gem "uglifier", ">= 1.0.3"
gem "turn", "~> 0.8.3"
gemspec :path => "../"

View File

@ -1,9 +1,3 @@
PATH
remote: ../
specs:
shoulda-matchers (2.7.0)
activesupport (>= 3.0.0)
GEM
remote: https://rubygems.org/
specs:
@ -207,7 +201,6 @@ DEPENDENCIES
rspec-rails (= 2.99.0)
sass-rails (~> 3.1.5)
shoulda-context (~> 1.2.0)
shoulda-matchers!
sqlite3
strong_parameters
therubyrhino

View File

@ -31,5 +31,3 @@ gem "coffee-rails", "~> 3.2.1"
gem "uglifier", ">= 1.0.3"
gem "spring"
gem "spring-commands-rspec"
gemspec :path => "../"

View File

@ -1,9 +1,3 @@
PATH
remote: ../
specs:
shoulda-matchers (2.7.0)
activesupport (>= 3.0.0)
GEM
remote: https://rubygems.org/
specs:
@ -206,7 +200,6 @@ DEPENDENCIES
rspec-rails (= 2.99.0)
sass-rails (~> 3.2.3)
shoulda-context (~> 1.2.0)
shoulda-matchers!
spring
spring-commands-rspec
sqlite3

View File

@ -34,5 +34,3 @@ gem "minitest-reporters"
gem "jbuilder", "~> 1.2"
gem "sass-rails", "~> 4.0.0"
gem "bcrypt-ruby", "~> 3.0.0"
gemspec :path => "../"

View File

@ -1,9 +1,3 @@
PATH
remote: ../
specs:
shoulda-matchers (2.7.0)
activesupport (>= 3.0.0)
GEM
remote: https://rubygems.org/
specs:
@ -217,7 +211,6 @@ DEPENDENCIES
sass-rails (~> 4.0.0)
sdoc
shoulda-context (~> 1.2.0)
shoulda-matchers!
spring
spring-commands-rspec
sqlite3

View File

@ -34,5 +34,3 @@ gem "minitest-reporters"
gem "jbuilder", "~> 1.2"
gem "sass-rails", "~> 4.0.0"
gem "bcrypt-ruby", "~> 3.1.2"
gemspec :path => "../"

View File

@ -1,9 +1,3 @@
PATH
remote: ../
specs:
shoulda-matchers (2.7.0)
activesupport (>= 3.0.0)
GEM
remote: https://rubygems.org/
specs:
@ -215,7 +209,6 @@ DEPENDENCIES
sass-rails (~> 4.0.0)
sdoc
shoulda-context (~> 1.2.0)
shoulda-matchers!
spring
spring-commands-rspec
sqlite3

View File

@ -34,5 +34,3 @@ gem "minitest-reporters"
gem "jbuilder", "~> 2.0"
gem "sass-rails", "~> 4.0.3"
gem "bcrypt", "~> 3.1.7"
gemspec :path => "../"

View File

@ -1,9 +1,3 @@
PATH
remote: ../
specs:
shoulda-matchers (2.7.0)
activesupport (>= 3.0.0)
GEM
remote: https://rubygems.org/
specs:
@ -214,7 +208,6 @@ DEPENDENCIES
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)
shoulda-context (~> 1.2.0)
shoulda-matchers!
spring
spring-commands-rspec
sqlite3

View File

@ -34,5 +34,3 @@ gem "minitest-reporters"
gem "jbuilder", "~> 2.0"
gem "sass-rails", "~> 5.0"
gem "bcrypt", "~> 3.1.7"
gemspec :path => "../"

View File

@ -1,9 +1,3 @@
PATH
remote: ../
specs:
shoulda-matchers (2.7.0)
activesupport (>= 3.0.0)
GEM
remote: https://rubygems.org/
specs:
@ -241,7 +235,6 @@ DEPENDENCIES
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
shoulda-context (~> 1.2.0)
shoulda-matchers!
spring
spring-commands-rspec
sqlite3

View File

@ -1,8 +1,6 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RenderTemplateMatcher, type: :controller do
include ActionController::TemplateAssertions
context 'a controller that renders a template' do
it 'accepts rendering that template' do
expect(controller_with_show).to render_template(:show)

View File

@ -22,8 +22,8 @@ monkey_patch_minitest_to_do_nothing
ENV['BUNDLE_GEMFILE'] ||= app.gemfile_path
ENV['RAILS_ENV'] = 'test'
require 'shoulda-matchers'
require 'rspec/rails'
require 'shoulda-matchers'
PROJECT_ROOT = File.expand_path('../..', __FILE__)
$LOAD_PATH << File.join(PROJECT_ROOT, 'lib')