fudge 0.6.1 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/fudge +0 -1
- data/lib/fudge/build.rb +0 -2
- data/lib/fudge/tasks.rb +1 -0
- data/lib/fudge/tasks/cucumber.rb +58 -0
- data/lib/fudge/version.rb +1 -1
- data/spec/lib/fudge/build_spec.rb +13 -15
- data/spec/lib/fudge/cli_spec.rb +29 -30
- data/spec/lib/fudge/description_spec.rb +37 -36
- data/spec/lib/fudge/exceptions_spec.rb +2 -2
- data/spec/lib/fudge/formatters/simple_spec.rb +31 -32
- data/spec/lib/fudge/output_checker_spec.rb +9 -9
- data/spec/lib/fudge/parser_spec.rb +2 -2
- data/spec/lib/fudge/runner_spec.rb +10 -10
- data/spec/lib/fudge/tasks/brakeman_spec.rb +2 -3
- data/spec/lib/fudge/tasks/bundler_spec.rb +4 -5
- data/spec/lib/fudge/tasks/cane_spec.rb +11 -11
- data/spec/lib/fudge/tasks/composite_task_spec.rb +9 -9
- data/spec/lib/fudge/tasks/cucumber_spec.rb +38 -0
- data/spec/lib/fudge/tasks/each_directory_spec.rb +9 -9
- data/spec/lib/fudge/tasks/flay_spec.rb +5 -6
- data/spec/lib/fudge/tasks/flog_spec.rb +9 -9
- data/spec/lib/fudge/tasks/in_directory_spec.rb +3 -3
- data/spec/lib/fudge/tasks/rake_spec.rb +2 -2
- data/spec/lib/fudge/tasks/rspec_spec.rb +12 -13
- data/spec/lib/fudge/tasks/shell_spec.rb +19 -22
- data/spec/lib/fudge/tasks/sub_process_spec.rb +20 -20
- data/spec/lib/fudge/tasks/task_spec.rb +20 -20
- data/spec/lib/fudge/tasks/yard_spec.rb +3 -3
- data/spec/lib/fudge/tasks_spec.rb +4 -4
- data/spec/lib/fudge/with_directory_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/support/dummy_task.rb +1 -1
- metadata +120 -146
- data/lib/fudge/version.rb.orig +0 -8
@@ -24,7 +24,7 @@ module Fudge::Exceptions
|
|
24
24
|
it { is_expected.to be_a String }
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'should take a task name as a parameter' do
|
28
28
|
expect { described_class.new }.to raise_error ArgumentError
|
29
29
|
end
|
30
30
|
end
|
@@ -39,7 +39,7 @@ module Fudge::Exceptions
|
|
39
39
|
it { is_expected.to be_a String }
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
42
|
+
it 'should take a task group name as a parameter' do
|
43
43
|
expect { described_class.new }.to raise_error ArgumentError
|
44
44
|
end
|
45
45
|
end
|
@@ -5,64 +5,63 @@ describe Fudge::Formatters::Simple do
|
|
5
5
|
|
6
6
|
subject { described_class.new(stdout) }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
string = subject.error
|
8
|
+
describe '#error' do
|
9
|
+
it 'returns message in RED' do
|
10
|
+
string = subject.error 'a message'
|
11
11
|
expect(string).to eq("\e[31ma message\e[0m")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
16
|
-
it
|
17
|
-
string = subject.success
|
15
|
+
describe '#success' do
|
16
|
+
it 'returns message in BRIGHT GREEN' do
|
17
|
+
string = subject.success 'a message'
|
18
18
|
expect(string).to eq("\e[1m\e[32ma message\e[0m")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe
|
23
|
-
it
|
24
|
-
string = subject.info
|
22
|
+
describe '#info' do
|
23
|
+
it 'returns message in CYAN' do
|
24
|
+
string = subject.info 'a message'
|
25
25
|
expect(string).to eq("\e[36ma message\e[0m")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
30
|
-
it
|
31
|
-
string = subject.notice
|
29
|
+
describe '#notice' do
|
30
|
+
it 'returns message in YELLOW' do
|
31
|
+
string = subject.notice 'a message'
|
32
32
|
expect(string).to eq("\e[33ma message\e[0m")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
37
|
-
it
|
38
|
-
string = subject.normal
|
39
|
-
expect(string).to eq(
|
36
|
+
describe '#normal' do
|
37
|
+
it 'returns unchanged message' do
|
38
|
+
string = subject.normal 'a message'
|
39
|
+
expect(string).to eq('a message')
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe
|
44
|
-
it
|
45
|
-
subject.puts
|
46
|
-
expect(stdout.string).to eq(
|
43
|
+
describe '#puts' do
|
44
|
+
it 'outputs message on stdout' do
|
45
|
+
subject.puts 'a message'
|
46
|
+
expect(stdout.string).to eq('a message' + "\n")
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
51
|
-
it
|
50
|
+
describe '#write' do
|
51
|
+
it 'supports chaining types to stdout' do
|
52
52
|
subject.write do |w|
|
53
|
-
w.normal('normal')
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
w.normal('normal')
|
54
|
+
.notice('notice')
|
55
|
+
.info('info')
|
56
|
+
.success('success')
|
57
|
+
.error('error')
|
58
58
|
end
|
59
59
|
|
60
|
-
expect(stdout.string).to eq('normal' + ' '
|
61
|
-
"\e[33mnotice\e[0m" + ' '
|
62
|
-
"\e[36minfo\e[0m" + ' '
|
63
|
-
"\e[1m\e[32msuccess\e[0m" + ' '
|
60
|
+
expect(stdout.string).to eq('normal' + ' ' \
|
61
|
+
"\e[33mnotice\e[0m" + ' ' \
|
62
|
+
"\e[36minfo\e[0m" + ' ' \
|
63
|
+
"\e[1m\e[32msuccess\e[0m" + ' ' \
|
64
64
|
"\e[31merror\e[0m" + "\n")
|
65
|
-
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
@@ -4,19 +4,19 @@ describe Fudge::OutputChecker do
|
|
4
4
|
let(:output_io) { StringIO.new }
|
5
5
|
let(:formatter) { Fudge::Formatters::Simple.new(output_io) }
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe '#check' do
|
8
8
|
subject { described_class.new(/foo/, formatter) }
|
9
9
|
|
10
|
-
context
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
context 'when the output does not match the check' do
|
11
|
+
it 'send a mismatch message to the output io' do
|
12
|
+
subject.check('bar')
|
13
|
+
expect(output_io.string).to include "Output didn't match (?-mix:foo)."
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
|
-
context
|
17
|
+
context 'with a block for checking' do
|
18
18
|
let(:callable) do
|
19
|
-
|
19
|
+
proc do
|
20
20
|
false
|
21
21
|
end
|
22
22
|
end
|
@@ -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
|
-
expect(output_io.string).to include
|
28
|
+
expect(output_io.string).to include 'Output matched (?-mix:foo) but condition failed.'
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -12,11 +12,11 @@ describe Fudge::Parser do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'should read a file and evaluate it' do
|
16
16
|
expect(subject.parse(@path)).to be_a Fudge::Description
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'should pass the contents to the new description' do
|
20
20
|
expect(subject.parse(@path).instance_variable_get(:@foo)).to eq(:bar)
|
21
21
|
end
|
22
22
|
end
|
@@ -10,35 +10,35 @@ describe Fudge::Runner do
|
|
10
10
|
subject { described_class.new(description) }
|
11
11
|
|
12
12
|
describe '#run_build' do
|
13
|
-
it
|
13
|
+
it 'should run the default task in the description' do
|
14
14
|
subject.run_build
|
15
15
|
|
16
16
|
expect(DummyTask.ran).to be_truthy
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'should raise an exception if the build fails' do
|
20
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
|
24
24
|
|
25
|
-
context
|
25
|
+
context 'when an formatter is provided' do
|
26
26
|
let(:stdout) { StringIO.new }
|
27
27
|
let(:formatter) { Fudge::Formatters::Simple.new(stdout) }
|
28
28
|
|
29
29
|
before :each do
|
30
|
-
subject.run_build 'default', :
|
30
|
+
subject.run_build 'default', formatter: formatter
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'puts all output to given formatter instead stdout' do
|
34
34
|
expect(stdout.string).not_to be_empty
|
35
|
-
expect(stdout.string).to include
|
36
|
-
expect(stdout.string).to include
|
37
|
-
expect(stdout.string).to include
|
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
|
-
it
|
41
|
-
expect(DummyTask.run_options).to eq(
|
40
|
+
it 'runs the task passing the formatter down' do
|
41
|
+
expect(DummyTask.run_options).to eq(formatter: formatter)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -5,7 +5,6 @@ describe Fudge::Tasks::Brakeman do
|
|
5
5
|
|
6
6
|
it_should_behave_like 'bundle aware'
|
7
7
|
|
8
|
-
|
9
8
|
let(:output_good) do
|
10
9
|
<<-EOF
|
11
10
|
| Errors | 0 |
|
@@ -50,10 +49,10 @@ EOF
|
|
50
49
|
|
51
50
|
context 'when :max score is supplied' do
|
52
51
|
it 'fails when score is higher than max' do
|
53
|
-
task = described_class.new :
|
52
|
+
task = described_class.new max: 0
|
54
53
|
expect(task).not_to succeed_with_output output_bad
|
55
54
|
|
56
|
-
task = described_class.new :
|
55
|
+
task = described_class.new max: 1
|
57
56
|
expect(task).to succeed_with_output output_bad
|
58
57
|
end
|
59
58
|
end
|
@@ -11,12 +11,11 @@ class TestBundlerAwareTask
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class TestNonBundlerAwareTask
|
14
|
-
|
15
14
|
def self.name
|
16
15
|
:test_non_bundle_aware
|
17
16
|
end
|
18
17
|
|
19
|
-
def run(
|
18
|
+
def run(_options = {})
|
20
19
|
true
|
21
20
|
end
|
22
21
|
end
|
@@ -28,15 +27,15 @@ describe Fudge::Tasks::CleanBundlerEnv do
|
|
28
27
|
let(:bundle_aware_task) { TestBundlerAwareTask.new }
|
29
28
|
let(:non_bundle_aware_task) { TestNonBundlerAwareTask.new }
|
30
29
|
|
31
|
-
context
|
32
|
-
it
|
30
|
+
context 'with a bundle aware task' do
|
31
|
+
it 'should run the bundle dependent tasks successfully' do
|
33
32
|
subject.tasks << bundle_aware_task
|
34
33
|
subject.tasks << non_bundle_aware_task
|
35
34
|
|
36
35
|
expect(subject.run).to be_truthy
|
37
36
|
end
|
38
37
|
|
39
|
-
it
|
38
|
+
it 'runs each task with a clean bundle env' do
|
40
39
|
expect(Bundler).to receive(:with_clean_env).and_call_original
|
41
40
|
|
42
41
|
subject.tasks << bundle_aware_task
|
@@ -6,31 +6,31 @@ describe Fudge::Tasks::Cane do
|
|
6
6
|
it_should_behave_like 'bundle aware'
|
7
7
|
|
8
8
|
describe '#run' do
|
9
|
-
it
|
10
|
-
expect(subject).to run_command
|
9
|
+
it 'runs cane on the codebase' do
|
10
|
+
expect(subject).to run_command 'cane'
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'with :doc => false' do
|
14
|
-
subject {described_class.new :
|
14
|
+
subject { described_class.new doc: false }
|
15
15
|
|
16
|
-
it
|
17
|
-
expect(subject).to run_command
|
16
|
+
it 'runs with --no-doc' do
|
17
|
+
expect(subject).to run_command 'cane --no-doc'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'with :style => false' do
|
22
|
-
subject {described_class.new :
|
22
|
+
subject { described_class.new style: false }
|
23
23
|
|
24
|
-
it
|
25
|
-
expect(subject).to run_command
|
24
|
+
it 'runs with --no-style' do
|
25
|
+
expect(subject).to run_command 'cane --no-style'
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'with :max_width => 100' do
|
30
|
-
subject {described_class.new :
|
30
|
+
subject { described_class.new max_width: 100 }
|
31
31
|
|
32
|
-
it
|
33
|
-
expect(subject).to run_command
|
32
|
+
it 'runs with --style-measure 100' do
|
33
|
+
expect(subject).to run_command 'cane --style-measure 100'
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -8,7 +8,7 @@ end
|
|
8
8
|
Fudge::Tasks.register(DummyTask2)
|
9
9
|
|
10
10
|
describe Fudge::Tasks::CompositeTask do
|
11
|
-
subject { described_class.new
|
11
|
+
subject { described_class.new { ; } }
|
12
12
|
|
13
13
|
describe '#run' do
|
14
14
|
before :each do
|
@@ -19,20 +19,20 @@ describe Fudge::Tasks::CompositeTask do
|
|
19
19
|
allow_any_instance_of(DummyTask2).to receive(:run) { |*_| @task_two_run = true }
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'should run all tasks defined and return true if they all succeed' do
|
23
23
|
expect_any_instance_of(DummyTask).to receive(:run).and_return(true)
|
24
24
|
expect(subject.run).to be_truthy
|
25
25
|
expect(@task_two_run).to be_truthy
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'should return false if any of the tasks fail' do
|
29
29
|
expect_any_instance_of(DummyTask).to receive(:run).and_return(false)
|
30
30
|
expect(subject.run).to be_falsey
|
31
31
|
expect(@task_two_run).to be_falsey
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe
|
35
|
+
describe 'Using TaskDSL' do
|
36
36
|
describe '#task' do
|
37
37
|
class AnotherCompositeTask < Fudge::Tasks::CompositeTask
|
38
38
|
include Fudge::TaskDSL
|
@@ -49,15 +49,15 @@ describe Fudge::Tasks::CompositeTask do
|
|
49
49
|
|
50
50
|
subject { AnotherCompositeTask.new }
|
51
51
|
|
52
|
-
it
|
52
|
+
it 'should define a task for each new instance of the composite task' do
|
53
53
|
expect(subject).to run_command 'foo bar'
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it 'should support defining composite tasks' do
|
57
57
|
expect(subject.tasks[1].tasks.first).to be_a DummyTask
|
58
58
|
end
|
59
59
|
|
60
|
-
context
|
60
|
+
context 'when provided an output' do
|
61
61
|
let(:output) { StringIO.new }
|
62
62
|
let(:formatter) { Fudge::Formatters::Simple.new(output) }
|
63
63
|
|
@@ -65,8 +65,8 @@ describe Fudge::Tasks::CompositeTask do
|
|
65
65
|
allow_any_instance_of(Fudge::Tasks::Shell).to receive(:run)
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
69
|
-
subject.run :
|
68
|
+
it 'prints messages to the output instead of stdout' do
|
69
|
+
subject.run formatter: formatter
|
70
70
|
|
71
71
|
expect(output.string).not_to be_empty
|
72
72
|
expect(output.string).to match /Running task.*shell.*foo, bar/
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fudge::Tasks::Cucumber do
|
4
|
+
it { is_expected.to be_registered_as :cucumber }
|
5
|
+
|
6
|
+
describe '#run' do
|
7
|
+
it 'turns on color if not specified' do
|
8
|
+
expect(subject).to run_command /--color/
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'turns off color if specified' do
|
12
|
+
expect(described_class.new(color: false)).not_to run_command /--color/
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'appends any arguments passed in' do
|
16
|
+
task = described_class.new('foobar', color: false)
|
17
|
+
expect(task).to run_command 'cucumber foobar'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should default the arguments to spec/' do
|
21
|
+
expect(described_class.new(color: false)).to run_command 'cucumber features/'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it_should_behave_like 'bundle aware'
|
26
|
+
|
27
|
+
describe '#coverage' do
|
28
|
+
subject { described_class.new coverage: 99 }
|
29
|
+
|
30
|
+
it { is_expected.not_to succeed_with_output 'some dummy output with no coverage' }
|
31
|
+
it { is_expected.not_to succeed_with_output '98.99999%) covered' }
|
32
|
+
it { is_expected.not_to succeed_with_output '0.00%) covered' }
|
33
|
+
it { is_expected.to succeed_with_output '99.99999%) covered' }
|
34
|
+
it { is_expected.to succeed_with_output '100.0%) covered' }
|
35
|
+
it { is_expected.to succeed_with_output "Finished in 0.1 seconds\n70 examples, 0 failures\n700 / 700 LOC (100.0%) covered." }
|
36
|
+
it { is_expected.not_to succeed_with_output "Finished in 0.6 seconds\n70 examples, 0 failures\n384 / 700 LOC (54.86%) covered." }
|
37
|
+
end
|
38
|
+
end
|
@@ -6,7 +6,7 @@ class TestEachDirectoryTask
|
|
6
6
|
:test_each_directory
|
7
7
|
end
|
8
8
|
|
9
|
-
def run(
|
9
|
+
def run(_options = {})
|
10
10
|
(self.pwds ||= []) << FileUtils.pwd
|
11
11
|
end
|
12
12
|
end
|
@@ -17,7 +17,7 @@ describe Fudge::Tasks::EachDirectory do
|
|
17
17
|
it { is_expected.to be_registered_as :each_directory }
|
18
18
|
|
19
19
|
describe '#initialize' do
|
20
|
-
it
|
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
|
@@ -33,35 +33,35 @@ describe Fudge::Tasks::EachDirectory do
|
|
33
33
|
subject.tasks << task
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should change to the given directories and run child tasks' do
|
37
37
|
subject.run
|
38
38
|
|
39
39
|
expect(task.pwds).to eq(dirs)
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
ed2 = described_class.new [
|
42
|
+
it 'should allow explicit specification of directories through an array' do
|
43
|
+
ed2 = described_class.new ['spec/lib', 'spec/support']
|
44
44
|
ed2.tasks << task
|
45
45
|
ed2.run
|
46
46
|
expect(task.pwds).to eq(dirs.sort)
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
50
|
-
ed2 = described_class.new [
|
49
|
+
it 'should respect the order of the directories as specified' do
|
50
|
+
ed2 = described_class.new ['spec/support', 'spec/lib']
|
51
51
|
ed2.tasks << task
|
52
52
|
ed2.run
|
53
53
|
expect(task.pwds).not_to eq(dirs.sort)
|
54
54
|
expect(task.pwds.sort).to eq(dirs.sort)
|
55
55
|
end
|
56
56
|
|
57
|
-
it
|
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
61
|
expect(ed2.tasks.first.options[:test]).to eq('coverage')
|
62
62
|
end
|
63
63
|
|
64
|
-
it
|
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
|