fudge 0.6.1 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/bin/fudge +0 -1
  3. data/lib/fudge/build.rb +0 -2
  4. data/lib/fudge/tasks.rb +1 -0
  5. data/lib/fudge/tasks/cucumber.rb +58 -0
  6. data/lib/fudge/version.rb +1 -1
  7. data/spec/lib/fudge/build_spec.rb +13 -15
  8. data/spec/lib/fudge/cli_spec.rb +29 -30
  9. data/spec/lib/fudge/description_spec.rb +37 -36
  10. data/spec/lib/fudge/exceptions_spec.rb +2 -2
  11. data/spec/lib/fudge/formatters/simple_spec.rb +31 -32
  12. data/spec/lib/fudge/output_checker_spec.rb +9 -9
  13. data/spec/lib/fudge/parser_spec.rb +2 -2
  14. data/spec/lib/fudge/runner_spec.rb +10 -10
  15. data/spec/lib/fudge/tasks/brakeman_spec.rb +2 -3
  16. data/spec/lib/fudge/tasks/bundler_spec.rb +4 -5
  17. data/spec/lib/fudge/tasks/cane_spec.rb +11 -11
  18. data/spec/lib/fudge/tasks/composite_task_spec.rb +9 -9
  19. data/spec/lib/fudge/tasks/cucumber_spec.rb +38 -0
  20. data/spec/lib/fudge/tasks/each_directory_spec.rb +9 -9
  21. data/spec/lib/fudge/tasks/flay_spec.rb +5 -6
  22. data/spec/lib/fudge/tasks/flog_spec.rb +9 -9
  23. data/spec/lib/fudge/tasks/in_directory_spec.rb +3 -3
  24. data/spec/lib/fudge/tasks/rake_spec.rb +2 -2
  25. data/spec/lib/fudge/tasks/rspec_spec.rb +12 -13
  26. data/spec/lib/fudge/tasks/shell_spec.rb +19 -22
  27. data/spec/lib/fudge/tasks/sub_process_spec.rb +20 -20
  28. data/spec/lib/fudge/tasks/task_spec.rb +20 -20
  29. data/spec/lib/fudge/tasks/yard_spec.rb +3 -3
  30. data/spec/lib/fudge/tasks_spec.rb +4 -4
  31. data/spec/lib/fudge/with_directory_spec.rb +2 -2
  32. data/spec/spec_helper.rb +1 -1
  33. data/spec/support/dummy_task.rb +1 -1
  34. metadata +120 -146
  35. data/lib/fudge/version.rb.orig +0 -8
@@ -5,7 +5,6 @@ describe Fudge::Tasks::Flay 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
  Total score (lower is better) = 0
@@ -19,15 +18,15 @@ EOF
19
18
  end
20
19
 
21
20
  describe '#run' do
22
- it "runs flay on the codebase" do
21
+ it 'runs flay on the codebase' do
23
22
  expect(subject).to run_command "flay --diff `find . | grep --color=never -e '\\.rb$'`"
24
23
  end
25
24
 
26
25
  context 'with :exclude => pattern' do
27
- subject {described_class.new :exclude => 'spec/'}
26
+ subject { described_class.new exclude: 'spec/' }
28
27
 
29
28
  # Test doesn't check result :(
30
- it "filters out the pattern" do
29
+ it 'filters out the pattern' do
31
30
  cmd = "flay --diff `find . | grep --color=never -e '\\.rb$' | grep --color=never -v -E 'spec/'`"
32
31
  expect(subject).to run_command cmd
33
32
  end
@@ -38,10 +37,10 @@ EOF
38
37
 
39
38
  context 'when :max score is supplied' do
40
39
  it 'fails when score is higher than max' do
41
- task = described_class.new :max => 99
40
+ task = described_class.new max: 99
42
41
  expect(task).not_to succeed_with_output output_bad
43
42
 
