guard-spinach 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -0
- data/lib/guard/spinach.rb +10 -2
- data/lib/guard/spinach/runner.rb +27 -4
- data/lib/guard/spinach/templates/Guardfile +1 -1
- data/lib/guard/spinach/version.rb +1 -1
- data/test/guard/spinach/runner_test.rb +49 -22
- data/test/guard/spinach_test.rb +63 -1
- data/test/test_helper.rb +1 -1
- metadata +5 -3
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
## guard-spinach
|
2
|
+
|
3
|
+
### Options
|
4
|
+
|
5
|
+
<dl>
|
6
|
+
<dt>all_on_start</dt>
|
7
|
+
<dd>Boolean. Run all features on start.</dd>
|
8
|
+
|
9
|
+
<dt>generate</dt>
|
10
|
+
<dd>Boolean. Auto generate missing step files during each run.</dd>
|
11
|
+
|
12
|
+
<dt>backtrace</dt>
|
13
|
+
<dd>Boolean. Show backtrace</dd>
|
14
|
+
|
15
|
+
<dt>tags</dt>
|
16
|
+
<dd>Array. Run scenarios marked with tags</dd>
|
17
|
+
|
18
|
+
<dt>command_prefix</dt>
|
19
|
+
<dd>String. Allows you to inject something before the `spinach` command. E.g. `zeus spinach`.</dd>
|
20
|
+
</dl>
|
21
|
+
|
22
|
+
### Example Guardfile snippet
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
guard 'spinach', command_prefix: 'zeus', all_on_start: true, generate: true, backtrace: true, tags:["@javascript", "~@disabled"] do
|
26
|
+
watch(%r|^features/(.*)\.feature|)
|
27
|
+
watch(%r|^features/steps/(.*)([^/]+)\.rb|) do |m|
|
28
|
+
"features/#{m[1]}#{m[2]}.feature"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
MIT (Expat) License. Copyright 2011 [Codegram Technologies](http://codegram.com)
|
data/lib/guard/spinach.rb
CHANGED
@@ -3,8 +3,16 @@ require 'guard/guard'
|
|
3
3
|
|
4
4
|
module Guard
|
5
5
|
class Spinach < Guard
|
6
|
-
def
|
7
|
-
|
6
|
+
def start
|
7
|
+
run_all if @options[:all_on_start]
|
8
|
+
end
|
9
|
+
|
10
|
+
def run_all
|
11
|
+
Runner.new([], @options).run
|
12
|
+
end
|
13
|
+
|
14
|
+
def run_on_change(paths)
|
15
|
+
Runner.new(paths, @options).run
|
8
16
|
end
|
9
17
|
end
|
10
18
|
end
|
data/lib/guard/spinach/runner.rb
CHANGED
@@ -1,19 +1,42 @@
|
|
1
1
|
module Guard
|
2
2
|
class Spinach
|
3
3
|
class Runner
|
4
|
-
attr_reader :paths
|
4
|
+
attr_reader :paths, :options
|
5
5
|
|
6
|
-
def initialize(paths)
|
6
|
+
def initialize(paths, opts = nil)
|
7
7
|
@paths = paths
|
8
|
+
@options = opts || {}
|
8
9
|
end
|
9
10
|
|
10
11
|
def run
|
11
|
-
puts "Running #{paths.join(" ")}
|
12
|
+
puts "Running #{paths.empty? ? "all Spinach features" : paths.join(" ")}"
|
12
13
|
system(run_command)
|
14
|
+
notify($? == 0)
|
13
15
|
end
|
14
16
|
|
15
17
|
def run_command
|
16
|
-
|
18
|
+
cmd = []
|
19
|
+
cmd << @options[:command_prefix] if @options[:command_prefix]
|
20
|
+
cmd << 'spinach'
|
21
|
+
cmd << paths.join(" ")
|
22
|
+
cmd << '-g' if @options[:generate]
|
23
|
+
cmd << "-t #{@options[:tags].join(',')}" if @options[:tags] && @options[:tags].any?
|
24
|
+
cmd << '-b' if @options[:backtrace]
|
25
|
+
cmd.join(" ")
|
26
|
+
end
|
27
|
+
|
28
|
+
def notify(passed)
|
29
|
+
opts = {title: 'Spinach results', priority: 2}
|
30
|
+
|
31
|
+
if passed
|
32
|
+
status = 'Passed'
|
33
|
+
image = :success
|
34
|
+
else
|
35
|
+
status = 'Failed'
|
36
|
+
image = :failed
|
37
|
+
end
|
38
|
+
|
39
|
+
Notifier.notify(status, opts.merge(image: image))
|
17
40
|
end
|
18
41
|
end
|
19
42
|
end
|
@@ -1,34 +1,61 @@
|
|
1
1
|
require_relative '../../test_helper'
|
2
2
|
|
3
3
|
describe Guard::Spinach::Runner do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
subject.paths.must_include 'fake/path.feature'
|
13
|
-
subject.paths.must_include 'foo/bar.feature'
|
4
|
+
let(:runner) { Guard::Spinach::Runner.new(paths, options) }
|
5
|
+
let(:paths) { ['fake/path.feature', 'foo/bar.feature'] }
|
6
|
+
let(:options) { nil }
|
7
|
+
|
8
|
+
describe '#initialize' do
|
9
|
+
it 'sets up a bunch of file paths' do
|
10
|
+
runner.paths.must_include 'fake/path.feature'
|
11
|
+
runner.paths.must_include 'foo/bar.feature'
|
14
12
|
end
|
15
13
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
|
15
|
+
describe '#run_command' do
|
16
|
+
it 'generates a valid run command' do
|
17
|
+
runner.run_command.must_equal 'spinach fake/path.feature foo/bar.feature'
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'when :command_prefix option is given' do
|
21
|
+
let (:options) { { :command_prefix => 'zeus' } }
|
22
|
+
it 'generates a run command with prefix' do
|
23
|
+
runner.run_command.must_equal 'zeus spinach fake/path.feature foo/bar.feature'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'when :generate option is given' do
|
28
|
+
let (:options) { { :generate => true } }
|
29
|
+
it 'generates a run command with -g flag' do
|
30
|
+
runner.run_command.must_equal 'spinach fake/path.feature foo/bar.feature -g'
|
31
|
+
end
|
19
32
|
end
|
20
33
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
|
35
|
+
describe '#run' do
|
36
|
+
it 'runs spinach on all the features in the list' do
|
37
|
+
runner.expects(:system).with('spinach fake/path.feature foo/bar.feature')
|
38
|
+
capture_output{ runner.run }
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'outputs a message' do
|
42
|
+
runner.stubs(:system)
|
43
|
+
output = capture_output{ runner.run }
|
44
|
+
output.must_include 'Running'
|
30
45
|
output.must_include paths[0]
|
31
46
|
output.must_include paths[1]
|
32
47
|
end
|
48
|
+
|
49
|
+
it 'notifies of success' do
|
50
|
+
runner.stubs(:system).returns(`(exit 0)`)
|
51
|
+
Guard::Notifier.expects(:notify).with('Passed', title: 'Spinach results', image: :success, priority: 2)
|
52
|
+
runner.run
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'notifier of failures' do
|
56
|
+
runner.stubs(:system).returns(`(exit 1)`)
|
57
|
+
Guard::Notifier.expects(:notify).with('Failed', title: 'Spinach results', image: :failed, priority: 2)
|
58
|
+
runner.run
|
59
|
+
end
|
33
60
|
end
|
34
61
|
end
|
data/test/guard/spinach_test.rb
CHANGED
@@ -2,15 +2,77 @@ require_relative '../test_helper'
|
|
2
2
|
|
3
3
|
describe Guard::Spinach do
|
4
4
|
subject do
|
5
|
-
Guard::Spinach.new(data)
|
5
|
+
Guard::Spinach.new(data, options)
|
6
6
|
end
|
7
7
|
let(:paths) do
|
8
8
|
['fake/path.feature', 'foo/bar.feature']
|
9
9
|
end
|
10
|
+
let(:data) do
|
11
|
+
[]
|
12
|
+
end
|
13
|
+
let(:options) do
|
14
|
+
{}
|
15
|
+
end
|
10
16
|
describe "#run_on_change" do
|
11
17
|
it "fires run on a runner" do
|
12
18
|
Guard::Spinach::Runner.any_instance.expects(:system).with(
|
13
19
|
"spinach fake/path.feature foo/bar.feature")
|
20
|
+
subject.run_on_change(['fake/path.feature', 'foo/bar.feature'])
|
21
|
+
end
|
22
|
+
describe "with generate enabled" do
|
23
|
+
let(:options) do
|
24
|
+
{ :generate => true }
|
25
|
+
end
|
26
|
+
it "runs with step definition file generation enabled" do
|
27
|
+
Guard::Spinach::Runner.any_instance.expects(:system).with(
|
28
|
+
"spinach #{paths.join(' ')} -g")
|
29
|
+
subject.run_on_change(paths)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
describe "#run_all" do
|
34
|
+
it "fires run on a runner" do
|
35
|
+
Guard::Spinach::Runner.any_instance.expects(:system).with(
|
36
|
+
"spinach ")
|
37
|
+
subject.run_all
|
38
|
+
end
|
39
|
+
describe "with generate enabled" do
|
40
|
+
let(:options) do
|
41
|
+
{ :generate => true }
|
42
|
+
end
|
43
|
+
it "runs with step definition file generation enabled" do
|
44
|
+
Guard::Spinach::Runner.any_instance.expects(:system).with(
|
45
|
+
"spinach -g")
|
46
|
+
subject.run_all
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
describe "#start" do
|
51
|
+
describe "with defaults" do
|
52
|
+
it "does not fire run on a runner" do
|
53
|
+
Guard::Spinach::Runner.any_instance.expects(:system).never
|
54
|
+
subject.start
|
55
|
+
end
|
56
|
+
end
|
57
|
+
describe "with all_on_start => true" do
|
58
|
+
let(:options) do
|
59
|
+
{ :all_on_start => true }
|
60
|
+
end
|
61
|
+
it "fires run on a runner" do
|
62
|
+
Guard::Spinach::Runner.any_instance.expects(:system).with(
|
63
|
+
"spinach ")
|
64
|
+
subject.start
|
65
|
+
end
|
66
|
+
end
|
67
|
+
describe "with generate and all_on_start" do
|
68
|
+
let(:options) do
|
69
|
+
{ :generate => true, :all_on_start => true }
|
70
|
+
end
|
71
|
+
it "runs with step definition file generation enabled" do
|
72
|
+
Guard::Spinach::Runner.any_instance.expects(:system).with(
|
73
|
+
"spinach -g")
|
74
|
+
subject.start
|
75
|
+
end
|
14
76
|
end
|
15
77
|
end
|
16
78
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-spinach
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- .rvmrc
|
87
87
|
- Gemfile
|
88
88
|
- Guardfile
|
89
|
+
- README.md
|
89
90
|
- Rakefile
|
90
91
|
- guard-spinach.gemspec
|
91
92
|
- lib/guard/spinach.rb
|
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
116
|
version: '0'
|
116
117
|
requirements: []
|
117
118
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.8.
|
119
|
+
rubygems_version: 1.8.23
|
119
120
|
signing_key:
|
120
121
|
specification_version: 3
|
121
122
|
summary: guard-spinach is a guard plugin for spinach
|
@@ -123,3 +124,4 @@ test_files:
|
|
123
124
|
- test/guard/spinach/runner_test.rb
|
124
125
|
- test/guard/spinach_test.rb
|
125
126
|
- test/test_helper.rb
|
127
|
+
has_rdoc:
|