Class: RailChaser::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RailChaser::Task
- Includes:
- Rake::DSL
- Defined in:
- lib/rail_chaser/task.rb
Instance Method Summary collapse
- #define(name) ⇒ Object
-
#initialize(name = :min) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(name = :min) ⇒ Task
Returns a new instance of Task.
9 10 11 |
# File 'lib/rail_chaser/task.rb', line 9 def initialize(name = :min) define(name) end |
Instance Method Details
#define(name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rail_chaser/task.rb', line 13 def define(name) desc 'Runs minimum set of specs' namespace :spec do task name do diff_files = `git diff HEAD --name-only`.split("\n") # ToDo: possibly add new spec files to specs # new_files = `git ls-files --exclude-standard --others`.split("\n") # new_files.select { |file| file =~ /(\/spec\/(.*)?)?\_spec\.rb/ } storage = RailChaser::Storage.new storage.load! puts "# Changed files:\n" specs = [] diff_files.each do |file| puts "# - #{file}" specs << storage.find_specs_by_class(file) end puts "#\n# Specs to run:\n" specs = specs.flatten.compact.uniq specs.each do |spec| puts "# - #{spec}" end unless specs.empty? rspec_command = "rspec #{specs.join(' ')}" result = `#{rspec_command}` puts "\n#{result}" end end end end |