spec_run_queue 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.markdown +19 -8
- data/bin/redis_runner +9 -13
- data/lib/spec_run_queue/queue/base.rb +1 -0
- data/lib/spec_run_queue/system_runner.rb +3 -10
- data/lib/spec_run_queue/version.rb +1 -1
- data/lib/spec_run_queue.rb +39 -0
- data/spec/spec_run_queue_spec.rb +35 -0
- data/spec/system_runner_spec.rb +12 -17
- data/spec_run_queue.gemspec +4 -0
- metadata +58 -43
data/.gitignore
CHANGED
data/README.markdown
CHANGED
@@ -20,26 +20,37 @@ and then runs the command, via backticks, in the shell. Summary results from th
|
|
20
20
|
NOTIFIERS
|
21
21
|
=========
|
22
22
|
|
23
|
-
Notifiers must provide at least one
|
23
|
+
Notifiers must provide at least one instance method, <tt>notify</tt>, which processes the output from the spec run. Currently, there are two runners, Stdout, and Growl. Stdout prints the results from the run to the terminal window, while growl sends a brief pass/fail summary to growl.
|
24
24
|
|
25
25
|
|
26
|
+
CONFIGURATION
|
27
|
+
=============
|
28
|
+
|
29
|
+
You can configure per project behavior by creating a SpecRunQueueFile in the root of
|
30
|
+
your project. An example of such a file might look like:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
SpecRunQueue.configure do |c|
|
34
|
+
c.rspec_bin = "bundle exec rspec"
|
35
|
+
c.add_notifier :growl, :password => "fizzbuzz"
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
If you do not provide a configuration, the runner will assume a binary of `rspec` and
|
40
|
+
use the stdout notifier.
|
41
|
+
|
26
42
|
USAGE
|
27
43
|
=====
|
28
44
|
|
29
45
|
In your project root, run
|
30
46
|
|
31
|
-
redis_runner
|
32
|
-
|
33
|
-
where 1 or 2 indicates the major version of rspec you are using for the project.
|
34
|
-
|
47
|
+
redis_runner
|
35
48
|
|
36
49
|
In order to trigger a queue run, you need your editor to insert a YAML dump of the instructions described above to the queue.
|
37
50
|
|
38
|
-
|
39
51
|
TODO
|
40
52
|
====
|
41
53
|
|
42
|
-
* Check for Gemfile to bundle exec the spec bin
|
43
|
-
* Genericify and configure the runner
|
44
54
|
* Include code or a plugin for the vim script I'm using to inject instructions into the queue
|
45
55
|
* Investigate a custom rspec runner in place of the current shell execution method
|
56
|
+
* Swap YAML for JSON
|
data/bin/redis_runner
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
#TODO make this more generic and configurable
|
4
|
-
|
5
3
|
require 'spec_run_queue'
|
6
4
|
require 'spec_run_queue/queue/redis'
|
7
|
-
require 'spec_run_queue/notifier/growl'
|
8
5
|
require 'spec_run_queue/notifier/stdout'
|
9
6
|
|
10
|
-
|
11
|
-
unless rspec_major_version
|
12
|
-
$stderr.puts "please specify 1 or 2 for rspec version"
|
13
|
-
exit -1
|
14
|
-
end
|
7
|
+
SPEC_RUN_QUEUE_FILE = "SpecRunQueueFile"
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
if File.readable?(SPEC_RUN_QUEUE_FILE)
|
10
|
+
load "./#{SPEC_RUN_QUEUE_FILE}"
|
11
|
+
else
|
12
|
+
SpecRunQueue.configure do |c|
|
13
|
+
c.add_notifier :stdout
|
14
|
+
end
|
15
|
+
end
|
19
16
|
|
20
|
-
queue = SpecRunQueue::Queue::Redis.new(runner)
|
17
|
+
queue = SpecRunQueue::Queue::Redis.new(SpecRunQueue.runner)
|
21
18
|
queue.run
|
22
|
-
|
@@ -1,20 +1,13 @@
|
|
1
1
|
module SpecRunQueue
|
2
2
|
class SystemRunner
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :options, :notifiers
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@version = version.to_i
|
5
|
+
def initialize(options = {})
|
7
6
|
@options = options
|
8
7
|
end
|
9
8
|
|
10
9
|
def rspec_bin
|
11
|
-
|
12
|
-
options[:spec_bin] || "spec"
|
13
|
-
elsif version == 2
|
14
|
-
options[:rspec_bin] || "rspec"
|
15
|
-
else
|
16
|
-
raise "Couldn't determine rspec bin'"
|
17
|
-
end
|
10
|
+
options.fetch(:rspec_bin, "rspec")
|
18
11
|
end
|
19
12
|
|
20
13
|
def add_notifier(notifier)
|
data/lib/spec_run_queue.rb
CHANGED
@@ -2,8 +2,47 @@ require 'rubygems'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
module SpecRunQueue
|
5
|
+
class Configuration
|
6
|
+
attr_accessor :rspec_bin
|
7
|
+
|
8
|
+
def add_notifier(runner_symbol, options = {})
|
9
|
+
klass = SpecRunQueue::Notifier.send(:const_get, runner_symbol.to_s.capitalize)
|
10
|
+
SpecRunQueue.runner.add_notifier klass.new(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_h
|
14
|
+
h = {}
|
15
|
+
h[:rspec_bin] = rspec_bin if rspec_bin
|
16
|
+
h
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.configuration
|
21
|
+
@configuration || configure
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.configure
|
25
|
+
@configuration = Configuration.new
|
26
|
+
|
27
|
+
if block_given?
|
28
|
+
yield configuration
|
29
|
+
end
|
30
|
+
|
31
|
+
@configuration
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.runner
|
35
|
+
@runner ||= SystemRunner.new(configuration.to_h)
|
36
|
+
end
|
5
37
|
end
|
6
38
|
|
7
39
|
require 'spec_run_queue/queue/base'
|
8
40
|
require 'spec_run_queue/notifier/base'
|
9
41
|
require 'spec_run_queue/system_runner'
|
42
|
+
|
43
|
+
module SpecRunQueue
|
44
|
+
module Notifier
|
45
|
+
autoload :Growl, 'spec_run_queue/notifier/growl'
|
46
|
+
autoload :Stdout, 'spec_run_queue/notifier/stdout'
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SpecRunQueue, "default runner" do
|
4
|
+
it "is a SystemRunner" do
|
5
|
+
runner = stub(:runner)
|
6
|
+
SpecRunQueue::SystemRunner.stub(:new).and_return(runner)
|
7
|
+
SpecRunQueue.runner.should == runner
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe SpecRunQueue, "Configuration" do
|
12
|
+
before do
|
13
|
+
SpecRunQueue.configure do |c|
|
14
|
+
c.rspec_bin = "/usr/local/bin/spec"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "provides a block style config" do
|
19
|
+
SpecRunQueue.configuration.rspec_bin.should == "/usr/local/bin/spec"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "can be converted to a hash of options" do
|
23
|
+
SpecRunQueue.configuration.to_h.should == { :rspec_bin => "/usr/local/bin/spec" }
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can add a notifier" do
|
27
|
+
notifier = stub(:notifier)
|
28
|
+
SpecRunQueue::Notifier::Growl.should_receive(:new).with(:password => "gpass").and_return(notifier)
|
29
|
+
SpecRunQueue.runner.should_receive(:add_notifier).with(notifier)
|
30
|
+
|
31
|
+
SpecRunQueue.configure do |c|
|
32
|
+
c.add_notifier :growl, :password => "gpass"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/system_runner_spec.rb
CHANGED
@@ -3,42 +3,37 @@ require 'spec_helper'
|
|
3
3
|
describe SpecRunQueue::SystemRunner do
|
4
4
|
let(:foo_notifier) { @foo_notifier ||= mock("FooNotifier", :notify => true) }
|
5
5
|
let(:bar_notifier) { @bar_notifier ||= mock("BarNotifier", :notify => true) }
|
6
|
-
let(:runner) { @runner ||=
|
6
|
+
let(:runner) { @runner ||=
|
7
7
|
begin
|
8
|
-
runner = SpecRunQueue::SystemRunner.new(
|
8
|
+
runner = SpecRunQueue::SystemRunner.new(:rspec_bin => "spec")
|
9
9
|
runner.add_notifier(foo_notifier)
|
10
10
|
runner.add_notifier(bar_notifier)
|
11
|
-
runner
|
11
|
+
runner
|
12
12
|
end
|
13
13
|
}
|
14
14
|
|
15
15
|
describe "initializing" do
|
16
|
-
it "should set the version" do
|
17
|
-
runner = SpecRunQueue::SystemRunner.new(1, { :password => "foo" })
|
18
|
-
runner.version.should == 1
|
19
|
-
end
|
20
|
-
|
21
16
|
it "should set the options" do
|
22
|
-
runner = SpecRunQueue::SystemRunner.new(
|
17
|
+
runner = SpecRunQueue::SystemRunner.new({ :password => "foo" })
|
23
18
|
runner.options.should == { :password => "foo" }
|
24
19
|
end
|
25
20
|
end
|
26
|
-
|
21
|
+
|
27
22
|
describe "getting the rspec binary" do
|
28
|
-
it "
|
29
|
-
runner = SpecRunQueue::SystemRunner.new
|
30
|
-
runner.rspec_bin.should == "
|
23
|
+
it "is 'rspec' by default" do
|
24
|
+
runner = SpecRunQueue::SystemRunner.new
|
25
|
+
runner.rspec_bin.should == "rspec"
|
31
26
|
end
|
32
27
|
|
33
|
-
it "
|
34
|
-
runner = SpecRunQueue::SystemRunner.new(
|
35
|
-
runner.rspec_bin.should == "rspec"
|
28
|
+
it "will use the rspec_bin option if present" do
|
29
|
+
runner = SpecRunQueue::SystemRunner.new(:rspec_bin => "bundle exec rspec")
|
30
|
+
runner.rspec_bin.should == "bundle exec rspec"
|
36
31
|
end
|
37
32
|
end
|
38
33
|
|
39
34
|
describe "adding a notifier" do
|
40
35
|
it "should append the notifier onto the notifiers list" do
|
41
|
-
runner = SpecRunQueue::SystemRunner.new
|
36
|
+
runner = SpecRunQueue::SystemRunner.new
|
42
37
|
foo_notifier = mock("FooNotifier")
|
43
38
|
runner.add_notifier(foo_notifier)
|
44
39
|
bar_notifier = mock("BarNotifier")
|
data/spec_run_queue.gemspec
CHANGED
@@ -18,4 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = ["redis_runner"]
|
20
20
|
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
s.add_development_dependency "redis"
|
24
|
+
s.add_development_dependency "ruby-growl", '~> 3.0'
|
21
25
|
end
|
metadata
CHANGED
@@ -1,34 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: spec_run_queue
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 5
|
10
|
-
version: 0.0.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Brendon Murphy
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2013-02-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &2152806200 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2152806200
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: redis
|
27
|
+
requirement: &2152805700 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2152805700
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: ruby-growl
|
38
|
+
requirement: &2152804800 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2152804800
|
22
47
|
description: Use a queue to run specs outside your editor
|
23
|
-
email:
|
48
|
+
email:
|
24
49
|
- xternal1+github@gmail.com
|
25
|
-
executables:
|
50
|
+
executables:
|
26
51
|
- redis_runner
|
27
52
|
extensions: []
|
28
|
-
|
29
53
|
extra_rdoc_files: []
|
30
|
-
|
31
|
-
files:
|
54
|
+
files:
|
32
55
|
- .gitignore
|
33
56
|
- Gemfile
|
34
57
|
- README.markdown
|
@@ -48,47 +71,39 @@ files:
|
|
48
71
|
- spec/queue/base_spec.rb
|
49
72
|
- spec/queue/redis_spec.rb
|
50
73
|
- spec/spec_helper.rb
|
74
|
+
- spec/spec_run_queue_spec.rb
|
51
75
|
- spec/system_runner_spec.rb
|
52
76
|
- spec_run_queue.gemspec
|
53
|
-
has_rdoc: true
|
54
77
|
homepage: https://github.com/bemurphy/spec_run_queue
|
55
78
|
licenses: []
|
56
|
-
|
57
79
|
post_install_message:
|
58
80
|
rdoc_options: []
|
59
|
-
|
60
|
-
require_paths:
|
81
|
+
require_paths:
|
61
82
|
- lib
|
62
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
84
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
|
69
|
-
- 0
|
70
|
-
version: "0"
|
71
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
90
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
version: "0"
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
80
95
|
requirements: []
|
81
|
-
|
82
96
|
rubyforge_project: spec_run_queue
|
83
|
-
rubygems_version: 1.
|
97
|
+
rubygems_version: 1.8.15
|
84
98
|
signing_key:
|
85
99
|
specification_version: 3
|
86
100
|
summary: Use a queue to run specs outside your editor
|
87
|
-
test_files:
|
101
|
+
test_files:
|
88
102
|
- spec/notifier/base_spec.rb
|
89
103
|
- spec/notifier/growl_spec.rb
|
90
104
|
- spec/notifier/stdout_spec.rb
|
91
105
|
- spec/queue/base_spec.rb
|
92
106
|
- spec/queue/redis_spec.rb
|
93
107
|
- spec/spec_helper.rb
|
108
|
+
- spec/spec_run_queue_spec.rb
|
94
109
|
- spec/system_runner_spec.rb
|