mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 17:40:43 +08:00
add qunit to autospec
This commit is contained in:
43
lib/autospec/rspec_runner.rb
Normal file
43
lib/autospec/rspec_runner.rb
Normal file
@ -0,0 +1,43 @@
|
||||
module Autospec
|
||||
|
||||
class RspecRunner < BaseRunner
|
||||
|
||||
WATCHERS = {}
|
||||
def self.watch(pattern, &blk); WATCHERS[pattern] = blk; end
|
||||
def watchers; WATCHERS; end
|
||||
|
||||
# Discourse specific
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/components/#{m[1]}_spec.rb" }
|
||||
|
||||
# Rails example
|
||||
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" }
|
||||
watch("app/controllers/application_controller.rb") { "spec/controllers" }
|
||||
|
||||
# Capybara request specs
|
||||
watch(%r{^app/views/(.+)/.+\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
||||
|
||||
# Fabrication
|
||||
watch(%r{^spec/fabricators/.+_fabricator\.rb$}) { "spec" }
|
||||
|
||||
RELOADERS = Set.new
|
||||
def self.reload(pattern); RELOADERS << pattern; end
|
||||
def reloaders; RELOADERS; end
|
||||
|
||||
# We need to reload the whole app when changing any of these files
|
||||
reload('spec/spec_helper.rb')
|
||||
reload('config/(.*).rb')
|
||||
reload('app/helpers/(.*).rb')
|
||||
|
||||
def failed_specs
|
||||
specs = []
|
||||
path = './tmp/rspec_result'
|
||||
specs = File.readlines(path) if File.exist?(path)
|
||||
specs
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user