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
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d8267a0d4afa0b74d964694a5871e21528b9d2ae
4
+ data.tar.gz: 2406d80644f4ab0355491eafafb1f4699a48e468
5
+ SHA512:
6
+ metadata.gz: 449dee87fe9c1b006a198bf5a4ca2e10842085f517fc91185a2c078ccc6814b4210b414dd2e39822f4568d18e1c69db7fa261677b5a942db7e1de03e90c5e796
7
+ data.tar.gz: 7ecf7d08cfbb75aadd7e388184f2b180632d059594e9e2e710c1c7bdb675e412dd6765853ad8ecb2a78a055007e5cc010e8da5601978d77e380eeafd1e1e8096
data/bin/fudge CHANGED
@@ -6,4 +6,3 @@ rescue Fudge::Exceptions::Base => e
6
6
  puts e.message
7
7
  exit 1
8
8
  end
9
-
@@ -25,8 +25,6 @@ module Fudge
25
25
  success = super
26
26
  if callbacks
27
27
  return false unless run_callbacks(success)
28
- else
29
- message "Skipping callbacks..."
30
28
  end
31
29
  report_time(start_time, time)
32
30
 
@@ -33,5 +33,6 @@ module Fudge
33
33
  require 'fudge/tasks/flay'
34
34
  require 'fudge/tasks/brakeman'
35
35
  require 'fudge/tasks/sub_process'
36
+ require 'fudge/tasks/cucumber'
36
37
  end
37
38
  end
@@ -0,0 +1,58 @@
1
+ module Fudge
2
+ module Tasks
3
+ # Allow use of Cucumber as a task
4
+ class Cucumber < Shell
5
+ include Helpers::BundleAware
6
+
7
+ private
8
+
9
+ def check_for
10
+ if coverage
11
+ [check_regex, method(:coverage_checker)]
12
+ else
13
+ super
14
+ end
15
+ end
16
+
17
+ def check_regex
18
+ /((\d+\.\d+)%\) covered)/
19
+ end
20
+
21
+ def coverage
22
+ options[:coverage]
23
+ end
24
+
25
+ # checks if the expected coverage is met
26
+ def coverage_checker(matches)
27
+ matches = matches.to_s
28
+ test_coverage_threshold(matches)
29
+ end
30
+
31
+ # checks the matched string from the console output,
32
+ # to see if the number for the coverage is greater or
33
+ # equal than the expected coverage
34
+ def test_coverage_threshold(matches)
35
+ if matches.to_f >= coverage
36
+ true
37
+ else
38
+ 'Insufficient Coverage.'
39
+ end
40
+ end
41
+
42
+ def color_options
43
+ ' --color' unless color == false
44
+ end
45
+
46
+ def cmd(options={})
47
+ self.arguments = 'features/' if (arguments.nil? || arguments.empty?)
48
+ bundle_cmd("cucumber#{color_options} #{arguments}", options)
49
+ end
50
+
51
+ def color
52
+ options[:color]
53
+ end
54
+ end
55
+
56
+ register Cucumber
57
+ end
58
+ end
@@ -1,4 +1,4 @@
1
1
  module Fudge
2
2
  # Define gem version
3
- VERSION = '0.6.1'
3
+ VERSION = '0.6.3'
4
4
  end
@@ -3,20 +3,18 @@ require 'spec_helper'
3
3
  describe Fudge::Build do
4
4
  it { is_expected.to be_a Fudge::Tasks::CompositeTask }
5
5
 
6
- describe "#run" do
7
-
8
- context "when provided an output" do
6
+ describe '#run' do
7
+ context 'when provided an output' do
9
8
  let(:stdout) { StringIO.new }
10
9
  let(:formatter) { Fudge::Formatters::Simple.new(stdout) }
11
10
 
12
- it "prints messages to the formatter instead of default" do
13
- subject.run :formatter => formatter
11
+ it 'prints messages to the formatter instead of default' do
12
+ subject.run formatter: formatter
14
13
 
15
- expect(stdout.string).not_to be_empty
16
- expect(stdout.string).to include "Skipping callbacks..."
14
+ expect(stdout.string).to be_empty
17
15
  end
