Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit f923aef

Browse files
committed
Added check to see if config file is empty and output, added relevant unit test
1 parent c8df8f4 commit f923aef

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/cukesparse.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def build_command
5858

5959
# Checks for task in arguments
6060
def check_for_task
61+
return abort 'ERROR: Your tasks.yml file is empty!'.red.underline unless @config
6162
task = argv & @config.keys
63+
6264
return abort 'ERROR: No task was passed to cukesparse!'.red.underline if task.empty?
6365
return puts 'WARN: Multiple tasks have been passed!'.yellow if task.length > 1
6466
return @task = @config[task[0]]

spec/cukesparse/check_for_task_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
Cukesparse.reset!
77
end
88

9+
context "when run with task defined and empty config file" do
10+
it "will return an error if config is empty" do
11+
ARGV.push('test_task')
12+
Cukesparse.config_file = File.join(fixture_path, 'empty_tasks.yml')
13+
Cukesparse.load_config
14+
Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: Your tasks.yml file is empty!\e[0m")
15+
Cukesparse.check_for_task
16+
end
17+
end
18+
919
context "when run with no task defined" do
1020
it "will return an error if no task is provided" do
1121
ARGV.push('incorrect_task')

0 commit comments

Comments
 (0)