rspactor 0.7.0.beta.3 → 0.7.0.beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +4 -5
- data/bin/inotify_watch +3 -5
- data/bin/rspactor +3 -0
- data/lib/formatters/rspec_formatter.rb +28 -0
- data/lib/formatters/rspec_one_formatter.rb +15 -0
- data/lib/formatters/rspec_two_formatter.rb +26 -0
- data/lib/rspactor/notifier.rb +23 -0
- data/lib/rspactor/runner.rb +43 -13
- data/lib/rspactor/version.rb +1 -1
- data/lib/rspactor.rb +1 -1
- metadata +8 -7
- data/lib/formatters/rspec2/growl_formatter.rb +0 -11
- data/lib/formatters/rspec2/libnotify_formatter.rb +0 -11
- data/lib/formatters/rspec2_formatter.rb +0 -40
data/README.rdoc
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
= RSpactor
|
|
2
2
|
|
|
3
3
|
RSpactor allows to automatically & intelligently launch your specs when your files are modified.
|
|
4
|
-
Version 0.7.x is a complete rewrite, RubyCocoa is no more needed, FSEvents are supported from scratch.
|
|
4
|
+
Version 0.7.x is a complete rewrite, RubyCocoa is no more needed, FSEvents & Inotify are supported from scratch.
|
|
5
5
|
|
|
6
6
|
== Features
|
|
7
7
|
|
|
8
8
|
- FSEvent support on Mac OS X (without RubyCocoa!)
|
|
9
9
|
- Inotify support on Linux
|
|
10
|
-
- RSpec 2.
|
|
10
|
+
- RSpec 1.x & 2.x (from beta.14) support
|
|
11
11
|
- Bundler support
|
|
12
12
|
- Super fast change detection
|
|
13
13
|
- Automatic _spec.rb files detection (even new file created, unlike watchr)
|
|
@@ -16,7 +16,7 @@ Version 0.7.x is a complete rewrite, RubyCocoa is no more needed, FSEvents are s
|
|
|
16
16
|
|
|
17
17
|
== Install
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Only Mac OS X (10.5+) & Linux are supported. Tested on Ruby 1.8.7 & 1.9.2dev.
|
|
20
20
|
|
|
21
21
|
Install the gem:
|
|
22
22
|
|
|
@@ -39,11 +39,10 @@ Options list is available with:
|
|
|
39
39
|
Signal handlers are now used to interact with RSpactor:
|
|
40
40
|
|
|
41
41
|
- Ctrl-C - Quit RSpactor or quick abort running spec(s)
|
|
42
|
-
- Ctrl-\
|
|
42
|
+
- Ctrl-\ - Running all specs
|
|
43
43
|
|
|
44
44
|
== TODO
|
|
45
45
|
|
|
46
|
-
- RSpec 1.3 support
|
|
47
46
|
- Specific files (spec_helper, factories, fixtures...) inspections
|
|
48
47
|
- Spork support (when {this issue}[http://github.com/timcharper/spork/issues#issue/37] will be resolved)
|
|
49
48
|
- {LiveReload}[http://github.com/mockko/livereload] support
|
data/bin/inotify_watch
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
2
|
require 'rubygems'
|
|
4
3
|
require 'rb-inotify'
|
|
5
4
|
|
|
@@ -15,13 +14,12 @@ end
|
|
|
15
14
|
|
|
16
15
|
while true do
|
|
17
16
|
notifier.process
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
if !folders.empty?
|
|
20
19
|
$stdout.puts folders.join(' ')
|
|
21
20
|
$stdout.flush
|
|
22
21
|
folders.clear
|
|
23
22
|
end
|
|
24
|
-
|
|
23
|
+
|
|
25
24
|
sleep(0.5)
|
|
26
|
-
end
|
|
27
|
-
|
|
25
|
+
end
|
data/bin/rspactor
CHANGED
|
@@ -7,6 +7,9 @@ options = Trollop::options do
|
|
|
7
7
|
version RSpactor::VERSION
|
|
8
8
|
|
|
9
9
|
opt :clear, "Clear the console beetween each spec(s) run"
|
|
10
|
+
opt :rspec_version, "Force RSpec Version (1 or 2), normally it should be automatically detected", :type => :int
|
|
10
11
|
end
|
|
11
12
|
|
|
13
|
+
Trollop::die :rspec_version, "not supported" unless [nil, 1, 2].include?(options[:rspec_version])
|
|
14
|
+
|
|
12
15
|
RSpactor.start(options)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module RSpecFormatter
|
|
2
|
+
|
|
3
|
+
def rspactor_title
|
|
4
|
+
"RSpec results"
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def rspactor_message(example_count, failure_count, pending_count, duration)
|
|
8
|
+
message = "#{example_count} examples, #{failure_count} failures"
|
|
9
|
+
if pending_count > 0
|
|
10
|
+
message << " (#{pending_count} pending)"
|
|
11
|
+
end
|
|
12
|
+
message << "\nin #{duration} seconds"
|
|
13
|
+
message
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# failed | pending | success
|
|
17
|
+
def rspactor_image_path(failure_count, pending_count)
|
|
18
|
+
icon = if failure_count > 0
|
|
19
|
+
'failed'
|
|
20
|
+
elsif pending_count > 0
|
|
21
|
+
'pending'
|
|
22
|
+
else
|
|
23
|
+
'success'
|
|
24
|
+
end
|
|
25
|
+
File.expand_path(File.dirname(__FILE__) + "/images/#{icon}.png")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'spec/runner/formatter/base_formatter'
|
|
2
|
+
require "#{File.dirname(__FILE__)}/rspec_formatter"
|
|
3
|
+
require "#{File.dirname(__FILE__)}/../rspactor/notifier"
|
|
4
|
+
|
|
5
|
+
class RSpecOneFormatter < Spec::Runner::Formatter::BaseFormatter
|
|
6
|
+
include RSpecFormatter
|
|
7
|
+
|
|
8
|
+
def dump_summary(duration, total, failures, pending)
|
|
9
|
+
message = rspactor_message(total, failures, pending, duration)
|
|
10
|
+
image_path = rspactor_image_path(failures, pending)
|
|
11
|
+
|
|
12
|
+
RSpactor::Notifier.notify(message, rspactor_title, image_path)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'rspec/core/formatters/base_formatter'
|
|
2
|
+
require "#{File.dirname(__FILE__)}/rspec_formatter"
|
|
3
|
+
require "#{File.dirname(__FILE__)}/../rspactor/notifier"
|
|
4
|
+
|
|
5
|
+
class RSpecTwoFormatter < RSpec::Core::Formatters::ProgressFormatter
|
|
6
|
+
include RSpecFormatter
|
|
7
|
+
|
|
8
|
+
def dump_summary
|
|
9
|
+
super
|
|
10
|
+
message = rspactor_message(@example_count, failure_count, pending_count, format_seconds(duration))
|
|
11
|
+
image_path = rspactor_image_path(failure_count, pending_count)
|
|
12
|
+
|
|
13
|
+
RSpactor::Notifier.notify(message, rspactor_title, image_path)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def failure_count
|
|
19
|
+
failed_examples.size
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def pending_count
|
|
23
|
+
pending_examples.size
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'sys/uname'
|
|
2
|
+
|
|
3
|
+
case Sys::Uname.sysname
|
|
4
|
+
when 'Darwin'
|
|
5
|
+
require 'growl'
|
|
6
|
+
when 'Linux'
|
|
7
|
+
require 'libnotify'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module RSpactor
|
|
11
|
+
module Notifier
|
|
12
|
+
|
|
13
|
+
def self.notify(message, title, image_path)
|
|
14
|
+
case Sys::Uname.sysname
|
|
15
|
+
when 'Darwin'
|
|
16
|
+
Growl.notify message, :title => title, :icon => image_path, :name => "RSpactor"
|
|
17
|
+
when 'Linux'
|
|
18
|
+
Libnotify.show :body => message, :summary => title, :icon_path => image_path
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/rspactor/runner.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module RSpactor
|
|
2
2
|
class Runner
|
|
3
|
-
attr_reader :pipe
|
|
3
|
+
attr_reader :pipe, :rspec_version
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
@rspec_version = RSpactor.options[:rspec_version] || determine_rspec_version
|
|
7
|
+
end
|
|
4
8
|
|
|
5
9
|
def start(options = {})
|
|
6
10
|
if options[:all]
|
|
@@ -25,29 +29,55 @@ module RSpactor
|
|
|
25
29
|
private
|
|
26
30
|
|
|
27
31
|
def run_rspec(command, message)
|
|
28
|
-
@pipe = IO.popen(command)
|
|
29
32
|
UI.info message, :reset => true, :clear => RSpactor.options[:clear]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
case rspec_version
|
|
34
|
+
when 1
|
|
35
|
+
# problem with color if launched via popen
|
|
36
|
+
system(command)
|
|
37
|
+
when 2
|
|
38
|
+
@pipe = IO.popen(command)
|
|
39
|
+
while pipe && !pipe.eof?
|
|
40
|
+
if pipe && char = pipe.read(32)
|
|
41
|
+
print char
|
|
42
|
+
$stdout.flush if pipe
|
|
43
|
+
end
|
|
34
44
|
end
|
|
45
|
+
@pipe = nil
|
|
35
46
|
end
|
|
36
|
-
@pipe = nil
|
|
37
47
|
end
|
|
38
48
|
|
|
39
49
|
def rspec_command(paths)
|
|
40
|
-
cmd_parts = [
|
|
41
|
-
cmd_parts
|
|
42
|
-
cmd_parts
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
cmd_parts = []
|
|
51
|
+
cmd_parts << (rspec_version == 1 ? "spec" : "rspec")
|
|
52
|
+
cmd_parts << "--color"
|
|
53
|
+
if growl_installed? || notify_installed?
|
|
54
|
+
case rspec_version
|
|
55
|
+
when 1
|
|
56
|
+
cmd_parts << "-f progress --require #{File.dirname(__FILE__)}/../formatters/rspec_one_formatter.rb --format RSpecOneFormatter:STDOUT"
|
|
57
|
+
when 2
|
|
58
|
+
cmd_parts << "--require #{File.dirname(__FILE__)}/../formatters/rspec_two_formatter.rb --format RSpecTwoFormatter"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
cmd_parts << paths.join(' ')
|
|
45
62
|
cmd_parts.unshift "bundle exec" if bundler?
|
|
46
63
|
cmd_parts.join(" ")
|
|
47
64
|
end
|
|
48
65
|
|
|
49
66
|
def bundler?
|
|
50
|
-
File.exist?("
|
|
67
|
+
File.exist?("#{Dir.pwd}/Gemfile")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def determine_rspec_version
|
|
71
|
+
UI.info "Determine rspec_version... (can be forced with -r <i> option)"
|
|
72
|
+
if bundler?
|
|
73
|
+
# Allow RSpactor to be tested with RSpactor (bundle show inside a bundle exec)
|
|
74
|
+
ENV['BUNDLE_GEMFILE'] = "#{Dir.pwd}/Gemfile"
|
|
75
|
+
`bundle show rspec`.include?("/rspec-1.") ? 1 : 2
|
|
76
|
+
elsif File.exist?("#{Dir.pwd}/spec/spec_helper.rb")
|
|
77
|
+
File.new("#{Dir.pwd}/spec/spec_helper.rb").read.include?("Spec::Runner") ? 1 : 2
|
|
78
|
+
else
|
|
79
|
+
2
|
|
80
|
+
end
|
|
51
81
|
end
|
|
52
82
|
|
|
53
83
|
def growl_installed?
|
data/lib/rspactor/version.rb
CHANGED
data/lib/rspactor.rb
CHANGED
|
@@ -18,7 +18,7 @@ module RSpactor
|
|
|
18
18
|
Inspector.determine_spec_paths(files)
|
|
19
19
|
runner.start if Inspector.spec_paths?
|
|
20
20
|
end
|
|
21
|
-
UI.info "RSpactor is now watching at '#{Dir.pwd}'"
|
|
21
|
+
UI.info "RSpactor is now watching at '#{Dir.pwd}' using RSpec #{runner.rspec_version}.x"
|
|
22
22
|
listener.start
|
|
23
23
|
end
|
|
24
24
|
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspactor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 62196443
|
|
5
5
|
prerelease: true
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 7
|
|
9
9
|
- 0
|
|
10
10
|
- beta
|
|
11
|
-
-
|
|
12
|
-
version: 0.7.0.beta.
|
|
11
|
+
- 4
|
|
12
|
+
version: 0.7.0.beta.4
|
|
13
13
|
platform: ruby
|
|
14
14
|
authors:
|
|
15
15
|
- Thibaud Guillaume-Gentil
|
|
@@ -17,7 +17,7 @@ autorequire:
|
|
|
17
17
|
bindir: bin
|
|
18
18
|
cert_chain: []
|
|
19
19
|
|
|
20
|
-
date: 2010-07-
|
|
20
|
+
date: 2010-07-14 00:00:00 +02:00
|
|
21
21
|
default_executable:
|
|
22
22
|
dependencies:
|
|
23
23
|
- !ruby/object:Gem::Dependency
|
|
@@ -113,12 +113,13 @@ files:
|
|
|
113
113
|
- lib/formatters/images/failed.png
|
|
114
114
|
- lib/formatters/images/pending.png
|
|
115
115
|
- lib/formatters/images/success.png
|
|
116
|
-
- lib/formatters/
|
|
117
|
-
- lib/formatters/
|
|
118
|
-
- lib/formatters/
|
|
116
|
+
- lib/formatters/rspec_formatter.rb
|
|
117
|
+
- lib/formatters/rspec_one_formatter.rb
|
|
118
|
+
- lib/formatters/rspec_two_formatter.rb
|
|
119
119
|
- lib/rspactor/inspector.rb
|
|
120
120
|
- lib/rspactor/interactor.rb
|
|
121
121
|
- lib/rspactor/listener.rb
|
|
122
|
+
- lib/rspactor/notifier.rb
|
|
122
123
|
- lib/rspactor/runner.rb
|
|
123
124
|
- lib/rspactor/ui.rb
|
|
124
125
|
- lib/rspactor/version.rb
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
require 'rspec/core/formatters/base_formatter'
|
|
2
|
-
|
|
3
|
-
class RSpec2Formatter < RSpec::Core::Formatters::ProgressFormatter
|
|
4
|
-
|
|
5
|
-
def rspactor_title
|
|
6
|
-
"RSpec results"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def rspactor_message
|
|
10
|
-
message = "#{@example_count} examples, #{failure_count} failures"
|
|
11
|
-
if pending_count > 0
|
|
12
|
-
message << " (#{pending_count} pending)"
|
|
13
|
-
end
|
|
14
|
-
message << "\nin #{format_seconds(duration)} seconds"
|
|
15
|
-
message
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# failed | pending | success
|
|
19
|
-
def rspactor_image_path
|
|
20
|
-
icon = if failure_count > 0
|
|
21
|
-
'failed'
|
|
22
|
-
elsif pending_count > 0
|
|
23
|
-
'pending'
|
|
24
|
-
else
|
|
25
|
-
'success'
|
|
26
|
-
end
|
|
27
|
-
File.expand_path(File.dirname(__FILE__) + "/images/#{icon}.png")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
def failure_count
|
|
33
|
-
failed_examples.size
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def pending_count
|
|
37
|
-
pending_examples.size
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|