18
16
 
19
- context "when there are callback hooks" do
17
+ context 'when there are callback hooks' do
20
18
  let(:hook) { double(:Hook) }
21
19
 
22
20
  before :each do
@@ -24,24 +22,24 @@ describe Fudge::Build do
24
22
  subject.success_hooks << hook
25
23
  end
26
24
 
27
- it "passesformatter down to the hook run" do
28
- expect(hook).to receive(:run).with(:formatter =>formatter).and_return(true)
29
- subject.run :formatter => formatter
25
+ it 'passesformatter down to the hook run' do
26
+ expect(hook).to receive(:run).with(formatter: formatter).and_return(true)
27
+ subject.run formatter: formatter
30
28
  end
31
29
  end
32
30
 
33
- context "when the `time` flag is set" do
31
+ context 'when the `time` flag is set' do
34
32
  before do
35
33
  subject.callbacks = true
36
34
  allow(subject).to receive(:run_callbacks).and_return(true)
37
35
  subject.time = true
38
36
  end
39
37
 
40
- it "should print out the time of the build" do
38
+ it 'should print out the time of the build' do
41
39
  expect(subject).to receive(:message) do |message|
42
- expect(message).to match /Finished in \d+.\d\d seconds./
40
+ expect(message).to match(/Finished in \d+.\d\d seconds./)
43
41
  end
44
- subject.run :formatter => formatter
42
+ subject.run formatter: formatter
45
43
  end
46
44
  end
47
45
  end
@@ -5,7 +5,7 @@ class AnotherDummyTask < DummyTask
5
5
  :another_dummy
6
6
  end
7
7
 
8
- def run(options={})
8
+ def run(_options = {})
9
9
  self.class.ran = true
10
10
  end
11
11
  end
@@ -18,7 +18,7 @@ describe Fudge::Cli do
18
18
  AnotherDummyTask.ran = false
19
19
  end
20
20
 
21
- describe ".build" do
21
+ describe '.build' do
22
22
  before :each do
23
23
  contents = <<-RUBY
24
24
  build :default do
@@ -33,15 +33,15 @@ describe Fudge::Cli do
33
33
  allow(File).to receive(:open) { |&block| block.yield file }
34
34
  end
35
35
 
36
- context "when not given a build name" do
37
- it "runs the default build" do
36
+ context 'when not given a build name' do
37
+ it 'runs the default build' do
38
38
  subject.build 'default'
39
39
  expect(DummyTask.ran).to be_truthy
40
40
  end
41
41
  end
42
42
 
43
- context "when given a build name" do
44
- it "runs the only the named build" do
43
+ context 'when given a build name' do
44
+ it 'runs the only the named build' do
45
45
  subject.build 'other'
46
46
  expect(DummyTask.ran).to be_falsey
47
47
  expect(AnotherDummyTask.ran).to be_truthy
@@ -49,13 +49,13 @@ describe Fudge::Cli do
49
49
  end
50
50
  end
51
51
 
52
- describe ".init" do
53
- let (:file_state) { { exists: false, content: '' } }
54
- let (:override_file_state) do
55
- ->(exists, content) {
52
+ describe '.init' do
53
+ let(:file_state) { { exists: false, content: '' } }
54
+ let(:override_file_state) do
55
+ lambda do |exists, content|
56
56
  file_state[:exists] = exists
57
57
  file_state[:content] = content
58
- }
58
+ end
59
59
  end
60
60
 
61
61
  before :each do
@@ -74,8 +74,8 @@ describe Fudge::Cli do
74
74
  allow(subject).to receive(:shell).and_return(shell)
75
75
  end
76
76
 
77
- context "when a Fudgefile does not exist in the current directory" do
78
- it "creates a new FudgeFile" do
77
+ context 'when a Fudgefile does not exist in the current directory' do
78
+ it 'creates a new FudgeFile' do
79
79
  expect(File).not_to be_exists('Fudgefile')
80
80
 
81
81
  subject.init
@@ -83,7 +83,7 @@ describe Fudge::Cli do
83
83
  expect(File).to be_exists('Fudgefile')
