Skip to content

Commit

Permalink
Merge pull request #40 from eliotsykes/add-require-support-instructions
Browse files Browse the repository at this point in the history
Add instruction on auto-requiring spec/support
  • Loading branch information
eliotsykes committed Apr 16, 2015
2 parents 778940b + 6275256 commit 72c2ea5
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 9 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Hopefully this will be of help to those of you learning RSpec and Rails. If ther

<!-- MarkdownTOC depth=0 autolink=true bracket=round -->

- [Support Configuration](#support-configuration)
- [Testing Rake Tasks with RSpec](#testing-rake-tasks-with-rspec)
- [Pry-rescue debugging](#pry-rescue-debugging)
- [Time Travel Examples](#time-travel-examples)
Expand Down Expand Up @@ -48,6 +49,16 @@ Hopefully this will be of help to those of you learning RSpec and Rails. If ther

<!-- /MarkdownTOC -->

# Support Configuration

The tests rely on this configuration being uncommented in `spec/rails_helper.rb`, you probably want it uncommented in your app too:
```ruby
# Loads `.rb` files in `spec/support` and its subdirectories:
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
```
(The rspec-rails installer generates this line, but it will be commented out.)


# Testing Rake Tasks with RSpec

RSpec testing Rake task configuration and example:
Expand Down
2 changes: 2 additions & 0 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Installing Capybara:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add capybara, selenium-webdriver, and chromedriver-helper to Gemfile:
#
# group :development, :test do
Expand Down
2 changes: 2 additions & 0 deletions spec/support/capybara_driver_resolver.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# You probably don't need this config, its for setting up Capybara drivers
# with descriptive names related to the underlying browser's HTML5 support.
module CapybaraDriverResolver
Expand Down
7 changes: 2 additions & 5 deletions spec/support/database_cleaner.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Installing database_cleaner:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add database_cleaner to Gemfile:
#
# group :test do
Expand Down Expand Up @@ -71,8 +73,3 @@
end

end

# Suggested docs
# --------------
# http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/

2 changes: 2 additions & 0 deletions spec/support/email_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Installing email_spec:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add email_spec to Gemfile:
#
# group :test do
Expand Down
2 changes: 2 additions & 0 deletions spec/support/factory_girl.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Installing factory_girl:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add factory_girl_rails to Gemfile:
#
# group :development, :test do
Expand Down
5 changes: 4 additions & 1 deletion spec/support/job_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Use Rails-provided test helper methods
# Use Rails-provided test helper methods:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Create a file like this one you're reading in spec/support/job_helpers.rb:
RSpec.configure do |config|
config.include ActiveJob::TestHelper, type: :job
end
Expand Down
4 changes: 3 additions & 1 deletion spec/support/matchers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Setting up Custom Matchers
# Setting up Custom Matchers:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Create a file like this one you're reading in spec/support/matchers.rb:

Dir[Rails.root.join("spec/matchers/**/*.rb")].each { |f| require f }
Expand Down
2 changes: 2 additions & 0 deletions spec/support/puffing_billy.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Installing Puffing Billy:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Puffing Billy depends on Capybara. Install Capybara as explained
# in spec/support/capybara.rb
#
Expand Down
4 changes: 3 additions & 1 deletion spec/support/shoulda_matchers.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Installing shoulda-matchers:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add shoulda-matchers to Gemfile:
#
# group :test do
# gem 'shoulda-matchers', require: false
# end
#
# 2. Create a file like this one you're reading in spec/support/shoulda-matchers.rb:
# 2. Create a file like this one you're reading in spec/support/shoulda_matchers.rb:
require 'shoulda/matchers'


Expand Down
5 changes: 5 additions & 0 deletions spec/support/tasks.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# How to test Rake tasks:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Create a file like this one you're reading in spec/support/tasks.rb:
require "rake"

RSpec.configure do |config|
Expand Down
5 changes: 4 additions & 1 deletion spec/support/time_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Use Rails-provided test helper methods instead of Timecop
# Use Rails-provided test helper methods instead of Timecop:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Create a file like this one you're reading in spec/support/time_helpers.rb:
RSpec.configure do |config|
config.include ActiveSupport::Testing::TimeHelpers
end
Expand Down
2 changes: 2 additions & 0 deletions spec/support/vcr.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Installing VCR:

# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add vcr and webmock gems to Gemfile:
#
# group :test do
Expand Down

0 comments on commit 72c2ea5

Please sign in to comment.