Skip to content

Commit fadd2a8

Browse files
authored
Setup rspec test framework (NCCE#8)
* remove test folder * Setup RSpec with some handy testing gems
1 parent d1e19d8 commit fadd2a8

File tree

20 files changed

+393
-79
lines changed

20 files changed

+393
-79
lines changed

.rspec

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

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ group :development, :test do
1919
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
2020
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
2121
gem 'dotenv-rails'
22+
gem 'rspec-rails', '~> 3.8'
23+
gem 'webmock'
2224
end
2325

2426
group :development do
@@ -33,6 +35,8 @@ group :test do
3335
gem 'capybara', '>= 2.15'
3436
gem 'selenium-webdriver'
3537
gem 'chromedriver-helper'
38+
gem 'shoulda-matchers', '~> 3.1'
39+
gem 'simplecov'
3640
end
3741

3842
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Gemfile.lock

Lines changed: 83 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (5.2.1)
5-
actionpack (= 5.2.1)
4+
actioncable (5.2.1.1)
5+
actionpack (= 5.2.1.1)
66
nio4r (~> 2.0)
77
websocket-driver (>= 0.6.1)
8-
actionmailer (5.2.1)
9-
actionpack (= 5.2.1)
10-
actionview (= 5.2.1)
11-
activejob (= 5.2.1)
8+
actionmailer (5.2.1.1)
9+
actionpack (= 5.2.1.1)
10+
actionview (= 5.2.1.1)
11+
activejob (= 5.2.1.1)
1212
mail (~> 2.5, >= 2.5.4)
1313
rails-dom-testing (~> 2.0)
14-
actionpack (5.2.1)
15-
actionview (= 5.2.1)
16-
activesupport (= 5.2.1)
14+
actionpack (5.2.1.1)
15+
actionview (= 5.2.1.1)
16+
activesupport (= 5.2.1.1)
1717
rack (~> 2.0)
1818
rack-test (>= 0.6.3)
1919
rails-dom-testing (~> 2.0)
2020
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21-
actionview (5.2.1)
22-
activesupport (= 5.2.1)
21+
actionview (5.2.1.1)
22+
activesupport (= 5.2.1.1)
2323
builder (~> 3.1)
2424
erubi (~> 1.4)
2525
rails-dom-testing (~> 2.0)
2626
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27-
activejob (5.2.1)
28-
activesupport (= 5.2.1)
27+
activejob (5.2.1.1)
28+
activesupport (= 5.2.1.1)
2929
globalid (>= 0.3.6)
30-
activemodel (5.2.1)
31-
activesupport (= 5.2.1)
32-
activerecord (5.2.1)
33-
activemodel (= 5.2.1)
34-
activesupport (= 5.2.1)
30+
activemodel (5.2.1.1)
31+
activesupport (= 5.2.1.1)
32+
activerecord (5.2.1.1)
33+
activemodel (= 5.2.1.1)
34+
activesupport (= 5.2.1.1)
3535
arel (>= 9.0)
36-
activestorage (5.2.1)
37-
actionpack (= 5.2.1)
38-
activerecord (= 5.2.1)
36+
activestorage (5.2.1.1)
37+
actionpack (= 5.2.1.1)
38+
activerecord (= 5.2.1.1)
3939
marcel (~> 0.3.1)
40-
activesupport (5.2.1)
40+
activesupport (5.2.1.1)
4141
concurrent-ruby (~> 1.0, >= 1.0.2)
4242
i18n (>= 0.7, < 2)
4343
minitest (~> 5.1)
@@ -52,7 +52,7 @@ GEM
5252
msgpack (~> 1.0)
5353
builder (3.2.3)
5454
byebug (10.0.2)
55-
capybara (3.10.1)
55+
capybara (3.12.0)
5656
addressable
5757
mini_mime (>= 0.1.3)
5858
nokogiri (~> 1.8)
@@ -68,8 +68,12 @@ GEM
6868
cloudflare-rails (0.4.0)
6969
httparty
7070
rails (~> 5.0)
71-
concurrent-ruby (1.1.2)
71+
concurrent-ruby (1.1.3)
72+
crack (0.4.3)
73+
safe_yaml (~> 1.0.0)
7274
crass (1.0.4)
75+
diff-lcs (1.3)
76+
docile (1.3.1)
7377
dotenv (2.5.0)
7478
dotenv-rails (2.5.0)
7579
dotenv (= 2.5.0)
@@ -79,13 +83,15 @@ GEM
7983
ffi (1.9.25)
8084
globalid (0.4.1)
8185
activesupport (>= 4.2.0)
86+
hashdiff (0.3.7)
8287
htmlentities (4.3.4)
8388
httparty (0.16.3)
8489
mime-types (~> 3.0)
8590
multi_xml (>= 0.5.2)
8691
i18n (1.1.1)
8792
concurrent-ruby (~> 1.0)
8893
io-like (0.3.0)
94+
json (2.1.0)
8995
listen (3.1.5)
9096
rb-fsevent (~> 0.9, >= 0.9.4)
9197
rb-inotify (~> 0.9, >= 0.9.7)
@@ -97,7 +103,7 @@ GEM
97103
mini_mime (>= 0.1.1)
98104
marcel (0.3.3)
99105
mimemagic (~> 0.3.2)
100-
method_source (0.9.1)
106+
method_source (0.9.2)
101107
mime-types (3.2.2)
102108
mime-types-data (~> 3.2015)
103109
mime-types-data (3.2018.0812)
@@ -118,38 +124,56 @@ GEM
118124
rack (>= 1.0, < 3)
119125
rack-test (1.1.0)
120126
rack (>= 1.0, < 3)
121-
rails (5.2.1)
122-
actioncable (= 5.2.1)
123-
actionmailer (= 5.2.1)
124-
actionpack (= 5.2.1)
125-
actionview (= 5.2.1)
126-
activejob (= 5.2.1)
127-
activemodel (= 5.2.1)
128-
activerecord (= 5.2.1)
129-
activestorage (= 5.2.1)
130-
activesupport (= 5.2.1)
127+
rails (5.2.1.1)
128+
actioncable (= 5.2.1.1)
129+
actionmailer (= 5.2.1.1)
130+
actionpack (= 5.2.1.1)
131+
actionview (= 5.2.1.1)
132+
activejob (= 5.2.1.1)
133+
activemodel (= 5.2.1.1)
134+
activerecord (= 5.2.1.1)
135+
activestorage (= 5.2.1.1)
136+
activesupport (= 5.2.1.1)
131137
bundler (>= 1.3.0)
132-
railties (= 5.2.1)
138+
railties (= 5.2.1.1)
133139
sprockets-rails (>= 2.0.0)
134140
rails-dom-testing (2.0.3)
135141
activesupport (>= 4.2.0)
136142
nokogiri (>= 1.6)
137143
rails-html-sanitizer (1.0.4)
138144
loofah (~> 2.2, >= 2.2.2)
139-
railties (5.2.1)
140-
actionpack (= 5.2.1)
141-
activesupport (= 5.2.1)
145+
railties (5.2.1.1)
146+
actionpack (= 5.2.1.1)
147+
activesupport (= 5.2.1.1)
142148
method_source
143149
rake (>= 0.8.7)
144150
thor (>= 0.19.0, < 2.0)
145151
rake (12.3.1)
146152
rb-fsevent (0.10.3)
147153
rb-inotify (0.9.10)
148154
ffi (>= 0.5.0, < 2)
149-
regexp_parser (1.2.0)
155+
regexp_parser (1.3.0)
156+
rspec-core (3.8.0)
157+
rspec-support (~> 3.8.0)
158+
rspec-expectations (3.8.2)
159+
diff-lcs (>= 1.2.0, < 2.0)
160+
rspec-support (~> 3.8.0)
161+
rspec-mocks (3.8.0)
162+
diff-lcs (>= 1.2.0, < 2.0)
163+
rspec-support (~> 3.8.0)
164+
rspec-rails (3.8.1)
165+
actionpack (>= 3.0)
166+
activesupport (>= 3.0)
167+
railties (>= 3.0)
168+
rspec-core (~> 3.8.0)
169+
rspec-expectations (~> 3.8.0)
170+
rspec-mocks (~> 3.8.0)
171+
rspec-support (~> 3.8.0)
172+
rspec-support (3.8.0)
150173
ruby_dep (1.5.0)
151174
rubyzip (1.2.2)
152-
sass (3.6.0)
175+
safe_yaml (1.0.4)
176+
sass (3.7.2)
153177
sass-listen (~> 4.0.0)
154178
sass-listen (4.0.0)
155179
rb-fsevent (~> 0.9, >= 0.9.4)
@@ -163,6 +187,13 @@ GEM
163187
selenium-webdriver (3.141.0)
164188
childprocess (~> 0.5)
165189
rubyzip (~> 1.2, >= 1.2.2)
190+
shoulda-matchers (3.1.2)
191+
activesupport (>= 4.0.0)
192+
simplecov (0.16.1)
193+
docile (~> 1.1)
194+
json (>= 1.8, < 3)
195+
simplecov-html (~> 0.10.0)
196+
simplecov-html (0.10.2)
166197
spring (2.0.2)
167198
activesupport (>= 4.2)
168199
spring-watcher-listen (2.0.1)
@@ -175,21 +206,25 @@ GEM
175206
actionpack (>= 4.0)
176207
activesupport (>= 4.0)
177208
sprockets (>= 3.0.0)
178-
thor (0.20.0)
209+
thor (0.20.3)
179210
thread_safe (0.3.6)
180-
tilt (2.0.8)
211+
tilt (2.0.9)
181212
turbolinks (5.2.0)
182213
turbolinks-source (~> 5.2)
183214
turbolinks-source (5.2.0)
184215
tzinfo (1.2.5)
185216
thread_safe (~> 0.1)
186-
uglifier (4.1.19)
217+
uglifier (4.1.20)
187218
execjs (>= 0.3.0, < 3)
188219
web-console (3.7.0)
189220
actionview (>= 5.0)
190221
activemodel (>= 5.0)
191222
bindex (>= 0.4.0)
192223
railties (>= 5.0)
224+
webmock (3.4.2)
225+
addressable (>= 2.3.6)
226+
crack (>= 0.3.2)
227+
hashdiff
193228
websocket-driver (0.7.0)
194229
websocket-extensions (>= 0.1.0)
195230
websocket-extensions (0.1.3)
@@ -213,14 +248,18 @@ DEPENDENCIES
213248
puma (~> 3.11)
214249
rack-attack (~> 5.4.2)
215250
rails (~> 5.2.1)
251+
rspec-rails (~> 3.8)
216252
sass-rails (~> 5.0)
217253
selenium-webdriver
254+
shoulda-matchers (~> 3.1)
255+
simplecov
218256
spring
219257
spring-watcher-listen (~> 2.0.0)
220258
turbolinks (~> 5)
221259
tzinfo-data
222260
uglifier (>= 1.3.0)
223261
web-console (>= 3.3.0)
262+
webmock
224263

225264
RUBY VERSION
226265
ruby 2.5.3p105

bin/bundle

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,105 @@
11
#!/usr/bin/env ruby
2-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3-
load Gem.bin_path('bundler', 'bundle')
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'bundle' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
require "rubygems"
12+
13+
m = Module.new do
14+
module_function
15+
16+
def invoked_as_script?
17+
File.expand_path($0) == File.expand_path(__FILE__)
18+
end
19+
20+
def env_var_version
21+
ENV["BUNDLER_VERSION"]
22+
end
23+
24+
def cli_arg_version
25+
return unless invoked_as_script? # don't want to hijack other binstubs
26+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27+
bundler_version = nil
28+
update_index = nil
29+
ARGV.each_with_index do |a, i|
30+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31+
bundler_version = a
32+
end
33+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34+
bundler_version = $1 || ">= 0.a"
35+
update_index = i
36+
end
37+
bundler_version
38+
end
39+
40+
def gemfile
41+
gemfile = ENV["BUNDLE_GEMFILE"]
42+
return gemfile if gemfile && !gemfile.empty?
43+
44+
File.expand_path("../../Gemfile", __FILE__)
45+
end
46+
47+
def lockfile
48+
lockfile =
49+
case File.basename(gemfile)
50+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51+
else "#{gemfile}.lock"
52+
end
53+
File.expand_path(lockfile)
54+
end
55+
56+
def lockfile_version
57+
return unless File.file?(lockfile)
58+
lockfile_contents = File.read(lockfile)
59+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60+
Regexp.last_match(1)
61+
end
62+
63+
def bundler_version
64+
@bundler_version ||= begin
65+
env_var_version || cli_arg_version ||
66+
lockfile_version || "#{Gem::Requirement.default}.a"
67+
end
68+
end
69+
70+
def load_bundler!
71+
ENV["BUNDLE_GEMFILE"] ||= gemfile
72+
73+
# must dup string for RG < 1.8 compatibility
74+
activate_bundler(bundler_version.dup)
75+
end
76+
77+
def activate_bundler(bundler_version)
78+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79+
bundler_version = "< 2"
80+
end
81+
gem_error = activation_error_handling do
82+
gem "bundler", bundler_version
83+
end
84+
return if gem_error.nil?
85+
require_error = activation_error_handling do
86+
require "bundler/version"
87+
end
88+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
90+
exit 42
91+
end
92+
93+
def activation_error_handling
94+
yield
95+
nil
96+
rescue StandardError, LoadError => e
97+
e
98+
end
99+
end
100+
101+
m.load_bundler!
102+
103+
if m.invoked_as_script?
104+
load Gem.bin_path("bundler", "bundle")
105+
end

0 commit comments

Comments
 (0)