84
84
  end
85
85
 
86
- it "writes a default build into the new Fudgefile" do
86
+ it 'writes a default build into the new Fudgefile' do
87
87
  subject.init
88
88
 
89
89
  File.open('Fudgefile', 'r') do |f|
@@ -91,33 +91,33 @@ describe Fudge::Cli do
91
91
  end
92
92
  end
93
93
 
94
- it "outputs a success message" do
94
+ it 'outputs a success message' do
95
95
  subject.init
96
96
  expect(@output).to eq 'Fudgefile created.'
97
97
  end
98
98
  end
99
99
 
100
- context "when a Fudgefile already exists in the current directory" do
100
+ context 'when a Fudgefile already exists in the current directory' do
101
101
  before :each do
102
- override_file_state.(true, 'foo')
102
+ override_file_state.call(true, 'foo')
103
103
  end
104
104
 
105
- it "does not modify the existing Fudgefile" do
105
+ it 'does not modify the existing Fudgefile' do
106
106
  expect(File).to be_exists('Fudgefile')
107
107
 
108
108
  subject.init
109
109
 
110
- expect(File.open('Fudgefile') { |f| f.read }).to eql 'foo'
110
+ expect(File.open('Fudgefile', &:read)).to eql 'foo'
111
111
  end
112
112
 
113
- it "outputs a failure message" do
113
+ it 'outputs a failure message' do
114
114
  subject.init
115
115
  expect(@output).to eq 'Fudgefile already exists.'
116
116
  end
117
117
  end
118
118
  end
119
119
 
120
- describe ".list" do
120
+ describe '.list' do
121
121
  before :each do
122
122
  contents = <<-RUBY
123
123
  build :default do
@@ -137,32 +137,31 @@ describe Fudge::Cli do
137
137
  allow(subject).to receive(:shell).and_return(shell)
138
138
  end
139
139
 
140
- context "when not given a filter string" do
141
- it "lists all the defined builds" do
140
+ context 'when not given a filter string' do
141
+ it 'lists all the defined builds' do
142
142
  subject.list
143
143
  expect(@output).to eql "default\t\nother\tnot the default"
144
144
  end
145
145
  end
146
146
 
147
- context "when given a filter string" do
148
- context "that matches one or builds" do
149
- it "lists only the builds that match the filter" do
147
+ context 'when given a filter string' do
148
+ context 'that matches one or builds' do
149
+ it 'lists only the builds that match the filter' do
150
150
  subject.list 'oth'
151
151
  expect(@output).to eql "other\tnot the default"
152
152
  end
153
153
 
154
- it "ignores the case of the filter" do
154
+ it 'ignores the case of the filter' do
155
155
  subject.list 'OTH'
156
156
  expect(@output).to eql "other\tnot the default"
157
157
  end
158
158
  end
159
159
 
160
- context "that matches no builds" do
161
- it "outputs nothing" do
160
+ context 'that matches no builds' do
161
+ it 'outputs nothing' do
162
162
  expect(@output).to eql ''
163
163
  end
164
164
  end
165
165
  end
166
166
  end
167
-
168
167
  end
@@ -8,7 +8,6 @@ describe Fudge::Description do
8
8
  let(:build) { subject.builds.values.first }
9
9
  let(:build_tasks) { build.tasks.dup }
10
10
 
11
-
12
11
  def make_build
13
12
  subject.build :default do
14
13
  subject.task :dummy
@@ -17,16 +16,16 @@ describe Fudge::Description do
17
16
  build.callbacks = callbacks
18
17
  end
19
18
 
20
- describe "#initialize" do
19
+ describe '#initialize' do
21
20
  let(:input) { 'build :foo do; end' }
22
21
 
23
- it "should add the builds in the given string" do
22
+ it 'should add the builds in the given string' do
24
23
  expect(subject.builds[:foo]).to be_a Fudge::Build
25
24
  end
26
25
  end
27
26
 
28
- describe "#build" do
29
- it "should create a new build and add it to the builds array" do
27
+ describe '#build' do
28
+ it 'should create a new build and add it to the builds array' do
30
29
  expect(subject.builds).to be_empty
