diff --git a/Gemfile b/Gemfile index 8bb13797..11228171 100644 --- a/Gemfile +++ b/Gemfile @@ -64,11 +64,11 @@ gem 'standard_deviation' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platform: :mri - gem 'debug', platforms: %i[mri mingw x64_mingw] gem 'factory_bot_rails' gem 'parallel_tests' gem 'rack-mini-profiler' gem 'rspec-rails', '~> 5.1.0' + gem 'debug', platforms: %i[mri mingw x64_mingw] end group :development do @@ -77,6 +77,10 @@ group :development do gem 'bullet' gem 'erb_lint', require: false gem 'erblint-github' + gem 'guard' + gem 'guard-rspec', require: false + gem 'guard-livereload', '~> 2.5', require: false + gem 'rack-livereload' gem 'listen', '~> 3.0.5' gem 'nested_scaffold' # gem 'reek', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 5ba33287..7f14beff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -109,6 +109,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + coderay (1.1.3) concurrent-ruby (1.2.2) crass (1.0.6) cssbundling-rails (1.1.2) @@ -133,6 +134,9 @@ GEM docile (1.4.0) e2mmap (0.1.0) ed25519 (1.3.0) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0) erb_lint (0.3.1) activesupport better_html (>= 2.0.1) @@ -142,6 +146,7 @@ GEM smart_properties erblint-github (0.1.3) erubi (1.12.0) + eventmachine (1.2.7) execjs (2.8.1) factory_bot (6.2.1) activesupport (>= 5.0.0) @@ -149,19 +154,40 @@ GEM factory_bot (~> 6.2.0) railties (>= 5.0.0) ffi (1.15.5) + formatador (1.1.0) friendly_id (5.1.0) activerecord (>= 4.0.0) globalid (1.1.0) activesupport (>= 5.0) + guard (2.18.0) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (>= 1.0.12, < 2.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.13.0) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-livereload (2.5.2) + em-websocket (~> 0.5) + guard (~> 2.8) + guard-compat (~> 1.0) + multi_json (~> 1.8) + guard-rspec (4.7.3) + guard (~> 2.1) + guard-compat (~> 1.1) + rspec (>= 2.99.0, < 4.0) haml (6.1.1) temple (>= 0.8.2) thor tilt hashie (5.0.0) + http_parser.rb (0.8.0) i18n (1.12.0) concurrent-ruby (~> 1.0) io-console (0.6.0) - irb (1.6.3) + irb (1.6.4) reline (>= 0.3.0) jaro_winkler (1.5.4) jbuilder (2.11.5) @@ -188,6 +214,7 @@ GEM loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) + lumberjack (1.2.8) mail (2.8.1) mini_mime (>= 0.1.1) net-imap @@ -200,6 +227,7 @@ GEM minitest (5.18.0) msgpack (1.6.1) multi_json (1.15.0) + nenv (0.3.0) nested_scaffold (1.1.0) net-imap (0.3.4) date @@ -217,6 +245,9 @@ GEM nio4r (2.5.8) nokogiri (1.14.2-x86_64-linux) racc (~> 1.4) + notiffany (0.1.3) + nenv (~> 0.1) + shellany (~> 0.0) omniauth (2.1.1) hashie (>= 3.4.6) rack (>= 2.2.3) @@ -228,11 +259,16 @@ GEM parser (3.2.1.1) ast (~> 2.4.1) pg (1.4.6) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) public_suffix (5.0.1) puma (6.1.1) nio4r (~> 2.0) racc (1.6.2) rack (2.2.6.4) + rack-livereload (0.3.17) + rack rack-mini-profiler (3.0.0) rack (>= 1.2.0) rack-protection (3.0.5) @@ -288,6 +324,10 @@ GEM reverse_markdown (2.1.1) nokogiri rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) rspec-core (3.12.1) rspec-support (~> 3.12.0) rspec-expectations (3.12.2) @@ -326,6 +366,7 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + shellany (0.0.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -423,6 +464,9 @@ DEPENDENCIES erblint-github factory_bot_rails friendly_id (~> 5.1.0) + guard + guard-livereload (~> 2.5) + guard-rspec haml jbuilder (~> 2.5) jquery-rails @@ -437,6 +481,7 @@ DEPENDENCIES parallel_tests pg puma (>= 5.6.4) + rack-livereload rack-mini-profiler rails (~> 7.0.4) rails-controller-testing diff --git a/Guardfile b/Guardfile new file mode 100644 index 00000000..389b123d --- /dev/null +++ b/Guardfile @@ -0,0 +1,109 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +## Uncomment and set this to only include directories you want to watch +# directories %w(app lib config test spec features) \ +# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")} + +## Note: if you are using the `directories` clause above and you are not +## watching the project directory ('.'), then you will want to move +## the Guardfile to a watched dir and symlink it back, e.g. +# +# $ mkdir config +# $ mv Guardfile config/ +# $ ln -s config/Guardfile . +# +# and, you'll have to watch "config/Guardfile" instead of "Guardfile" + +# Note: The cmd option is now required due to the increasing number of ways +# rspec may be run, below are examples of the most common uses. +# * bundler: 'bundle exec rspec' +# * bundler binstubs: 'bin/rspec' +# * spring: 'bin/rspec' (This will use spring if running and you have +# installed the spring binstubs per the docs) +# * zeus: 'zeus rspec' (requires the server to be started separately) +# * 'just' rspec: 'rspec' + +guard :rspec, cmd: "bundle exec rspec" do + require "guard/rspec/dsl" + dsl = Guard::RSpec::Dsl.new(self) + + # Feel free to open issues for suggestions and improvements + + # RSpec files + rspec = dsl.rspec + watch(rspec.spec_helper) { rspec.spec_dir } + watch(rspec.spec_support) { rspec.spec_dir } + watch(rspec.spec_files) + + # Ruby files + ruby = dsl.ruby + dsl.watch_spec_files_for(ruby.lib_files) + + # Rails files + rails = dsl.rails(view_extensions: %w(erb haml slim)) + dsl.watch_spec_files_for(rails.app_files) + dsl.watch_spec_files_for(rails.views) + + watch(rails.controllers) do |m| + [ + rspec.spec.call("routing/#{m[1]}_routing"), + rspec.spec.call("controllers/#{m[1]}_controller"), + rspec.spec.call("acceptance/#{m[1]}") + ] + end + + # Rails config changes + watch(rails.spec_helper) { rspec.spec_dir } + watch(rails.routes) { "#{rspec.spec_dir}/routing" } + watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" } + + # Capybara features specs + watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") } + watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m| + Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance" + end +end + +guard 'livereload' do + extensions = { + css: :css, + scss: :css, + sass: :css, + js: :js, + coffee: :js, + html: :html, + png: :png, + gif: :gif, + jpg: :jpg, + jpeg: :jpeg, + # less: :less, # uncomment if you want LESS stylesheets done in browser + } + + rails_view_exts = %w(erb haml slim) + + # file types LiveReload may optimize refresh for + compiled_exts = extensions.values.uniq + watch(%r{public/.+\.(#{compiled_exts * '|'})}) + + extensions.each do |ext, type| + watch(%r{ + (?:app|vendor) + (?:/assets/\w+/(?[^.]+) # path+base without extension + (?\.#{ext})) # matching extension (must be first encountered) + (?:\.\w+|$) # other extensions + }x) do |m| + path = m[1] + "/assets/#{path}.#{type}" + end + end + + # file needing a full reload of the page anyway + watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$}) + watch(%r{app/helpers/.+\.rb}) + watch(%r{config/locales/.+\.yml}) +end diff --git a/config/environments/development.rb b/config/environments/development.rb index a73fd411..6e5dc553 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,12 +1,12 @@ Rails.application.configure do config.after_initialize do - Bullet.enable = true - Bullet.alert = false + Bullet.enable = true + Bullet.alert = false Bullet.bullet_logger = true - Bullet.console = true + Bullet.console = true # Bullet.growl = true - Bullet.rails_logger = true - Bullet.add_footer = true + Bullet.rails_logger = true + Bullet.add_footer = true end # Settings specified here will take precedence over those in config/application.rb. @@ -71,4 +71,6 @@ Rails.application.configure do config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.action_controller.include_all_helpers = false + + config.middleware.insert_before Rack::Runtime, Rack::LiveReload end