44
- task = described_class.new :max => 100
43
+ task = described_class.new max: 100
45
44
  expect(task).to succeed_with_output output_bad
46
45
  end
47
46
  end
@@ -46,24 +46,24 @@ EOF
46
46
  end
47
47
 
48
48
  describe '#run' do
49
- it "runs flog on the codebase" do
49
+ it 'runs flog on the codebase' do
50
50
  expect(subject).to run_command "flog `find . | grep --color=never -e '\\.rb$'`"
51
51
  end
52
52
 
53
53
  context 'with :exclude => pattern' do
54
- subject {described_class.new :exclude => 'spec/'}
54
+ subject { described_class.new exclude: 'spec/' }
55
55
 
56
56
  # Test doesn't check result :(
57
- it "filters out the pattern" do
57
+ it 'filters out the pattern' do
58
58
  with_pattern = "flog `find . | grep --color=never -e '\\.rb$' | grep --color=never -v -E 'spec/'`"
59
59
  expect(subject).to run_command with_pattern
60
60
  end
61
61
  end
62
62
 
63
63
  context 'with :methods => true' do
64
- subject {described_class.new :methods => true}
64
+ subject { described_class.new methods: true }
65
65
 
66
- it "runs with methods only flag" do
66
+ it 'runs with methods only flag' do
67
67
  with_pattern = "flog -m `find . | grep --color=never -e '\\.rb$'`"
68
68
  expect(subject).to run_command with_pattern
69
69
  end
@@ -76,20 +76,20 @@ EOF
76
76
 
77
77
  context 'when :max score is supplied' do
78
78
  it 'fails when score is higher than max' do
79
- task = described_class.new :max => 9.9
79
+ task = described_class.new max: 9.9
80
80
  expect(task).not_to succeed_with_output output_good
81
81
 
82
- task = described_class.new :max => 10.0
82
+ task = described_class.new max: 10.0
83
83
  expect(task).to succeed_with_output output_good
84
84
  end
85
85
  end
86
86
 
87
87
  context 'when :average score is supplied' do
88
88
  it 'fails when average is higher than :average' do
89
- task = described_class.new :average => 4.9
89
+ task = described_class.new average: 4.9
90
90
  expect(task).not_to succeed_with_output output_good
91
91
 
92
- task = described_class.new :average => 5.0
92
+ task = described_class.new average: 5.0
93
93
  expect(task).to succeed_with_output output_good
94
94
  end
95
95
  end
@@ -6,7 +6,7 @@ class TestInDirectoryTask
6
6
  :test_in_directory
7
7
  end
8
8
 
9
- def run(options={})
9
+ def run(_options = {})
10
10
  self.pwd = FileUtils.pwd
11
11
  end
12
12
  end
@@ -17,7 +17,7 @@ describe Fudge::Tasks::InDirectory do
17
17
  it { is_expected.to be_registered_as :in_directory }
18
18
 
19
19
  describe '#initialize' do
20
- it "should take a directory as first argument" do
20
+ it 'should take a directory as first argument' do
21
21
  expect { described_class.new }.to raise_error ArgumentError
22
22
  end
23
23
  end
@@ -30,7 +30,7 @@ describe Fudge::Tasks::InDirectory do
30
30
  subject.tasks << task
31
31
  end
32
32
 
33
- it "should change to the given directory and run child tasks" do
33
+ it 'should change to the given directory and run child tasks' do
34
34
  subject.run
35
35
 
36
36
  expect(task.pwd).to eq(path)
@@ -5,13 +5,13 @@ describe Fudge::Tasks::Rake do
5
5
  it { is_expected.to be_a Fudge::Tasks::Shell }
6
6
 
7
7
  describe '#run' do
8
- it "should be rake by default" do
8
+ it 'should be rake by default' do
9
9
  expect(subject).to run_command 'rake '
10
10
  end
11
11
 
12
12
  it_should_behave_like 'bundle aware'
