uberspec 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/.rvmrc +1 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/img/failed.png +0 -0
- data/img/other.png +0 -0
- data/img/passed.png +0 -0
- data/img/pending.png +0 -0
- data/lib/uberspec/config.rb +57 -0
- data/lib/uberspec/notify/growl.rb +23 -0
- data/lib/uberspec/notify/lib_notify.rb +23 -0
- data/lib/uberspec/notify.rb +50 -0
- data/lib/uberspec/parallel.rb +36 -0
- data/lib/uberspec/rspec.rb +27 -0
- data/lib/uberspec.rb +121 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/uberspec/config_spec.rb +27 -0
- data/spec/uberspec/notify/growl_spec.rb +21 -0
- data/spec/uberspec/notify/lib_notify_spec.rb +21 -0
- data/spec/uberspec/notify_spec.rb +58 -0
- data/spec/uberspec/parallel_spec.rb +72 -0
- data/spec/uberspec/rspec_spec.rb +46 -0
- data/spec/uberspec_spec.rb +168 -0
- data/uberspec.gemspec +85 -0
- data/uberspec.watchr +10 -0
- metadata +148 -0
data/.document
ADDED
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.8.7@uberspec
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 alanpeabody
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= uberspec
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 alanpeabody. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "uberspec"
|
8
|
+
gem.summary = %Q{Watchr + Rspec + Parallel Spec = Uberspec}
|
9
|
+
gem.description = %Q{Continious Integration for Rspec using Watchr}
|
10
|
+
gem.email = "gapeabody@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/alanpeabody/uberspec"
|
12
|
+
gem.authors = ["Alan Peabody"]
|
13
|
+
gem.add_dependency "watchr"
|
14
|
+
gem.add_dependency "rspec", "1.2.9"
|
15
|
+
gem.add_development_dependency "rspec", "1.2.9"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
require 'rake/rdoctask'
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
41
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "uberspec #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/img/failed.png
ADDED
Binary file
|
data/img/other.png
ADDED
Binary file
|
data/img/passed.png
ADDED
Binary file
|
data/img/pending.png
ADDED
Binary file
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Uberspec
|
2
|
+
class Config
|
3
|
+
|
4
|
+
IMAGE_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'img'))
|
5
|
+
|
6
|
+
# An array of watchr patterns for spec files.
|
7
|
+
attr_accessor :spec_paths
|
8
|
+
|
9
|
+
# An array of watchr patterns for code files.
|
10
|
+
attr_accessor :code_paths
|
11
|
+
|
12
|
+
# Accessor for which notify library to use, if any.
|
13
|
+
attr_accessor :notify
|
14
|
+
|
15
|
+
# Image/Icon to show when all tests pass
|
16
|
+
attr_accessor :passed_image
|
17
|
+
|
18
|
+
# Image/Icon to show when there are pending tests
|
19
|
+
attr_accessor :pending_image
|
20
|
+
|
21
|
+
# Image/Icon to show when any tests fail
|
22
|
+
attr_accessor :failed_image
|
23
|
+
|
24
|
+
# Create new config object with default values
|
25
|
+
def initialize
|
26
|
+
self.spec_paths = default_spec_paths
|
27
|
+
self.code_paths = default_code_paths
|
28
|
+
self.notify = false
|
29
|
+
self.passed_image = default_passed_image
|
30
|
+
self.pending_image = default_pending_image
|
31
|
+
self.failed_image = default_failed_image
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def default_spec_paths
|
37
|
+
['^spec/(.*)_spec\.rb']
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_code_paths
|
41
|
+
['^lib/(.*)\.rb']
|
42
|
+
end
|
43
|
+
|
44
|
+
def default_passed_image
|
45
|
+
"#{IMAGE_DIR}/passed.png"
|
46
|
+
end
|
47
|
+
|
48
|
+
def default_failed_image
|
49
|
+
"#{IMAGE_DIR}/failed.png"
|
50
|
+
end
|
51
|
+
|
52
|
+
def default_pending_image
|
53
|
+
"#{IMAGE_DIR}/pending.png"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Uberspec
|
2
|
+
module Notify
|
3
|
+
class Growl < Uberspec::Notify::Base
|
4
|
+
|
5
|
+
def command
|
6
|
+
'growlnotify'
|
7
|
+
end
|
8
|
+
|
9
|
+
def title
|
10
|
+
"-t '#{super}'"
|
11
|
+
end
|
12
|
+
|
13
|
+
def body
|
14
|
+
"-m '#{super}'"
|
15
|
+
end
|
16
|
+
|
17
|
+
def image
|
18
|
+
"--image '#{super}'"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Uberspec
|
2
|
+
module Notify
|
3
|
+
class LibNotify < Uberspec::Notify::Base
|
4
|
+
|
5
|
+
def command
|
6
|
+
'notify-send'
|
7
|
+
end
|
8
|
+
|
9
|
+
def title
|
10
|
+
"'#{super}'"
|
11
|
+
end
|
12
|
+
|
13
|
+
def body
|
14
|
+
"'#{super}'"
|
15
|
+
end
|
16
|
+
|
17
|
+
def image
|
18
|
+
"-i '#{super}'"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Uberspec
|
2
|
+
module Notify
|
3
|
+
class Base
|
4
|
+
attr_reader :stats
|
5
|
+
attr_reader :failure_image
|
6
|
+
attr_reader :passing_image
|
7
|
+
|
8
|
+
def initialize(pass_img,fail_img)
|
9
|
+
@passing_image = pass_img
|
10
|
+
@failure_image = fail_img
|
11
|
+
end
|
12
|
+
|
13
|
+
def notify(stats = {})
|
14
|
+
@stats = stats
|
15
|
+
system("#{command} #{title} #{body} #{image}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def title
|
19
|
+
failed ? "Tests Failed!" : "Tests Passed!"
|
20
|
+
end
|
21
|
+
|
22
|
+
def body
|
23
|
+
%Q{
|
24
|
+
#{stats[:examples]} Examples
|
25
|
+
#{stats[:failed]} Failed
|
26
|
+
#{stats[:pending]} Pending
|
27
|
+
|
28
|
+
Tests took #{stats[:time]} seconds
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def command
|
33
|
+
raise "'command' Must be defined by notification library"
|
34
|
+
end
|
35
|
+
|
36
|
+
def image
|
37
|
+
failed ? failure_image : passing_image
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def failed
|
43
|
+
stats[:failed] > 0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
require 'uberspec/notify/lib_notify'
|
50
|
+
require 'uberspec/notify/growl'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Uberspec
|
2
|
+
class Parallel < Uberspec::Rspec
|
3
|
+
|
4
|
+
def command
|
5
|
+
case matches.length
|
6
|
+
when 1
|
7
|
+
'parallel_spec -n 1'
|
8
|
+
when 2..4
|
9
|
+
'parallel_spec -n 2'
|
10
|
+
else
|
11
|
+
'parallel_spec'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse_results(result_string)
|
16
|
+
results = result_string.split("\n")
|
17
|
+
results = results[results.rindex("Results:")+1,results.length].compact.delete_if {|i| i !~ /\S/i }
|
18
|
+
examples = 0
|
19
|
+
pending = 0
|
20
|
+
failed = 0
|
21
|
+
results.each do |line|
|
22
|
+
if line =~ /\d+ example/
|
23
|
+
stats = line.split(',').map(&:to_i)
|
24
|
+
examples += stats[0]
|
25
|
+
failed += stats[1]
|
26
|
+
pending += stats[2] if stats[2]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
time = results.last.match(/\d*\.\d*/)[0].to_f
|
31
|
+
|
32
|
+
{:examples => examples, :pending => pending, :failed => failed, :time => time}
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Uberspec
|
2
|
+
class Rspec < Uberspec::Base
|
3
|
+
|
4
|
+
def command
|
5
|
+
'spec'
|
6
|
+
end
|
7
|
+
|
8
|
+
def all_test_files
|
9
|
+
Dir['spec/**/*_spec.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse_results(result_string)
|
13
|
+
results = result_string.split("\n")
|
14
|
+
results = results.last(4).compact.delete_if {|i| i !~ /\S/i }
|
15
|
+
|
16
|
+
time = results[0].match(/\d+\.\d+/)[0].to_f
|
17
|
+
|
18
|
+
stats = results[1].split(', ').map(&:to_i)
|
19
|
+
examples = stats[0]
|
20
|
+
failed = stats[1]
|
21
|
+
pending = stats[2]
|
22
|
+
|
23
|
+
{:time => time, :examples => examples, :failed => failed, :pending => pending}
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/uberspec.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
require 'uberspec/config'
|
3
|
+
require 'uberspec/notify'
|
4
|
+
|
5
|
+
module Uberspec
|
6
|
+
class Base
|
7
|
+
class << self
|
8
|
+
def watch(watchr_script, config = Config.new)
|
9
|
+
yield config if block_given?
|
10
|
+
tester = new(watchr_script,config)
|
11
|
+
tester.start_watching
|
12
|
+
tester
|
13
|
+
end
|
14
|
+
|
15
|
+
def run_all
|
16
|
+
ObjectSpace.each_object(self) { |o| o.run_all }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :watchr
|
21
|
+
attr_reader :matches
|
22
|
+
attr_reader :config
|
23
|
+
attr_reader :notifier
|
24
|
+
|
25
|
+
def initialize(watchr_script,config)
|
26
|
+
@watchr = watchr_script
|
27
|
+
@config = config
|
28
|
+
@notifier = set_notifier
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_notifier
|
32
|
+
return false if config.notify == false
|
33
|
+
raise "Unsupported Notification library (try 'LibNotify' or 'Growl')." unless ['LibNotify', 'Growl'].include? config.notify
|
34
|
+
eval("Uberspec::Notify::#{config.notify}").new(config.passed_image,config.failed_image)
|
35
|
+
end
|
36
|
+
|
37
|
+
def start_watching
|
38
|
+
all_paths.each do |path|
|
39
|
+
watchr.watch(path) {|m| find_and_run_match(m[1]) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def find_and_run_match(thing_to_match)
|
44
|
+
@matches = all_test_files.grep(/#{thing_to_match}/i)
|
45
|
+
if matches.empty?
|
46
|
+
puts "No matches found for #{thing_to_match}"
|
47
|
+
else
|
48
|
+
run
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def all_paths
|
53
|
+
(@config.spec_paths + @config.code_paths).uniq
|
54
|
+
end
|
55
|
+
|
56
|
+
def all_test_files
|
57
|
+
raise "'all_test_files' Must be defined in test suite specific implimentation"
|
58
|
+
end
|
59
|
+
|
60
|
+
def command
|
61
|
+
raise "'command' Must be defined in test suite specific implimentation"
|
62
|
+
end
|
63
|
+
|
64
|
+
def run_all
|
65
|
+
@matches = all_test_files
|
66
|
+
run
|
67
|
+
end
|
68
|
+
|
69
|
+
def clear
|
70
|
+
system("clear")
|
71
|
+
end
|
72
|
+
|
73
|
+
def run
|
74
|
+
clear
|
75
|
+
system_with_notify("#{command} #{matches.join(' ')}")
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse_results(results)
|
79
|
+
raise "'parse_results' Must be defined in test suit specific implimentation"
|
80
|
+
end
|
81
|
+
|
82
|
+
def system_with_notify(command)
|
83
|
+
#my_io = MyIO.new($stdout)
|
84
|
+
#$stdout = my_io
|
85
|
+
#system(command)
|
86
|
+
#$stdout = my_io.old_io
|
87
|
+
#results = my_io.captured
|
88
|
+
if notifier
|
89
|
+
results = %x{#{command}}
|
90
|
+
notifier.notify(parse_results(results))
|
91
|
+
puts results
|
92
|
+
else
|
93
|
+
system(command)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
Signal.trap('QUIT') { run_all } # Ctrl-\
|
100
|
+
Signal.trap('INT' ) { abort("\n") } # Ctrl-C
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class MyIO < IO
|
105
|
+
attr_reader :old_io
|
106
|
+
attr_reader :captured
|
107
|
+
|
108
|
+
def initialize(io)
|
109
|
+
super('')
|
110
|
+
@captured = ''
|
111
|
+
@old_io = io
|
112
|
+
end
|
113
|
+
|
114
|
+
def write(string)
|
115
|
+
@captured = string
|
116
|
+
super
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
require 'uberspec/rspec'
|
121
|
+
require 'uberspec/parallel'
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Uberspec::Config do
|
4
|
+
context "when initialized" do
|
5
|
+
before(:each) do
|
6
|
+
@config = Uberspec::Config.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should add default code path when initialized" do
|
10
|
+
@config.code_paths.length.should == 1
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should add default spec path when initialized" do
|
14
|
+
@config.spec_paths.length.should == 1
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set the default notification library to false" do
|
18
|
+
@config.notify.should == false
|
19
|
+
end
|
20
|
+
|
21
|
+
[:passed, :failed, :pending].each do |status|
|
22
|
+
it "should set the default #{status} image" do
|
23
|
+
@config.send("#{status}_image").should match(/^.*\/#{status}\.png/i)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Uberspec::Notify::Growl do
|
4
|
+
before(:each) do
|
5
|
+
@notifier = Uberspec::Notify::Growl.new('path/to/success.png','path/to/failure.png')
|
6
|
+
@stats = {:failed => 1, :examples => 100, :pending => 5, :time => 0.1234}
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have command defined" do
|
10
|
+
@notifier.stub!(:system)
|
11
|
+
@notifier.notify(@stats)
|
12
|
+
@notifier.command.should == 'growlnotify'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should send the correct command" do
|
16
|
+
@notifier.should_receive(:system).with(/growlnotify/)# '.*' '.*' -i '.*'/i)
|
17
|
+
@notifier.notify(@stats)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Uberspec::Notify::LibNotify do
|
4
|
+
before(:each) do
|
5
|
+
@notifier = Uberspec::Notify::LibNotify.new('path/to/success.png','path/to/failure.png')
|
6
|
+
@stats = {:failed => 1, :examples => 100, :pending => 5, :time => 0.1234}
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have command defined" do
|
10
|
+
@notifier.stub!(:system)
|
11
|
+
@notifier.notify(@stats)
|
12
|
+
@notifier.command.should == 'notify-send'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should send the correct command" do
|
16
|
+
@notifier.should_receive(:system).with(/notify-send/)# '.*' '.*' -i '.*'/i)
|
17
|
+
@notifier.notify(@stats)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe Uberspec::Notify::Base do
|
4
|
+
before(:each) do
|
5
|
+
@notifier = Uberspec::Notify::Base.new('path/to/success.png','path/to/failure.png')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should raise error because command is not defined" do
|
9
|
+
lambda { @notifier.command }.should raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
context "with failing tests" do
|
13
|
+
before(:each) do
|
14
|
+
@stats = {:failed => 1, :examples => 100, :pending => 5, :time => 0.1234}
|
15
|
+
@notifier.stub!(:system)
|
16
|
+
@notifier.stub!(:command)
|
17
|
+
@notifier.notify(@stats)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should set the title to failing" do
|
21
|
+
@notifier.title.should == "Tests Failed!"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should add the stats to the body" do
|
25
|
+
@notifier.body.split("\n").should include("100 Examples", "5 Pending", "1 Failed")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should say how long the tests took" do
|
29
|
+
@notifier.body.split("\n").should include("Tests took 0.1234 seconds")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should use the failure image" do
|
33
|
+
@notifier.image.should == 'path/to/failure.png'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with no failing tests" do
|
38
|
+
before(:each) do
|
39
|
+
@stats = {:failed => 0, :examples => 100, :pending => 5, :time => 0.1234}
|
40
|
+
@notifier.stub!(:system)
|
41
|
+
@notifier.stub!(:command)
|
42
|
+
@notifier.notify(@stats)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should set the title to failing" do
|
46
|
+
@notifier.title.should == "Tests Passed!"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should add the stats to the body" do
|
50
|
+
@notifier.body.split("\n").should include("100 Examples", "5 Pending", "0 Failed")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should user the success image" do
|
54
|
+
@notifier.image.should == 'path/to/success.png'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Uberspec::Parallel do
|
4
|
+
before(:each) do
|
5
|
+
@watchr_script = mock('watchr', :watch => nil)
|
6
|
+
@parallel = Uberspec::Parallel.watch(@watchr_script)
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with only one match" do
|
10
|
+
before(:each) do
|
11
|
+
@parallel.stub(:matches).and_return(['one/match'])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should run with only one core" do
|
15
|
+
@parallel.command.should == 'parallel_spec -n 1'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with less then five matches" do
|
20
|
+
before(:each) do
|
21
|
+
@parallel.stub(:matches).and_return(['one/match','two/match','three/match','four/match'])
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should run with only two cores" do
|
25
|
+
@parallel.command.should == 'parallel_spec -n 2'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with more then five matches" do
|
30
|
+
before(:each) do
|
31
|
+
@parallel.stub(:matches).and_return(['one/match','two/match','three/match','four/match','five/match','six/match'])
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should run with all cores" do
|
35
|
+
@parallel.command.should == 'parallel_spec'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when parsing results" do
|
40
|
+
before(:each) do
|
41
|
+
@result_string = <<-STRNG
|
42
|
+
|
43
|
+
Results:
|
44
|
+
261 examples, 2 failures, 22 pending
|
45
|
+
258 examples, 0 failures
|
46
|
+
242 examples, 0 failures, 12 pending
|
47
|
+
276 examples, 0 failures, 17 pending
|
48
|
+
|
49
|
+
Took 29.364053 seconds
|
50
|
+
|
51
|
+
STRNG
|
52
|
+
|
53
|
+
@parsed_results = @parallel.parse_results(@result_string)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return the number of examples" do
|
57
|
+
@parsed_results[:examples].should == 1037
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return the number of failing tests" do
|
61
|
+
@parsed_results[:failed].should == 2
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should return the number of pending tests" do
|
65
|
+
@parsed_results[:pending].should == 51
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should return the time it takes to runt he examples" do
|
69
|
+
@parsed_results[:time].should == 29.364053
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Uberspec::Rspec do
|
4
|
+
before(:each) do
|
5
|
+
@watchr_script = mock('watchr', :watch => nil)
|
6
|
+
@rspec = Uberspec::Rspec.watch(@watchr_script)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should define the command" do
|
10
|
+
@rspec.command.should == 'spec'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should define all test files" do
|
14
|
+
@rspec.all_test_files.should == Dir['spec/**/*_spec.rb']
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when parsing results" do
|
18
|
+
before(:each) do
|
19
|
+
@result_string = <<-STRNG
|
20
|
+
|
21
|
+
Finished in 0.12345 seconds
|
22
|
+
|
23
|
+
25 examples, 2 failures, 3 pending
|
24
|
+
|
25
|
+
STRNG
|
26
|
+
|
27
|
+
@parsed_results = @rspec.parse_results(@result_string)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return the number of examples" do
|
31
|
+
@parsed_results[:examples].should == 25
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return the number of failing tests" do
|
35
|
+
@parsed_results[:failed].should == 2
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return the number of pending tests" do
|
39
|
+
@parsed_results[:pending].should == 3
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return the time it takes to runt he examples" do
|
43
|
+
@parsed_results[:time].should == 0.12345
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Uberspec::Base do
|
4
|
+
before(:each) do
|
5
|
+
@watchr_script = mock('watchr', :watch => nil)
|
6
|
+
end
|
7
|
+
|
8
|
+
context "when calling watch" do
|
9
|
+
it "should create a new Uberspec::Rspec object" do
|
10
|
+
Uberspec::Base.watch(@watchr_script).class.should == Uberspec::Base
|
11
|
+
end
|
12
|
+
|
13
|
+
context "without a block of options" do
|
14
|
+
before(:each) do
|
15
|
+
@base = Uberspec::Base.watch(@watchr_script)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should set the configuration object" do
|
19
|
+
@base.config.class.should == Uberspec::Config
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should use the default config object if no options are given." do
|
23
|
+
@base.config.notify.should == false
|
24
|
+
@base.config.code_paths.should == Uberspec::Config.new.code_paths
|
25
|
+
@base.config.spec_paths.should == Uberspec::Config.new.spec_paths
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should set notifier to false" do
|
29
|
+
@base.notifier.should == false
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should store the watchr script" do
|
33
|
+
@base.watchr.should == @watchr_script
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with a option block" do
|
38
|
+
before(:each) do
|
39
|
+
@base = Uberspec::Base.watch(@watchr_script) do |config|
|
40
|
+
config.code_paths += ['code/path']
|
41
|
+
config.spec_paths = ['spec/path']
|
42
|
+
config.notify = "LibNotify"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should add the code paths" do
|
47
|
+
@base.config.code_paths.should include('code/path')
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should overwrite the spec paths" do
|
51
|
+
@base.config.spec_paths.should == ['spec/path']
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should set the notifier to lib notify" do
|
55
|
+
@base.notifier.class.should == Uberspec::Notify::LibNotify
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should start watching files" do
|
60
|
+
@watchr_script.should_receive(:watch).twice
|
61
|
+
@base = Uberspec::Base.watch(@watchr_script)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "running files" do
|
66
|
+
before(:each) do
|
67
|
+
@base = Uberspec::Base.watch(@watchr_script)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should expect command to be defined" do
|
71
|
+
lambda { @base.command }.should raise_error
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should expect all test files to be defined" do
|
75
|
+
lambda { @base.all_test_files}.should raise_error
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should run all files" do
|
79
|
+
@base.should_receive(:all_test_files)
|
80
|
+
@base.should_receive(:run)
|
81
|
+
@base.run_all
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should run all from the class level" do
|
85
|
+
pending "Not sure this is the best implimentation, nor how to test it"
|
86
|
+
@base.stub!(:all_test_files).and_return(['code/paths'])
|
87
|
+
@base.should_receive(:run_all)
|
88
|
+
Uberspec::Base.run_all
|
89
|
+
end
|
90
|
+
|
91
|
+
context "when no match is found" do
|
92
|
+
before(:each) do
|
93
|
+
@base.stub!(:puts)
|
94
|
+
@base.stub!(:all_test_files).and_return([])
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should not run" do
|
98
|
+
@base.should_not_receive(:run)
|
99
|
+
@base.find_and_run_match('spec_name')
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should set matches to empty" do
|
103
|
+
@base.find_and_run_match('spec_name')
|
104
|
+
@base.matches.should == []
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "when one match is found" do
|
109
|
+
before(:each) do
|
110
|
+
@base.stub!(:all_test_files).and_return(['spec/path'])
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should set the matches" do
|
114
|
+
@base.stub!(:run)
|
115
|
+
@base.find_and_run_match('path')
|
116
|
+
@base.matches.should == ['spec/path']
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should run" do
|
120
|
+
@base.should_receive(:run)
|
121
|
+
@base.find_and_run_match('path')
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should clear the console" do
|
125
|
+
@base.should_receive(:system).with("clear")
|
126
|
+
@base.clear
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
context "when running" do
|
132
|
+
before(:each) do
|
133
|
+
@base.stub!(:command).and_return('echo')
|
134
|
+
@base.stub!(:matches).and_return(['spec/path'])
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should clear the console" do
|
138
|
+
@base.stub(:system)
|
139
|
+
@base.should_receive(:clear)
|
140
|
+
@base.run
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should run the tests" do
|
144
|
+
@base.stub(:clear)
|
145
|
+
@base.should_receive(:system_with_notify).once
|
146
|
+
@base.run
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should run the tests and save the results" do
|
150
|
+
@base.should_receive(:system)
|
151
|
+
@base.system_with_notify('echo test')
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should have the custom IO stuff better tested"
|
155
|
+
end
|
156
|
+
|
157
|
+
context "when parsing results" do
|
158
|
+
before(:each) do
|
159
|
+
@results = "string of results"
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should raise an error" do
|
163
|
+
lambda { @base.parse_results(@results) }.should raise_error
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
data/uberspec.gemspec
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{uberspec}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alan Peabody"]
|
12
|
+
s.date = %q{2010-10-25}
|
13
|
+
s.description = %q{Continious Integration for Rspec using Watchr}
|
14
|
+
s.email = %q{gapeabody@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
".rvmrc",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"img/failed.png",
|
28
|
+
"img/other.png",
|
29
|
+
"img/passed.png",
|
30
|
+
"img/pending.png",
|
31
|
+
"lib/uberspec.rb",
|
32
|
+
"lib/uberspec/config.rb",
|
33
|
+
"lib/uberspec/notify.rb",
|
34
|
+
"lib/uberspec/notify/growl.rb",
|
35
|
+
"lib/uberspec/notify/lib_notify.rb",
|
36
|
+
"lib/uberspec/parallel.rb",
|
37
|
+
"lib/uberspec/rspec.rb",
|
38
|
+
"spec/spec.opts",
|
39
|
+
"spec/spec_helper.rb",
|
40
|
+
"spec/uberspec/config_spec.rb",
|
41
|
+
"spec/uberspec/notify/growl_spec.rb",
|
42
|
+
"spec/uberspec/notify/lib_notify_spec.rb",
|
43
|
+
"spec/uberspec/notify_spec.rb",
|
44
|
+
"spec/uberspec/parallel_spec.rb",
|
45
|
+
"spec/uberspec/rspec_spec.rb",
|
46
|
+
"spec/uberspec_spec.rb",
|
47
|
+
"uberspec.gemspec",
|
48
|
+
"uberspec.watchr"
|
49
|
+
]
|
50
|
+
s.homepage = %q{http://github.com/alanpeabody/uberspec}
|
51
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
52
|
+
s.require_paths = ["lib"]
|
53
|
+
s.rubygems_version = %q{1.3.7}
|
54
|
+
s.summary = %q{Watchr + Rspec + Parallel Spec = Uberspec}
|
55
|
+
s.test_files = [
|
56
|
+
"spec/uberspec_spec.rb",
|
57
|
+
"spec/uberspec/rspec_spec.rb",
|
58
|
+
"spec/uberspec/config_spec.rb",
|
59
|
+
"spec/uberspec/notify_spec.rb",
|
60
|
+
"spec/uberspec/parallel_spec.rb",
|
61
|
+
"spec/uberspec/notify/lib_notify_spec.rb",
|
62
|
+
"spec/uberspec/notify/growl_spec.rb",
|
63
|
+
"spec/spec_helper.rb"
|
64
|
+
]
|
65
|
+
|
66
|
+
if s.respond_to? :specification_version then
|
67
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
68
|
+
s.specification_version = 3
|
69
|
+
|
70
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
71
|
+
s.add_runtime_dependency(%q<watchr>, [">= 0"])
|
72
|
+
s.add_runtime_dependency(%q<rspec>, ["= 1.2.9"])
|
73
|
+
s.add_development_dependency(%q<rspec>, ["= 1.2.9"])
|
74
|
+
else
|
75
|
+
s.add_dependency(%q<watchr>, [">= 0"])
|
76
|
+
s.add_dependency(%q<rspec>, ["= 1.2.9"])
|
77
|
+
s.add_dependency(%q<rspec>, ["= 1.2.9"])
|
78
|
+
end
|
79
|
+
else
|
80
|
+
s.add_dependency(%q<watchr>, [">= 0"])
|
81
|
+
s.add_dependency(%q<rspec>, ["= 1.2.9"])
|
82
|
+
s.add_dependency(%q<rspec>, ["= 1.2.9"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
data/uberspec.watchr
ADDED
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uberspec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Alan Peabody
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-25 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: watchr
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - "="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 13
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 2
|
47
|
+
- 9
|
48
|
+
version: 1.2.9
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rspec
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - "="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 13
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 2
|
63
|
+
- 9
|
64
|
+
version: 1.2.9
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: Continious Integration for Rspec using Watchr
|
68
|
+
email: gapeabody@gmail.com
|
69
|
+
executables: []
|
70
|
+
|
71
|
+
extensions: []
|
72
|
+
|
73
|
+
extra_rdoc_files:
|
74
|
+
- LICENSE
|
75
|
+
- README.rdoc
|
76
|
+
files:
|
77
|
+
- .document
|
78
|
+
- .gitignore
|
79
|
+
- .rvmrc
|
80
|
+
- LICENSE
|
81
|
+
- README.rdoc
|
82
|
+
- Rakefile
|
83
|
+
- VERSION
|
84
|
+
- img/failed.png
|
85
|
+
- img/other.png
|
86
|
+
- img/passed.png
|
87
|
+
- img/pending.png
|
88
|
+
- lib/uberspec.rb
|
89
|
+
- lib/uberspec/config.rb
|
90
|
+
- lib/uberspec/notify.rb
|
91
|
+
- lib/uberspec/notify/growl.rb
|
92
|
+
- lib/uberspec/notify/lib_notify.rb
|
93
|
+
- lib/uberspec/parallel.rb
|
94
|
+
- lib/uberspec/rspec.rb
|
95
|
+
- spec/spec.opts
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- spec/uberspec/config_spec.rb
|
98
|
+
- spec/uberspec/notify/growl_spec.rb
|
99
|
+
- spec/uberspec/notify/lib_notify_spec.rb
|
100
|
+
- spec/uberspec/notify_spec.rb
|
101
|
+
- spec/uberspec/parallel_spec.rb
|
102
|
+
- spec/uberspec/rspec_spec.rb
|
103
|
+
- spec/uberspec_spec.rb
|
104
|
+
- uberspec.gemspec
|
105
|
+
- uberspec.watchr
|
106
|
+
has_rdoc: true
|
107
|
+
homepage: http://github.com/alanpeabody/uberspec
|
108
|
+
licenses: []
|
109
|
+
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options:
|
112
|
+
- --charset=UTF-8
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 3
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
hash: 3
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
requirements: []
|
134
|
+
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 1.3.7
|
137
|
+
signing_key:
|
138
|
+
specification_version: 3
|
139
|
+
summary: Watchr + Rspec + Parallel Spec = Uberspec
|
140
|
+
test_files:
|
141
|
+
- spec/uberspec_spec.rb
|
142
|
+
- spec/uberspec/rspec_spec.rb
|
143
|
+
- spec/uberspec/config_spec.rb
|
144
|
+
- spec/uberspec/notify_spec.rb
|
145
|
+
- spec/uberspec/parallel_spec.rb
|
146
|
+
- spec/uberspec/notify/lib_notify_spec.rb
|
147
|
+
- spec/uberspec/notify/growl_spec.rb
|
148
|
+
- spec/spec_helper.rb
|