Class: Guard::JRubyRSpec
- Inherits:
-
RSpec
- Object
- RSpec
- Guard::JRubyRSpec
show all
- Defined in:
- lib/guard/jruby-rspec.rb,
lib/guard/jruby-rspec/runner.rb,
lib/guard/jruby-rspec/inspector.rb,
lib/guard/jruby-rspec/containment.rb
Defined Under Namespace
Classes: Containment, Inspector, Runner
Instance Method Summary
collapse
Constructor Details
#initialize(watchers = [], options = {}) ⇒ JRubyRSpec
Returns a new instance of JRubyRSpec.
11
12
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
47
|
# File 'lib/guard/jruby-rspec.rb', line 11
def initialize(watchers = [], options = {})
@options = {
:all_after_pass => true,
:all_on_start => true,
:keep_failed => true,
:spec_paths => ["spec"],
:spec_file_suffix => "_spec.rb",
:run_all => {},
:monitor_file => ".guard-jruby-rspec",
:custom_reloaders => []
}.merge(options)
@last_failed = false
@failed_paths = []
default_watchers = [Watcher.new(@monitor)]
if @custom_watchers.nil? or @custom_watchers.empty?
default_watchers <<
Watcher.new(%r{^(.+)\.rb$}) <<
Watcher.new(%r{^(.+)\.(erb|haml)$})
else
watchers.each do |w|
default_watchers << Watcher.new(w.pattern)
end
end
@custom_watchers = watchers
super(default_watchers, @options)
@inspector = Inspector.new(@options)
@runner = Runner.new(@options)
@reloaders = set_up_reloaders(@options)
end
|
Instance Method Details
#reload_paths(paths) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/guard/jruby-rspec.rb', line 87
def reload_paths(paths)
paths.reject {|p| p.end_with?(@options[:spec_file_suffix])}.each do |p|
if File.exists?(p)
if p == @options[:monitor_file]
else
Containment.new.protect do
load p
end
end
end
end
end
|
#reload_rails ⇒ Object
80
81
82
83
84
85
|
# File 'lib/guard/jruby-rspec.rb', line 80
def reload_rails(*)
if defined? ::ActionDispatch::Reloader
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
end
end
|
#run_all ⇒ Object
55
56
57
58
|
# File 'lib/guard/jruby-rspec.rb', line 55
def run_all
unload_previous_examples
super
end
|
#run_on_changes(raw_paths) ⇒ Object
Also known as:
run_on_change
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/guard/jruby-rspec.rb', line 60
def run_on_changes(raw_paths)
unload_previous_examples
@reloaders.reload(raw_paths)
unless @custom_watchers.nil? or @custom_watchers.empty?
paths = []
raw_paths.each do |p|
@custom_watchers.each do |w|
if (m = w.match(p))
paths << (w.action.nil? ? p : w.call_action(m))
end
end
end
super(paths.flatten)
end
end
|
#start ⇒ Object
Call once when guard starts
50
51
52
53
|
# File 'lib/guard/jruby-rspec.rb', line 50
def start
UI.info "Guard::JRuby::RSpec is running, with RSpec!"
run_all if @options[:all_on_start]
end
|