13
13
 
14
- it "should add any arguments given" do
14
+ it 'should add any arguments given' do
15
15
  expect(described_class.new('db:migrate')).to run_command 'rake db:migrate'
16
16
  end
17
17
  end
@@ -4,38 +4,37 @@ describe Fudge::Tasks::Rspec do
4
4
  it { is_expected.to be_registered_as :rspec }
5
5
 
6
6
  describe '#run' do
7
- it "should turn on color if not specified" do
7
+ it 'should turn on color if not specified' do
8
8
  expect(subject).to run_command /--tty/
9
9
  end
10
10
 
11
- it "should turn off color if specified" do
12
- expect(described_class.new(:color => false)).not_to run_command /--tty/
11
+ it 'should turn off color if specified' do
12
+ expect(described_class.new(color: false)).not_to run_command /--tty/
13
13
  end
14
14
 
15
- it "should append any arguments passed in" do
16
- task = described_class.new('foobar', :color => false)
15
+ it 'should append any arguments passed in' do
16
+ task = described_class.new('foobar', color: false)
17
17
  expect(task).to run_command 'rspec foobar'
18
18
  end
19
19
 
20
- it "should default the arguments to spec/" do
21
- expect(described_class.new(:color => false)).to run_command 'rspec spec/'
20
+ it 'should default the arguments to spec/' do
21
+ expect(described_class.new(color: false)).to run_command 'rspec spec/'
22
22
  end
23
-
24
23
  end
25
24
 
26
25
  it_should_behave_like 'bundle aware'
27
26
 
28
27
  describe '#coverage' do
29
- subject { described_class.new :coverage => 99 }
28
+ subject { described_class.new coverage: 99 }
30
29
 
31
30
  it { is_expected.not_to succeed_with_output 'some dummy output with no coverage' }
32
31
  it { is_expected.not_to succeed_with_output '98.99999%) covered' }
33
32
  it { is_expected.not_to succeed_with_output '0.00%) covered' }
34
33
  it { is_expected.to succeed_with_output '99.99999%) covered' }
35
34
  it { is_expected.to succeed_with_output '100.0%) covered' }
36
- it { is_expected.to succeed_with_output "\n0 examples, 0 failures"}
37
- it { is_expected.to succeed_with_output "No examples found.\n\n\nFinished in 0.00006 seconds\n\e[32m0 examples, 0 failures\e[0m\n"}
38
- it { is_expected.to succeed_with_output "Finished in 0.1 seconds\n70 examples, 0 failures\n700 / 700 LOC (100.0%) covered."}
39
- it { is_expected.not_to succeed_with_output "Finished in 0.6 seconds\n70 examples, 0 failures\n384 / 700 LOC (54.86%) covered."}
35
+ it { is_expected.to succeed_with_output "\n0 examples, 0 failures" }
36
+ it { is_expected.to succeed_with_output "No examples found.\n\n\nFinished in 0.00006 seconds\n\e[32m0 examples, 0 failures\e[0m\n" }
37
+ it { is_expected.to succeed_with_output "Finished in 0.1 seconds\n70 examples, 0 failures\n700 / 700 LOC (100.0%) covered." }
38
+ it { is_expected.not_to succeed_with_output "Finished in 0.6 seconds\n70 examples, 0 failures\n384 / 700 LOC (54.86%) covered." }
40
39
  end
41
40
  end
@@ -2,63 +2,60 @@ require 'spec_helper'
2
2
 
3
3
  describe Fudge::Tasks::Shell do
4
4
  describe '#run' do
5
- it "should take a command and run it" do
5
+ it 'should take a command and run it' do
6
6
  expect(described_class.new(:ls)).to run_command 'ls'
7
7
  end
8
8
 
9
- it "should add any arguments given" do
9
+ it 'should add any arguments given' do
10
10
  expect(described_class.new(:ls, '-l', '-a')).to run_command 'ls -l -a'