31
30
 
32
31
  subject.build :some_branch do
@@ -37,8 +36,8 @@ describe Fudge::Description do
37
36
  end
38
37
  end
39
38
 
40
- describe "#task" do
41
- it "should add a task to the current scope" do
39
+ describe '#task' do
40
+ it 'should add a task to the current scope' do
42
41
  subject.build :default do
43
42
  subject.task :dummy
44
43
  end
@@ -47,7 +46,7 @@ describe Fudge::Description do
47
46
  expect(build_tasks.first).to be_a DummyTask
48
47
  end
49
48
 
50
- it "should pass arguments to the initializer" do
49
+ it 'should pass arguments to the initializer' do
51
50
  subject.build :default do
52
51
  subject.task :dummy, :foo, :bar
53
52
  end
@@ -55,7 +54,7 @@ describe Fudge::Description do
55
54
  expect(build_tasks.first.args).to eq([:foo, :bar])
56
55
  end
57
56
 
58
- it "should forward missing methods to task" do
57
+ it 'should forward missing methods to task' do
59
58
  subject.build :default do
60
59
  subject.dummy :foo, :bar
61
60
  end
@@ -63,11 +62,11 @@ describe Fudge::Description do
63
62
  expect(build_tasks.first.args).to eq([:foo, :bar])
64
63
  end
65
64
 
66
- it "should super method_missing if no task found" do
65
+ it 'should super method_missing if no task found' do
67
66
  expect { subject.no_task :foo, :bar }.to raise_error(NoMethodError)
68
67
  end
69
68
 
70
- it "should add tasks recursively to composite tasks" do
69
+ it 'should add tasks recursively to composite tasks' do
71
70
  subject.build :default do
72
71
  subject.dummy_composite do
73
72
  subject.dummy
@@ -78,8 +77,8 @@ describe Fudge::Description do
78
77
  end
79
78
  end
80
79
 
81
- describe "#task_group" do
82
- it "should add a task group and allow it to be used in a build" do
80
+ describe '#task_group' do
81
+ it 'should add a task group and allow it to be used in a build' do
83
82
  subject.task_group :group1 do
84
83
  subject.task :dummy
85
84
  end
@@ -92,7 +91,7 @@ describe Fudge::Description do
92
91
  expect(DummyTask.ran).to be_truthy
93
92
  end
94
93
 
95
- it "should allow passing arguments to task groups" do
94
+ it 'should allow passing arguments to task groups' do
96
95
  subject.task_group :special_group do |which|
97
96
  subject.task which
98
97
  end
@@ -105,7 +104,7 @@ describe Fudge::Description do
105
104
  expect(DummyTask.ran).to be_truthy
106
105
  end
107
106
 
108
- it "should raise an exception if task group not found" do
107
+ it 'should raise an exception if task group not found' do
109
108
  expect do
110
109
  subject.build :default do
111
110
  subject.task_group :unkown_group
@@ -113,14 +112,14 @@ describe Fudge::Description do
113
112
  end.to raise_error Fudge::Exceptions::TaskGroupNotFound
114
113
  end
115
114
 
116
- context "grouped tasks" do
115
+ context 'grouped tasks' do
117
116
  before :each do
118
117
  subject.task_group :group1 do
119
118
  subject.task :dummy
120
119
  end
121
120
  end
122
121
 
123
- it "allows group task reuse in composite tasks" do
122
+ it 'allows group task reuse in composite tasks' do
124
123
  subject.build :default do
125
124
  subject.task :dummy_composite do
126
125
  subject.task_group :group1
@@ -131,9 +130,9 @@ describe Fudge::Description do
131
130
  expect(DummyTask.ran).to be_truthy
132
131
  end
133
132
 
134
- it "supports when options are given" do
133
+ it 'supports when options are given' do
135
134
  subject.build :default do
136
- subject.task :dummy_composite, :hello, :foobar => true do
135
+ subject.task :dummy_composite, :hello, foobar: true do
137
136
  subject.task_group :group1
