2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-11-01 18:57:50 -04:00
|
|
|
module Autospec
|
|
|
|
|
|
|
|
class RspecRunner < BaseRunner
|
|
|
|
|
|
|
|
WATCHERS = {}
|
2018-12-03 22:48:13 -05:00
|
|
|
def self.watch(pattern, &blk)
|
|
|
|
WATCHERS[pattern] = blk
|
|
|
|
end
|
|
|
|
def watchers
|
|
|
|
WATCHERS
|
|
|
|
end
|
2013-11-01 18:57:50 -04:00
|
|
|
|
|
|
|
# Discourse specific
|
|
|
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/components/#{m[1]}_spec.rb" }
|
|
|
|
|
|
|
|
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
|
|
|
watch(%r{^app/(.+)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
|
|
|
watch(%r{^spec/.+_spec\.rb$})
|
|
|
|
watch(%r{^spec/support/.+\.rb$}) { "spec" }
|
2018-08-22 00:35:57 -04:00
|
|
|
watch("app/controllers/application_controller.rb") { "spec/requests" }
|
|
|
|
|
|
|
|
watch(%r{app/controllers/(.+).rb}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
2013-11-01 18:57:50 -04:00
|
|
|
|
|
|
|
watch(%r{^app/views/(.+)/.+\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
|
|
|
|
|
|
|
watch(%r{^spec/fabricators/.+_fabricator\.rb$}) { "spec" }
|
|
|
|
|
2017-07-27 21:20:09 -04:00
|
|
|
watch(%r{^app/assets/javascripts/pretty-text/.*\.js\.es6$}) { "spec/components/pretty_text_spec.rb" }
|
|
|
|
watch(%r{^plugins/.*/discourse-markdown/.*\.js\.es6$}) { "spec/components/pretty_text_spec.rb" }
|
2017-06-08 18:02:30 -04:00
|
|
|
|
|
|
|
watch(%r{^plugins/.*/spec/.*\.rb})
|
2018-05-21 01:19:10 -04:00
|
|
|
watch(%r{^(plugins/.*/)plugin\.rb}) { |m| "#{m[1]}spec" }
|
2018-05-08 22:32:48 -04:00
|
|
|
watch(%r{^(plugins/.*)/(lib|app)}) { |m| "#{m[1]}/spec/integration" }
|
2017-10-22 19:24:07 -04:00
|
|
|
watch(%r{^(plugins/.*)/lib/(.*)\.rb}) { |m| "#{m[1]}/spec/lib/#{m[2]}_spec.rb" }
|
2017-06-08 18:02:30 -04:00
|
|
|
|
2013-11-01 18:57:50 -04:00
|
|
|
RELOADERS = Set.new
|
2018-12-03 22:48:13 -05:00
|
|
|
def self.reload(pattern)
|
|
|
|
RELOADERS << pattern
|
|
|
|
end
|
|
|
|
def reloaders
|
|
|
|
RELOADERS
|
|
|
|
end
|
2013-11-01 18:57:50 -04:00
|
|
|
|
2017-10-06 01:20:01 -04:00
|
|
|
# we are using a simple runner at the moment, whole idea of using a reloader is no longer needed
|
|
|
|
watch("spec/rails_helper.rb")
|
|
|
|
watch(%r{config/.+\.rb})
|
|
|
|
#reload(%r{app/helpers/.+\.rb})
|
2013-11-01 18:57:50 -04:00
|
|
|
|
|
|
|
def failed_specs
|
|
|
|
specs = []
|
|
|
|
path = './tmp/rspec_result'
|
|
|
|
specs = File.readlines(path) if File.exist?(path)
|
|
|
|
specs
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|