11
11
  end
12
12
 
13
- it "should return false for an unsuccessful command" do
13
+ it 'should return false for an unsuccessful command' do
14
14
  expect(described_class.new(:ls, '--newnre').run).to be_falsey
15
15
  end
16
16
 
17
- it "should return true for a successful command" do
17
+ it 'should return true for a successful command' do
18
18
  expect(described_class.new(:ls).run).to be_truthy
19
19
  end
20
20
 
21
- context "when there is an formatter passed to run" do
22
-
21
+ context 'when there is an formatter passed to run' do
23
22
  let(:output) { StringIO.new }
24
23
  let(:formatter) { Fudge::Formatters::Simple.new(output) }
25
24
  subject { described_class.new('echo foo') }
26
25
 
27
- it "prints messages to the formatter instead of default" do
28
-
29
- subject.run :formatter => formatter
26
+ it 'prints messages to the formatter instead of default' do
27
+ subject.run formatter: formatter
30
28
 
31
29
  expect(output.string).not_to be_empty
32
- expect(output.string).to include "foo"
30
+ expect(output.string).to include 'foo'
33
31
  end
34
32
 
35
33
  it 'uses the formatter when reporting checks on build result' do
36
34
  checker = double.as_null_object
37
35
  expect(Fudge::OutputChecker).to receive(:new).with(anything, formatter) { checker }
38
- subject.run :formatter => formatter
36
+ subject.run formatter: formatter
39
37
  end
40
-
41
38
  end
42
39
  end
43
40
 
44
41
  describe '#check_for' do
45
- context "with no callable to check the matches" do
46
- subject { described_class.new(:ls, :check_for => /4 files found/) }
42
+ context 'with no callable to check the matches' do
43
+ subject { described_class.new(:ls, check_for: /4 files found/) }
47
44
 
48
- it { is_expected.to succeed_with_output "Hello there were 4 files found." }
49
- it { is_expected.not_to succeed_with_output "Hellow there were 5 files found." }
45
+ it { is_expected.to succeed_with_output 'Hello there were 4 files found.' }
46
+ it { is_expected.not_to succeed_with_output 'Hellow there were 5 files found.' }
50
47
  end
51
48
 
52
- context "with a callable to check the matches" do
53
- let(:file_count_matcher) { lambda { |matches| matches[1].to_i >= 4 }}
49
+ context 'with a callable to check the matches' do
50
+ let(:file_count_matcher) { ->(matches) { matches[1].to_i >= 4 } }
54
51
  subject do
55
52
  described_class.new :ls,
56
- :check_for => [/(\d+) files found/, file_count_matcher]
53
+ check_for: [/(\d+) files found/, file_count_matcher]
57
54
  end
58
55
 
59
- it { is_expected.not_to succeed_with_output "Hello there were 3 files found." }
60
- it { is_expected.to succeed_with_output "Hello there were 4 files found." }
61
- it { is_expected.to succeed_with_output "Hellow there were 5 files found." }
56
+ it { is_expected.not_to succeed_with_output 'Hello there were 3 files found.' }
57
+ it { is_expected.to succeed_with_output 'Hello there were 4 files found.' }
58
+ it { is_expected.to succeed_with_output 'Hellow there were 5 files found.' }
62
59
  end
63
60
  end
64
61
  end
@@ -6,25 +6,25 @@ describe Fudge::Tasks::SubProcess do
6
6
  let(:formatter) { Fudge::Formatters::Simple.new(output) }
7
7
 
8
8
  describe '#run' do
9
- it "takes a command and runs it" do
9
+ it 'takes a command and runs it' do
10
10
  expect(described_class.new(:ls)).to run_command [{}, 'ls', {}]
11
11
  end
12
12
 
13
- it "adds any arguments given" do
13
+ it 'adds any arguments given' do
14
14
  expect(described_class.new(:ls, '-l', '-a')).to run_command [{}, 'ls', '-l', '-a', {}]
