Skip to content

Commit 10ac2fe

Browse files
author
Ryan Bigg
committed
Section 3.3.1: Set up gem dependencies and run rspec generator
1 parent 35475c1 commit 10ac2fe

File tree

6 files changed

+186
-0
lines changed

6 files changed

+186
-0
lines changed

ticketee/.rspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--require spec_helper

ticketee/Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,11 @@ group :development, :test do
4141

4242
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
4343
gem 'spring'
44+
45+
gem 'rspec-rails', '3.1.0'
46+
end
47+
48+
group :test do
49+
gem 'capybara', '2.4.4'
4450
end
4551

ticketee/Gemfile.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ GEM
4444
columnize (~> 0.8)
4545
debugger-linecache (~> 1.2)
4646
slop (~> 3.6)
47+
capybara (2.4.4)
48+
mime-types (>= 1.16)
49+
nokogiri (>= 1.3.3)
50+
rack (>= 1.0.0)
51+
rack-test (>= 0.5.4)
52+
xpath (~> 2.0)
4753
coffee-rails (4.0.1)
4854
coffee-script (>= 2.2.0)
4955
railties (>= 4.0.0, < 5.0)
@@ -54,6 +60,7 @@ GEM
5460
columnize (0.8.9)
5561
debug_inspector (0.0.2)
5662
debugger-linecache (1.2.0)
63+
diff-lcs (1.2.5)
5764
erubis (2.7.0)
5865
execjs (2.2.2)
5966
globalid (0.3.0)
@@ -108,6 +115,22 @@ GEM
108115
rake (10.3.2)
109116
rdoc (4.1.2)
110117
json (~> 1.4)
118+
rspec-core (3.1.7)
119+
rspec-support (~> 3.1.0)
120+
rspec-expectations (3.1.2)
121+
diff-lcs (>= 1.2.0, < 2.0)
122+
rspec-support (~> 3.1.0)
123+
rspec-mocks (3.1.3)
124+
rspec-support (~> 3.1.0)
125+
rspec-rails (3.1.0)
126+
actionpack (>= 3.0)
127+
activesupport (>= 3.0)
128+
railties (>= 3.0)
129+
rspec-core (~> 3.1.0)
130+
rspec-expectations (~> 3.1.0)
131+
rspec-mocks (~> 3.1.0)
132+
rspec-support (~> 3.1.0)
133+
rspec-support (3.1.2)
111134
sass (3.4.6)
112135
sass-rails (5.0.0.beta1)
113136
railties (>= 4.0.0, < 5.0)
@@ -144,16 +167,20 @@ GEM
144167
binding_of_caller (= 0.7.3.pre1)
145168
railties (~> 4.0)
146169
sprockets-rails (>= 2.0, < 4.0)
170+
xpath (2.0.0)
171+
nokogiri (~> 1.3)
147172

148173
PLATFORMS
149174
ruby
150175

151176
DEPENDENCIES
152177
byebug
178+
capybara (= 2.4.4)
153179
coffee-rails (~> 4.0.0)
154180
jbuilder (~> 2.0)
155181
jquery-rails (~> 4.0.0.beta2)
156182
rails (= 4.2.0.beta2)
183+
rspec-rails (= 3.1.0)
157184
sass-rails (~> 5.0.0.beta1)
158185
sdoc (~> 0.4.0)
159186
spring

ticketee/bin/rspec

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env ruby
2+
#
3+
# This file was generated by Bundler.
4+
#
5+
# The application 'rspec' is installed as part of a gem, and
6+
# this file is here to facilitate running it.
7+
#
8+
9+
require 'pathname'
10+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11+
Pathname.new(__FILE__).realpath)
12+
13+
require 'rubygems'
14+
require 'bundler/setup'
15+
16+
load Gem.bin_path('rspec-core', 'rspec')