138
137
  end
139
138
  end
@@ -146,10 +145,9 @@ describe Fudge::Description do
146
145
  expect(DummyTask.ran).to be_truthy
147
146
  end
148
147
  end
149
-
150
148
  end
151
149
 
152
- describe "Callback Hooks" do
150
+ describe 'Callback Hooks' do
153
151
  before :each do
154
152
  @ran = []
155
153
  allow_any_instance_of(Fudge::Tasks::Shell).to receive(:run_command) do |cmd|
@@ -158,21 +156,21 @@ describe Fudge::Description do
158
156
  end
159
157
  end
160
158
 
161
- describe "#on_success" do
162
- context "when callbacks is set to true" do
159
+ describe '#on_success' do
160
+ context 'when callbacks is set to true' do
163
161
  let(:callbacks) { true }
164
162
 
165
- it "should add success hooks that run after the build is successful" do
163
+ it 'should add success hooks that run after the build is successful' do
166
164
  make_build do
167
165
  subject.on_success { subject.shell 'FOO' }
168
166
  subject.on_success { subject.shell 'BAR' }
169
167
  end
170
168
 
171
169
  expect(build.run).to be_truthy
172
- expect(@ran).to eq(['FOO', 'BAR'])
170
+ expect(@ran).to eq(%w(FOO BAR))
173
171
  end
174
172
 
175
- it "fails the build HARD when hooks fail" do
173
+ it 'fails the build HARD when hooks fail' do
176
174
  make_build do
177
175
  subject.on_success { subject.shell 'fail'; subject.shell 'FOO' }
178
176
  subject.on_success { subject.shell 'BAR' }
@@ -183,10 +181,10 @@ describe Fudge::Description do
183
181
  end
184
182
  end
185
183
 
186
- context "when callbacks is set to false" do
184
+ context 'when callbacks is set to false' do
187
185
  let(:callbacks) { false }
188
186
 
189
- it "should not run the callbacks if the build succeeds" do
187
+ it 'should not run the callbacks if the build succeeds' do
190
188
  make_build do
191
189
  subject.on_success { subject.shell 'echo "WOOP"' }
192
190
  end
@@ -197,27 +195,30 @@ describe Fudge::Description do
197
195
  end
198
196
  end
199
197
 
200
- describe "#on_failure" do
198
+ describe '#on_failure' do
201
199
  before :each do
202
200
  allow_any_instance_of(DummyTask).to receive(:run).and_return(false)
203
201
  end
204
202
 
205
- context "when callbacks is set to true" do
203
+ context 'when callbacks is set to true' do
206
204
  let(:callbacks) { true }
207
205
 
208
- it "should add failure hooks that run after the build fails" do
206
+ it 'should add failure hooks that run after the build fails' do
209
207
  make_build do
210
208
  subject.on_failure { subject.shell 'WOOP' }
211
209
  subject.on_failure { subject.shell 'BAR' }
212
210
  end
213
211
 
214
212
  expect(build.run).to be_falsey
215
- expect(@ran).to eq(['WOOP', 'BAR'])
213
+ expect(@ran).to eq(%w(WOOP BAR))
216
214
  end
217
215
 
218
- it "fails the build HARD when hooks fail" do
216
+ it 'fails the build HARD when hooks fail' do
219
217
  make_build do
220
- subject.on_failure { subject.shell 'fail'; subject.shell 'FOO' }
218
+ subject.on_failure do
219
+ subject.shell 'fail'
220
+ subject.shell 'FOO'
221
+ end
221
222
  subject.on_failure { subject.shell 'BAR' }
222
223
  end
223
224
 
@@ -226,10 +227,10 @@ describe Fudge::Description do
226
227
  end
227
228
  end
228
229
 
229
- context "when callbacks is set to false" do
230
+ context 'when callbacks is set to false' do
230
231
  let(:callbacks) { false }
231
232
 
232
- it "should not run the callbacks if the build fails" do
233
+ it 'should not run the callbacks if the build fails' do
233
234
  make_build do
234
235
  subject.on_failure { subject.shell 'WOOP' }
235
236
  end