15
15
  end
16
16
 
17
- it "returns false for an unsuccessful command" do
17
+ it 'returns false for an unsuccessful command' do
18
18
  expect(described_class.new(:ls, '--newnre').run).to be_falsey
19
19
  end
20
20
 
21
- it "returns true for a successful command" do
21
+ it 'returns true for a successful command' do
22
22
  expect(described_class.new(:ls).run).to be_truthy
23
23
  end
24
24
 
25
- context "when given environment variables" do
26
- context "when the task is created" do
27
- it "passes the variables to the sub-process" do
25
+ context 'when given environment variables' do
26
+ context 'when the task is created' do
27
+ it 'passes the variables to the sub-process' do
28
28
  process = described_class.new(%(ruby -e "puts ENV['PATH'];puts ENV['FOO']"), environment: { 'FOO' => 'bar' })
29
29
 
30
30
  process.run(formatter: formatter)
@@ -33,8 +33,8 @@ describe Fudge::Tasks::SubProcess do
33
33
  end
34
34
  end
35
35
 
36
- context "when the task is run" do
37
- it "passes the variables to the sub-process" do
36
+ context 'when the task is run' do
37
+ it 'passes the variables to the sub-process' do
38
38
  process = described_class.new(%(ruby -e "puts ENV['PATH'];puts ENV['FOO']"))
39
39
 
40
40
  process.run(formatter: formatter, environment: { 'FOO' => 'bar' })
@@ -43,8 +43,8 @@ describe Fudge::Tasks::SubProcess do
43
43
  end
44
44
  end
45
45
 
46
- context "when the task is created and when it is run" do
47
- it "gives priority to the variables passed in on run" do
46
+ context 'when the task is created and when it is run' do
47
+ it 'gives priority to the variables passed in on run' do
48
48
  process = described_class.new(%(ruby -e "puts ENV['FOO'];puts ENV['BAZ']"),
49
49
  environment: { 'FOO' => 'bar', 'BAZ' => 'quux' })
50
50
 
@@ -55,8 +55,8 @@ describe Fudge::Tasks::SubProcess do
55
55
  end
56
56
  end
57
57
 
58
- context "when not given an environment variable" do
59
- it "does not make that variable available to the sub-process" do
58
+ context 'when not given an environment variable' do
59
+ it 'does not make that variable available to the sub-process' do
60
60
  process = described_class.new(%(ruby -e "puts ENV['FOO']"))
61
61
 
62
62
  process.run(formatter: formatter)
@@ -65,9 +65,9 @@ describe Fudge::Tasks::SubProcess do
65
65
  end
66
66
  end
67
67
 
68
- context "when given spawn options" do
69
- context "when the task is created" do
70
- it "applies those options to the sub-process" do
68
+ context 'when given spawn options' do
69
+ context 'when the task is created' do
70
+ it 'applies those options to the sub-process' do
71
71
  process = described_class.new(%(ruby -e "puts ENV['PATH'];puts ENV['FOO']"),
72
72
  environment: { 'FOO' => 'bar' },
73
73
  spawn_options: { unsetenv_others: true }) # Should clear environment variables
@@ -78,8 +78,8 @@ describe Fudge::Tasks::SubProcess do
78
78
  end
79
79
  end
80
80
 
81
- context "when the task is run" do
82
- it "applies those options to the sub-process" do
81
+ context 'when the task is run' do
82
+ it 'applies those options to the sub-process' do
83
83
  process = described_class.new(%(ruby -e "puts ENV['PATH'];puts ENV['FOO']"),
84
84
  environment: { 'FOO' => 'bar' })
85
85
 
@@ -89,8 +89,8 @@ describe Fudge::Tasks::SubProcess do
89
89
  end
90
90
  end
91
91
 
