Skip to content

Commit 18bbebe

Browse files
committed
Added guard
1 parent 7ee1f21 commit 18bbebe

File tree

5 files changed

+139
-10
lines changed

5 files changed

+139
-10
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
/public/assets
1212
/tags
1313
/tmp/*
14+
coverage

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ group :development do
2626
gem "spring"
2727
gem "spring-commands-rspec"
2828
gem "web-console"
29+
gem 'guard-rspec', require: false
30+
gem 'terminal-notifier-guard'
31+
gem 'guard-rails', require: false
2932
end
3033

3134
group :development, :test do

Gemfile.lock

+32
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,30 @@ GEM
9595
railties (>= 3.0.0)
9696
ffi (1.9.18)
9797
flutie (2.0.0)
98+
formatador (0.2.5)
9899
formulaic (0.4.0)
99100
activesupport
100101
capybara
101102
i18n
102103
globalid (0.3.7)
103104
activesupport (>= 4.1.0)
105+
guard (2.14.1)
106+
formatador (>= 0.2.4)
107+
listen (>= 2.7, < 4.0)
108+
lumberjack (~> 1.0)
109+
nenv (~> 0.1)
110+
notiffany (~> 0.0)
111+
pry (>= 0.9.12)
112+
shellany (~> 0.0)
113+
thor (>= 0.18.1)
114+
guard-compat (1.2.1)
115+
guard-rails (0.8.0)
116+
guard (~> 2.11)
117+
guard-compat (~> 1.0)
118+
guard-rspec (4.7.3)
119+
guard (~> 2.1)
120+
guard-compat (~> 1.1)
121+
rspec (>= 2.99.0, < 4.0)
104122
hashdiff (0.3.2)
105123
high_voltage (3.0.0)
106124
i18n (0.8.1)
@@ -117,6 +135,7 @@ GEM
117135
ruby_dep (~> 1.2)
118136
loofah (2.0.3)
119137
nokogiri (>= 1.5.9)
138+
lumberjack (1.0.11)
120139
mail (2.6.4)
121140
mime-types (>= 1.16, < 4)
122141
method_source (0.8.2)
@@ -128,10 +147,14 @@ GEM
128147
neat (2.0.0)
129148
sass (~> 3.4)
130149
thor (~> 0.19)
150+
nenv (0.3.0)
131151
nio4r (2.0.0)
132152
nokogiri (1.7.1)
133153
mini_portile2 (~> 2.1.0)
134154
normalize-rails (3.0.3)
155+
notiffany (0.1.1)
156+
nenv (~> 0.1)
157+
shellany (~> 0.0)
135158
pg (0.20.0)
136159
pry (0.10.4)
137160
coderay (~> 1.1.0)
@@ -183,6 +206,10 @@ GEM
183206
recipient_interceptor (0.1.2)
184207
mail
185208
refills (0.2.0)
209+
rspec (3.5.0)
210+
rspec-core (~> 3.5.0)
211+
rspec-expectations (~> 3.5.0)
212+
rspec-mocks (~> 3.5.0)
186213
rspec-core (3.5.4)
187214
rspec-support (~> 3.5.0)
188215
rspec-expectations (3.5.0)
@@ -209,6 +236,7 @@ GEM
209236
sprockets (>= 2.8, < 4.0)
210237
sprockets-rails (>= 2.0, < 4.0)
211238
tilt (>= 1.1, < 3)
239+
shellany (0.0.1)
212240
shoulda-matchers (3.1.1)
213241
activesupport (>= 4.0.0)
214242
simple_form (3.4.0)
@@ -237,6 +265,7 @@ GEM
237265
bitters (~> 1.5)
238266
bundler (~> 1.3)
239267
rails (~> 5.0.0)
268+
terminal-notifier-guard (1.7.0)
240269
thor (0.19.4)
241270
thread_safe (0.3.6)
242271
tilt (2.0.7)
@@ -280,6 +309,8 @@ DEPENDENCIES
280309
factory_girl_rails
281310
flutie
282311
formulaic
312+
guard-rails
313+
guard-rspec
283314
high_voltage
284315
jquery-rails
285316
launchy
@@ -306,6 +337,7 @@ DEPENDENCIES
306337
spring-commands-rspec
307338
sprockets (>= 3.0.0)
308339
suspenders
340+
terminal-notifier-guard
309341
timecop
310342
title
311343
uglifier

Guardfile

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# A sample Guardfile
2+
# More info at https://github.com/guard/guard#readme
3+
4+
## Uncomment and set this to only include directories you want to watch
5+
# directories %w(app lib config test spec features) \
6+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7+
8+
## Note: if you are using the `directories` clause above and you are not
9+
## watching the project directory ('.'), then you will want to move
10+
## the Guardfile to a watched dir and symlink it back, e.g.
11+
#
12+
# $ mkdir config
13+
# $ mv Guardfile config/
14+
# $ ln -s config/Guardfile .
15+
#
16+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17+
18+
# Note: The cmd option is now required due to the increasing number of ways
19+
# rspec may be run, below are examples of the most common uses.
20+
# * bundler: 'bundle exec rspec'
21+
# * bundler binstubs: 'bin/rspec'
22+
# * spring: 'bin/rspec' (This will use spring if running and you have
23+
# installed the spring binstubs per the docs)
24+
# * zeus: 'zeus rspec' (requires the server to be started separately)
25+
# * 'just' rspec: 'rspec'
26+
notification :terminal_notifier
27+
guard :rspec, cmd: "bundle exec rspec" do
28+
require "guard/rspec/dsl"
29+
dsl = Guard::RSpec::Dsl.new(self)
30+
31+
# Feel free to open issues for suggestions and improvements
32+
33+
# RSpec files
34+
rspec = dsl.rspec
35+
watch(rspec.spec_helper) { rspec.spec_dir }
36+
watch(rspec.spec_support) { rspec.spec_dir }
37+
watch(rspec.spec_files)
38+
39+
# Ruby files
40+
ruby = dsl.ruby
41+
dsl.watch_spec_files_for(ruby.lib_files)
42+
43+
# Rails files
44+
rails = dsl.rails(view_extensions: %w(erb haml slim))
45+
dsl.watch_spec_files_for(rails.app_files)
46+
dsl.watch_spec_files_for(rails.views)
47+
48+
watch(rails.controllers) do |m|
49+
[
50+
rspec.spec.call("routing/#{m[1]}_routing"),
51+
rspec.spec.call("controllers/#{m[1]}_controller"),
52+
rspec.spec.call("acceptance/#{m[1]}")
53+
]
54+
end
55+
56+
# Rails config changes
57+
watch(rails.spec_helper) { rspec.spec_dir }
58+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60+
61+
# Capybara features specs
62+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64+
65+
# Turnip features and steps
66+
watch(%r{^spec/acceptance/(.+)\.feature$})
67+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69+
end
70+
end
71+
72+
# Guard-Rails supports a lot options with default values:
73+
# daemon: false # runs the server as a daemon.
74+
# debugger: false # enable ruby-debug gem.
75+
# environment: 'development' # changes server environment.
76+
# force_run: false # kills any process that's holding the listen port before attempting to (re)start Rails.
77+
# pid_file: 'tmp/pids/[RAILS_ENV].pid' # specify your pid_file.
78+
# host: 'localhost' # server hostname.
79+
# port: 3000 # server port number.
80+
# root: '/spec/dummy' # Rails' root path.
81+
# server: thin # webserver engine.
82+
# start_on_start: true # will start the server when starting Guard.
83+
# timeout: 30 # waits untill restarting the Rails server, in seconds.
84+
# zeus_plan: server # custom plan in zeus, only works with `zeus: true`.
85+
# zeus: false # enables zeus gem.
86+
# CLI: 'rails server' # customizes runner command. Omits all options except `pid_file`!
87+
88+
guard 'rails' do
89+
watch('Gemfile.lock')
90+
watch(%r{^(config|lib)/.*})
91+
end

spec/spec_helper.rb

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
if ENV.fetch("COVERAGE", false)
2-
require "simplecov"
3-
4-
if ENV["CIRCLE_ARTIFACTS"]
5-
dir = File.join(ENV["CIRCLE_ARTIFACTS"], "coverage")
6-
SimpleCov.coverage_dir(dir)
7-
end
8-
9-
SimpleCov.start "rails"
10-
end
1+
#if ENV.fetch("COVERAGE", false)
2+
# require "simplecov"
3+
#
4+
# if ENV["CIRCLE_ARTIFACTS"]
5+
# dir = File.join(ENV["CIRCLE_ARTIFACTS"], "coverage")
6+
# SimpleCov.coverage_dir(dir)
7+
# end
8+
#
9+
# SimpleCov.start "rails"
10+
#end
11+
require "simplecov"
12+
SimpleCov.start "rails"
1113

1214
require "webmock/rspec"
1315

0 commit comments

Comments
 (0)