fudge 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fudge/build.rb +25 -10
- data/lib/fudge/cli.rb +1 -0
- data/lib/fudge/rspec/matchers.rb +54 -49
- data/lib/fudge/runner.rb +1 -0
- data/lib/fudge/tasks/composite_task.rb +6 -4
- data/lib/fudge/tasks/each_directory.rb +1 -1
- data/lib/fudge/tasks/in_directory.rb +1 -1
- data/lib/fudge/tasks/shell.rb +1 -1
- data/lib/fudge/tasks/task.rb +5 -0
- data/lib/fudge/version.rb +1 -1
- data/spec/lib/fudge/build_spec.rb +19 -4
- data/spec/lib/fudge/cli_spec.rb +16 -16
- data/spec/lib/fudge/description_spec.rb +43 -42
- data/spec/lib/fudge/exceptions_spec.rb +17 -7
- data/spec/lib/fudge/formatters/simple_spec.rb +15 -15
- data/spec/lib/fudge/output_checker_spec.rb +2 -2
- data/spec/lib/fudge/parser_spec.rb +3 -3
- data/spec/lib/fudge/runner_spec.rb +9 -9
- data/spec/lib/fudge/tasks/brakeman_spec.rb +7 -7
- data/spec/lib/fudge/tasks/bundler_spec.rb +5 -5
- data/spec/lib/fudge/tasks/cane_spec.rb +8 -8
- data/spec/lib/fudge/tasks/composite_task_spec.rb +16 -15
- data/spec/lib/fudge/tasks/each_directory_spec.rb +9 -9
- data/spec/lib/fudge/tasks/flay_spec.rb +8 -8
- data/spec/lib/fudge/tasks/flog_spec.rb +13 -13
- data/spec/lib/fudge/tasks/in_directory_spec.rb +4 -4
- data/spec/lib/fudge/tasks/rake_spec.rb +5 -5
- data/spec/lib/fudge/tasks/rspec_spec.rb +16 -16
- data/spec/lib/fudge/tasks/shell_spec.rb +14 -14
- data/spec/lib/fudge/tasks/sub_process_spec.rb +3 -3
- data/spec/lib/fudge/tasks/task_spec.rb +1 -1
- data/spec/lib/fudge/tasks/yard_spec.rb +10 -10
- data/spec/lib/fudge/tasks_spec.rb +4 -4
- data/spec/lib/fudge/with_directory_spec.rb +2 -2
- metadata +145 -107
- checksums.yaml +0 -7
@@ -2,20 +2,27 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Fudge::Exceptions
|
4
4
|
describe Base do
|
5
|
-
it {
|
5
|
+
it { is_expected.to be_a StandardError }
|
6
6
|
end
|
7
7
|
|
8
8
|
describe BuildFailed do
|
9
|
-
it {
|
10
|
-
|
9
|
+
it { is_expected.to be_a Base }
|
10
|
+
|
11
|
+
describe '#message' do
|
12
|
+
subject { super().message }
|
13
|
+
it { is_expected.to be_a String }
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
describe TaskNotFound do
|
14
18
|
subject { described_class.new :foo }
|
15
19
|
|
16
|
-
it {
|
20
|
+
it { is_expected.to be_a Base }
|
17
21
|
|
18
|
-
|
22
|
+
describe '#message' do
|
23
|
+
subject { super().message }
|
24
|
+
it { is_expected.to be_a String }
|
25
|
+
end
|
19
26
|
|
20
27
|
it "should take a task name as a parameter" do
|
21
28
|
expect { described_class.new }.to raise_error ArgumentError
|
@@ -25,9 +32,12 @@ module Fudge::Exceptions
|
|
25
32
|
describe TaskGroupNotFound do
|
26
33
|
subject { described_class.new :foo }
|
27
34
|
|
28
|
-
it {
|
35
|
+
it { is_expected.to be_a Base }
|
29
36
|
|
30
|
-
|
37
|
+
describe '#message' do
|
38
|
+
subject { super().message }
|
39
|
+
it { is_expected.to be_a String }
|
40
|
+
end
|
31
41
|
|
32
42
|
it "should take a task group name as a parameter" do
|
33
43
|
expect { described_class.new }.to raise_error ArgumentError
|
@@ -5,49 +5,49 @@ describe Fudge::Formatters::Simple do
|
|
5
5
|
|
6
6
|
subject { described_class.new(stdout) }
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe "#error" do
|
9
9
|
it "returns message in RED" do
|
10
10
|
string = subject.error "a message"
|
11
|
-
string.
|
11
|
+
expect(string).to eq("\e[31ma message\e[0m")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe "#success" do
|
16
16
|
it "returns message in BRIGHT GREEN" do
|
17
17
|
string = subject.success "a message"
|
18
|
-
string.
|
18
|
+
expect(string).to eq("\e[1m\e[32ma message\e[0m")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe
|
22
|
+
describe "#info" do
|
23
23
|
it "returns message in CYAN" do
|
24
24
|
string = subject.info "a message"
|
25
|
-
string.
|
25
|
+
expect(string).to eq("\e[36ma message\e[0m")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
29
|
+
describe "#notice" do
|
30
30
|
it "returns message in YELLOW" do
|
31
31
|
string = subject.notice "a message"
|
32
|
-
string.
|
32
|
+
expect(string).to eq("\e[33ma message\e[0m")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
36
|
+
describe "#normal" do
|
37
37
|
it "returns unchanged message" do
|
38
38
|
string = subject.normal "a message"
|
39
|
-
string.
|
39
|
+
expect(string).to eq("a message")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe
|
43
|
+
describe "#puts" do
|
44
44
|
it "outputs message on stdout" do
|
45
45
|
subject.puts "a message"
|
46
|
-
stdout.string.
|
46
|
+
expect(stdout.string).to eq("a message" + "\n")
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
50
|
+
describe "#write" do
|
51
51
|
it "supports chaining types to stdout" do
|
52
52
|
subject.write do |w|
|
53
53
|
w.normal('normal').
|
@@ -57,11 +57,11 @@ describe Fudge::Formatters::Simple do
|
|
57
57
|
error('error')
|
58
58
|
end
|
59
59
|
|
60
|
-
stdout.string.
|
60
|
+
expect(stdout.string).to eq('normal' + ' ' +
|
61
61
|
"\e[33mnotice\e[0m" + ' ' +
|
62
62
|
"\e[36minfo\e[0m" + ' ' +
|
63
63
|
"\e[1m\e[32msuccess\e[0m" + ' ' +
|
64
|
-
"\e[31merror\e[0m" + "\n"
|
64
|
+
"\e[31merror\e[0m" + "\n")
|
65
65
|
|
66
66
|
end
|
67
67
|
end
|
@@ -10,7 +10,7 @@ describe Fudge::OutputChecker do
|
|
10
10
|
context "when the output does not match the check" do
|
11
11
|
it 'send a mismatch message to the output io' do
|
12
12
|
subject.check('bar')
|
13
|
-
output_io.string.
|
13
|
+
expect(output_io.string).to include "Output didn't match (?-mix:foo)."
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -25,7 +25,7 @@ describe Fudge::OutputChecker do
|
|
25
25
|
it 'sends error mesage to the output io' do
|
26
26
|
subject.check('foo')
|
27
27
|
|
28
|
-
output_io.string.
|
28
|
+
expect(output_io.string).to include "Output matched (?-mix:foo) but condition failed."
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Fudge::Parser do
|
4
4
|
use_tmp_dir
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe '#parse' do
|
7
7
|
before :each do
|
8
8
|
@path = 'FudgeFile'
|
9
9
|
|
@@ -13,11 +13,11 @@ describe Fudge::Parser do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should read a file and evaluate it" do
|
16
|
-
subject.parse(@path).
|
16
|
+
expect(subject.parse(@path)).to be_a Fudge::Description
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should pass the contents to the new description" do
|
20
|
-
subject.parse(@path).instance_variable_get(:@foo).
|
20
|
+
expect(subject.parse(@path).instance_variable_get(:@foo)).to eq(:bar)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -3,21 +3,21 @@ require 'spec_helper'
|
|
3
3
|
describe Fudge::Runner do
|
4
4
|
let(:input) do
|
5
5
|
StringIO.new('build :default do; task :dummy; end').tap do |s|
|
6
|
-
s.
|
6
|
+
allow(s).to receive(:path).and_return('')
|
7
7
|
end
|
8
8
|
end
|
9
9
|
let(:description) { Fudge::Description.new(input) }
|
10
10
|
subject { described_class.new(description) }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#run_build' do
|
13
13
|
it "should run the default task in the description" do
|
14
14
|
subject.run_build
|
15
15
|
|
16
|
-
DummyTask.ran.
|
16
|
+
expect(DummyTask.ran).to be_truthy
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should raise an exception if the build fails" do
|
20
|
-
Fudge::Build.
|
20
|
+
allow_any_instance_of(Fudge::Build).to receive(:run).and_return(false)
|
21
21
|
|
22
22
|
expect { subject.run_build }.to raise_error Fudge::Exceptions::BuildFailed
|
23
23
|
end
|
@@ -31,14 +31,14 @@ describe Fudge::Runner do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "puts all output to given formatter instead stdout" do
|
34
|
-
stdout.string.
|
35
|
-
stdout.string.
|
36
|
-
stdout.string.
|
37
|
-
stdout.string.
|
34
|
+
expect(stdout.string).not_to be_empty
|
35
|
+
expect(stdout.string).to include "Running build"
|
36
|
+
expect(stdout.string).to include "default"
|
37
|
+
expect(stdout.string).to include "Build SUCCEEDED!"
|
38
38
|
end
|
39
39
|
|
40
40
|
it "runs the task passing the formatter down" do
|
41
|
-
DummyTask.run_options.
|
41
|
+
expect(DummyTask.run_options).to eq({:formatter => formatter})
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Fudge::Tasks::Brakeman do
|
4
|
-
it {
|
4
|
+
it { is_expected.to be_registered_as :brakeman }
|
5
5
|
|
6
6
|
it_should_behave_like 'bundle aware'
|
7
7
|
|
@@ -40,21 +40,21 @@ Model Warnings:
|
|
40
40
|
EOF
|
41
41
|
end
|
42
42
|
|
43
|
-
describe
|
43
|
+
describe '#run' do
|
44
44
|
it 'runs brakeman on the codebase' do
|
45
|
-
subject.
|
45
|
+
expect(subject).to run_command 'brakeman '
|
46
46
|
end
|
47
47
|
|
48
|
-
it {
|
49
|
-
it {
|
48
|
+
it { is_expected.not_to succeed_with_output output_bad }
|
49
|
+
it { is_expected.to succeed_with_output output_good }
|
50
50
|
|
51
51
|
context 'when :max score is supplied' do
|
52
52
|
it 'fails when score is higher than max' do
|
53
53
|
task = described_class.new :max => 0
|
54
|
-
task.
|
54
|
+
expect(task).not_to succeed_with_output output_bad
|
55
55
|
|
56
56
|
task = described_class.new :max => 1
|
57
|
-
task.
|
57
|
+
expect(task).to succeed_with_output output_bad
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -22,9 +22,9 @@ class TestNonBundlerAwareTask
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe Fudge::Tasks::CleanBundlerEnv do
|
25
|
-
it {
|
25
|
+
it { is_expected.to be_registered_as :clean_bundler_env }
|
26
26
|
|
27
|
-
describe
|
27
|
+
describe '#run' do
|
28
28
|
let(:bundle_aware_task) { TestBundlerAwareTask.new }
|
29
29
|
let(:non_bundle_aware_task) { TestNonBundlerAwareTask.new }
|
30
30
|
|
@@ -33,14 +33,14 @@ describe Fudge::Tasks::CleanBundlerEnv do
|
|
33
33
|
subject.tasks << bundle_aware_task
|
34
34
|
subject.tasks << non_bundle_aware_task
|
35
35
|
|
36
|
-
subject.run.
|
36
|
+
expect(subject.run).to be_truthy
|
37
37
|
end
|
38
38
|
|
39
39
|
it "runs each task with a clean bundle env" do
|
40
|
-
Bundler.
|
40
|
+
expect(Bundler).to receive(:with_clean_env).and_call_original
|
41
41
|
|
42
42
|
subject.tasks << bundle_aware_task
|
43
|
-
subject.run.
|
43
|
+
expect(subject.run).to be_truthy
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Fudge::Tasks::Cane do
|
4
|
-
it {
|
4
|
+
it { is_expected.to be_registered_as :cane }
|
5
5
|
|
6
6
|
it_should_behave_like 'bundle aware'
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe '#run' do
|
9
9
|
it "runs cane on the codebase" do
|
10
|
-
subject.
|
10
|
+
expect(subject).to run_command "cane"
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'with :doc => false' do
|
14
14
|
subject {described_class.new :doc => false }
|
15
15
|
|
16
16
|
it "runs with --no-doc" do
|
17
|
-
subject.
|
17
|
+
expect(subject).to run_command "cane --no-doc"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,7 +22,7 @@ describe Fudge::Tasks::Cane do
|
|
22
22
|
subject {described_class.new :style => false }
|
23
23
|
|
24
24
|
it "runs with --no-style" do
|
25
|
-
subject.
|
25
|
+
expect(subject).to run_command "cane --no-style"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -30,11 +30,11 @@ describe Fudge::Tasks::Cane do
|
|
30
30
|
subject {described_class.new :max_width => 100 }
|
31
31
|
|
32
32
|
it "runs with --style-measure 100" do
|
33
|
-
subject.
|
33
|
+
expect(subject).to run_command "cane --style-measure 100"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
it {
|
38
|
-
it {
|
37
|
+
it { is_expected.not_to succeed_with_output 'any output from cane is bad' }
|
38
|
+
it { is_expected.to succeed_with_output '' }
|
39
39
|
end
|
40
40
|
end
|
@@ -10,29 +10,30 @@ Fudge::Tasks.register(DummyTask2)
|
|
10
10
|
describe Fudge::Tasks::CompositeTask do
|
11
11
|
subject { described_class.new do; end }
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe '#run' do
|
14
14
|
before :each do
|
15
15
|
subject.tasks << DummyTask.new
|
16
16
|
subject.tasks << DummyTask2.new
|
17
|
+
|
18
|
+
@task_two_run = false
|
19
|
+
allow_any_instance_of(DummyTask2).to receive(:run) { |*_| @task_two_run = true }
|
17
20
|
end
|
18
21
|
|
19
22
|
it "should run all tasks defined and return true if they all succeed" do
|
20
|
-
DummyTask.
|
21
|
-
|
22
|
-
|
23
|
-
subject.run.should be_true
|
23
|
+
expect_any_instance_of(DummyTask).to receive(:run).and_return(true)
|
24
|
+
expect(subject.run).to be_truthy
|
25
|
+
expect(@task_two_run).to be_truthy
|
24
26
|
end
|
25
27
|
|
26
28
|
it "should return false if any of the tasks fail" do
|
27
|
-
DummyTask.
|
28
|
-
|
29
|
-
|
30
|
-
subject.run.should be_false
|
29
|
+
expect_any_instance_of(DummyTask).to receive(:run).and_return(false)
|
30
|
+
expect(subject.run).to be_falsey
|
31
|
+
expect(@task_two_run).to be_falsey
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
35
|
describe "Using TaskDSL" do
|
35
|
-
describe
|
36
|
+
describe '#task' do
|
36
37
|
class AnotherCompositeTask < Fudge::Tasks::CompositeTask
|
37
38
|
include Fudge::TaskDSL
|
38
39
|
|
@@ -49,11 +50,11 @@ describe Fudge::Tasks::CompositeTask do
|
|
49
50
|
subject { AnotherCompositeTask.new }
|
50
51
|
|
51
52
|
it "should define a task for each new instance of the composite task" do
|
52
|
-
subject.
|
53
|
+
expect(subject).to run_command 'foo bar'
|
53
54
|
end
|
54
55
|
|
55
56
|
it "should support defining composite tasks" do
|
56
|
-
subject.tasks[1].tasks.first.
|
57
|
+
expect(subject.tasks[1].tasks.first).to be_a DummyTask
|
57
58
|
end
|
58
59
|
|
59
60
|
context "when provided an output" do
|
@@ -61,14 +62,14 @@ describe Fudge::Tasks::CompositeTask do
|
|
61
62
|
let(:formatter) { Fudge::Formatters::Simple.new(output) }
|
62
63
|
|
63
64
|
before :each do
|
64
|
-
Fudge::Tasks::Shell.
|
65
|
+
allow_any_instance_of(Fudge::Tasks::Shell).to receive(:run)
|
65
66
|
end
|
66
67
|
|
67
68
|
it "prints messages to the output instead of stdout" do
|
68
69
|
subject.run :formatter => formatter
|
69
70
|
|
70
|
-
output.string.
|
71
|
-
output.string.
|
71
|
+
expect(output.string).not_to be_empty
|
72
|
+
expect(output.string).to match /Running task.*shell.*foo, bar/
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
@@ -14,15 +14,15 @@ Fudge::Tasks.register(TestEachDirectoryTask)
|
|
14
14
|
|
15
15
|
describe Fudge::Tasks::EachDirectory do
|
16
16
|
subject { described_class.new 'spec/*' }
|
17
|
-
it {
|
17
|
+
it { is_expected.to be_registered_as :each_directory }
|
18
18
|
|
19
|
-
describe
|
19
|
+
describe '#initialize' do
|
20
20
|
it "should take a directory pattern as first argument" do
|
21
21
|
expect { described_class.new }.to raise_error ArgumentError
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe '#run' do
|
26
26
|
let(:task) { TestEachDirectoryTask.new }
|
27
27
|
let(:dirs) do
|
28
28
|
files = Dir[File.expand_path('../../../../*', __FILE__)]
|
@@ -36,36 +36,36 @@ describe Fudge::Tasks::EachDirectory do
|
|
36
36
|
it "should change to the given directories and run child tasks" do
|
37
37
|
subject.run
|
38
38
|
|
39
|
-
task.pwds.
|
39
|
+
expect(task.pwds).to eq(dirs)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should allow explicit specification of directories through an array" do
|
43
43
|
ed2 = described_class.new ["spec/lib","spec/support"]
|
44
44
|
ed2.tasks << task
|
45
45
|
ed2.run
|
46
|
-
task.pwds.
|
46
|
+
expect(task.pwds).to eq(dirs.sort)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should respect the order of the directories as specified" do
|
50
50
|
ed2 = described_class.new ["spec/support","spec/lib"]
|
51
51
|
ed2.tasks << task
|
52
52
|
ed2.run
|
53
|
-
task.pwds.
|
54
|
-
task.pwds.sort.
|
53
|
+
expect(task.pwds).not_to eq(dirs.sort)
|
54
|
+
expect(task.pwds.sort).to eq(dirs.sort)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should load fudge_settings.yml in the right directory" do
|
58
58
|
ed2 = described_class.new ['spec/lib']
|
59
59
|
ed2.tasks << Fudge::Tasks::Shell.new('pwd')
|
60
60
|
ed2.run
|
61
|
-
ed2.tasks.first.options[:test].
|
61
|
+
expect(ed2.tasks.first.options[:test]).to eq('coverage')
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should not load fudge_settings.yml in the wrong directory" do
|
65
65
|
ed2 = described_class.new ['spec/support']
|
66
66
|
ed2.tasks << Fudge::Tasks::Shell.new('pwd')
|
67
67
|
ed2.run
|
68
|
-
ed2.tasks.first.options.size.
|
68
|
+
expect(ed2.tasks.first.options.size).to eq(0)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|