ticketee/spec/rails_helper.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This file is copied to spec/ when you run 'rails generate rspec:install'
2+
ENV["RAILS_ENV"] ||= 'test'
3+
require 'spec_helper'
4+
require File.expand_path("../../config/environment", __FILE__)
5+
require 'rspec/rails'
6+
# Add additional requires below this line. Rails is not loaded until this point!
7+
8+
# Requires supporting ruby files with custom matchers and macros, etc, in
9+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
10+
# run as spec files by default. This means that files in spec/support that end
11+
# in _spec.rb will both be required and run as specs, causing the specs to be
12+
# run twice. It is recommended that you do not name files matching this glob to
13+
# end with _spec.rb. You can configure this pattern with the --pattern
14+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
15+
#
16+
# The following line is provided for convenience purposes. It has the downside
17+
# of increasing the boot-up time by auto-requiring all files in the support
18+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
19+
# require only the support files necessary.
20+
#
21+
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
22+
23+
# Checks for pending migrations before tests are run.
24+
# If you are not using ActiveRecord, you can remove this line.
25+
ActiveRecord::Migration.maintain_test_schema!
26+
27+
RSpec.configure do |config|
28+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
29+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
30+
31+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
32+
# examples within a transaction, remove the following line or assign false
33+
# instead of true.
34+
config.use_transactional_fixtures = true
35+
36+
# RSpec Rails can automatically mix in different behaviours to your tests
37+
# based on their file location, for example enabling you to call `get` and
38+
# `post` in specs under `spec/controllers`.
39+
#
40+
# You can disable this behaviour by removing the line below, and instead
41+
# explicitly tag your specs with their type, e.g.:
42+
#
43+
# RSpec.describe UsersController, :type => :controller do
44+
# # ...
45+
# end
46+
#
47+
# The different available types are documented in the features, such as in
48+
# https://relishapp.com/rspec/rspec-rails/docs
49+
config.infer_spec_type_from_file_location!
50+
end

ticketee/spec/spec_helper.rb

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
2+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
4+
# file to always be loaded, without a need to explicitly require it in any files.
5+
#
6+
# Given that it is always loaded, you are encouraged to keep this file as
7+
# light-weight as possible. Requiring heavyweight dependencies from this file
8+
# will add to the boot time of your test suite on EVERY test run, even for an
9+
# individual file that may not need all of that loaded. Instead, consider making
10+
# a separate helper file that requires the additional dependencies and performs
11+
# the additional setup, and require it from the spec files that actually need it.
12+
#
13+
# The `.rspec` file also contains a few flags that are not defaults but that
14+
# users commonly want.
15+
#
16+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17+
RSpec.configure do |config|
18+
# rspec-expectations config goes here. You can use an alternate
19+
# assertion/expectation library such as wrong or the stdlib/minitest
20+
# assertions if you prefer.
21+
config.expect_with :rspec do |expectations|
22+
# This option will default to `true` in RSpec 4. It makes the `description`
23+
# and `failure_message` of custom matchers include text for helper methods
24+
# defined using `chain`, e.g.:
25+
# be_bigger_than(2).and_smaller_than(4).description
26+
# # => "be bigger than 2 and smaller than 4"
27+
# ...rather than:
28+
# # => "be bigger than 2"
29+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30+
end
31+
32+
# rspec-mocks config goes here. You can use an alternate test double
33+
# library (such as bogus or mocha) by changing the `mock_with` option here.
34+
config.mock_with :rspec do |mocks|
35+
# Prevents you from mocking or stubbing a method that does not exist on
36+
# a real object. This is generally recommended, and will default to
37+
# `true` in RSpec 4.
38+
mocks.verify_partial_doubles = true
39+
end
40+
41+
# The settings below are suggested to provide a good initial experience
42+
# with RSpec, but feel free to customize to your heart's content.
43+
=begin
44+
# These two settings work together to allow you to limit a spec run
45+
# to individual examples or groups you care about by tagging them with
46+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
47+
# get run.
48+
config.filter_run :focus
49+
config.run_all_when_everything_filtered = true
50+
51+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
52+
# For more details, see:
53+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56+
config.disable_monkey_patching!
57+
58+
# Many RSpec users commonly either run the entire suite or an individual
59+
# file, and it's useful to allow more verbose output when running an
60+
# individual spec file.
61+
if config.files_to_run.one?
62+
# Use the documentation formatter for detailed output,
63+
# unless a formatter has already been configured
64+
# (e.g. via a command-line flag).
65+
config.default_formatter = 'doc'
66+
end
67+
68+
# Print the 10 slowest examples and example groups at the
69+
# end of the spec run, to help surface which specs are running
70+
# particularly slow.
71+
config.profile_examples = 10
72+
73+
# Run specs in random order to surface order dependencies. If you find an
74+
# order dependency and want to debug it, you can fix the order by providing
75+
# the seed, which is printed after each run.
76+
# --seed 1234
77+
config.order = :random
78+
79+
# Seed global randomization in this process using the `--seed` CLI option.
80+
# Setting this allows you to use `--seed` to deterministically reproduce
81+
# test failures related to randomization by passing the same `--seed` value
82+
# as the one that triggered the failure.
83+
Kernel.srand config.seed
84+
=end
85+
end

0 commit comments

Comments
 (0)