92
- context "when the task is created and when it is run" do
93
- it "gives priority to the options passed in on run" do
92
+ context 'when the task is created and when it is run' do
93
+ it 'gives priority to the options passed in on run' do
94
94
  process = described_class.new(%(ruby -e "puts ENV['PATH'];puts ENV['FOO']"),
95
95
  environment: { 'FOO' => 'bar' },
96
96
  spawn_options: { unsetenv_others: true }) # Clear environment variables
@@ -4,7 +4,7 @@ class MyTask < Fudge::Tasks::Task
4
4
  attr_accessor :cod
5
5
 
6
6
  attr_accessor :_methods_missing
7
- def method_missing(method, *args)
7
+ def method_missing(method, *_args)
8
8
  (@_methods_missing ||= []).push(method)
9
9
  end
10
10
  end
@@ -16,56 +16,56 @@ end
16
16
 
17
17
  describe Fudge::Tasks::Task do
18
18
  describe :initialize do
19
- context "given arguments" do
20
- it "accepts and stores the arguments" do
19
+ context 'given arguments' do
20
+ it 'accepts and stores the arguments' do
21
21
  task = MyTask.new :foo, :bar, :baz
22
22
  expect(task.args).to match_array [:foo, :bar, :baz]
23
23
  end
24
24
  end
25
25
 
26
- context "given options" do
27
- let (:task) { MyTask.new :cod => 'fanglers' }
26
+ context 'given options' do
27
+ let(:task) { MyTask.new cod: 'fanglers' }
28
28
 
29
- it "accepts and sets the options" do
29
+ it 'accepts and sets the options' do
30
30
  expect(task.cod).to eq 'fanglers'
31
31
  end
32
32
 
33
- it "accepts and stores the options" do
34
- expect(task.options).to eq({ cod: 'fanglers' })
33
+ it 'accepts and stores the options' do
34
+ expect(task.options).to eq(cod: 'fanglers')
35
35
  end
36
36
 
37
- context "including an option that is not supported" do
38
- let (:task) { MyTask.new :cod => 'fanglers', :foo => 'bar' }
37
+ context 'including an option that is not supported' do
38
+ let(:task) { MyTask.new cod: 'fanglers', foo: 'bar' }
39
39
 
40
- it "ignores the unsupported options" do
40
+ it 'ignores the unsupported options' do
41
41
  expect(task._methods_missing).to be_nil
42
42
  end
43
43
 
44
- it "stores all provided options" do
45
- expect(task.options).to eq({ cod: 'fanglers', foo: 'bar' })
44
+ it 'stores all provided options' do
45
+ expect(task.options).to eq(cod: 'fanglers', foo: 'bar')
46
46
  end
47
47
  end
48
48
  end
49
49
 
50
- context "given arguments and options" do
51
- let (:task) { MyTask.new :foo, :bar, :cod => 'fanglers' }
50
+ context 'given arguments and options' do
51
+ let(:task) { MyTask.new :foo, :bar, cod: 'fanglers' }
52
52
 
53
- it "stores the arguments separately from the options" do
53
+ it 'stores the arguments separately from the options' do
54
54
  expect(task.args).to match_array [:foo, :bar]
55
55
  end
56
56
 
57
- it "applies the options" do
57
+ it 'applies the options' do
58
58
  expect(task.cod).to eq 'fanglers'
59
59
  end
60
60
 
61
- it "stores the options separately from the arguments" do
62
- expect(task.options).to eq({ cod: 'fanglers' })
61
+ it 'stores the options separately from the arguments' do
62
+ expect(task.options).to eq(cod: 'fanglers')
63
63
  end
64
64
  end
65
65
  end
66
66
 
67
67
  describe :name do
68
- it "should default to implied name from class name" do
68
+ it 'should default to implied name from class name' do
69
69
  expect(TestNamespace::SomeTask.name).to eq(:some_task)
70
70
  end
71
71
  end