From e928edfb32733ba08e512b056b6dd47dc0990145 Mon Sep 17 00:00:00 2001 From: Austin Kabiru Date: Fri, 4 Jan 2019 16:08:46 +0300 Subject: [PATCH] chore(workflow): Add test runner for dev --- Gemfile.lock | 31 +++++++++++++++++++++ Guardfile | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ fakerbot.gemspec | 1 + 3 files changed, 102 insertions(+) create mode 100644 Guardfile diff --git a/Gemfile.lock b/Gemfile.lock index 93d562e..369bd40 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,17 +27,42 @@ GEM equatable (0.5.0) faker (1.9.1) i18n (>= 0.7) + ffi (1.9.25) + formatador (0.2.5) + guard (2.15.0) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (>= 1.0.12, < 2.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-rspec (4.7.3) + guard (~> 2.1) + guard-compat (~> 1.1) + rspec (>= 2.99.0, < 4.0) http-cookie (1.0.3) domain_name (~> 0.5) i18n (1.1.0) concurrent-ruby (~> 1.0) json (2.1.0) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + lumberjack (1.0.13) method_source (0.9.0) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) multi_json (1.13.1) + nenv (0.3.0) netrc (0.11.0) + notiffany (0.1.1) + nenv (~> 0.1) + shellany (~> 0.0) pastel (0.7.2) equatable (~> 0.5.0) tty-color (~> 0.4.0) @@ -45,6 +70,9 @@ GEM coderay (~> 1.1.0) method_source (~> 0.9.0) rake (10.5.0) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) rest-client (2.0.2) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) @@ -62,6 +90,8 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) rspec-support (3.7.1) + ruby_dep (1.5.0) + shellany (0.0.1) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -97,6 +127,7 @@ DEPENDENCIES bundler (~> 1.16) coveralls fakerbot! + guard-rspec pry rake (~> 10.0) rspec (~> 3.0) diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..23074cd --- /dev/null +++ b/Guardfile @@ -0,0 +1,70 @@ +# 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 diff --git a/fakerbot.gemspec b/fakerbot.gemspec index b7ada0e..223b129 100644 --- a/fakerbot.gemspec +++ b/fakerbot.gemspec @@ -28,6 +28,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", "~> 1.16" spec.add_development_dependency "coveralls" + spec.add_development_dependency "guard-rspec" spec.add_development_dependency "pry" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "~> 3.0"