Skip to content

Commit

Permalink
cucumber scenarios for reek command-line options
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed Jun 26, 2009
1 parent 93ee686 commit 5c1055a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 22 deletions.
28 changes: 28 additions & 0 deletions features/options.feature
@@ -0,0 +1,28 @@
@options
Feature: Reek can be controlled using command-line options
In order to change reek's default behaviour
As a developer
I want to supply options on the command line

Scenario: return non-zero status on bad option
When I run reek --no-such-option
Then it fails with exit status 1
And it displays the error message:
"""
Error: invalid option: --no-such-option
"""

Scenario: return non-zero status on missing argument
When I run reek -f
Then it fails with exit status 1
And it displays the error message:
"""
Error: missing argument: -f
"""

Scenario: display the current version number
When I run reek --version
Then it succeeds
And it reports the current version
10 changes: 9 additions & 1 deletion features/step_definitions/reek_steps.rb
Expand Up @@ -2,6 +2,10 @@
run args
end

Then /^it succeeds$/ do
@last_exit_status.should == 0
end

Then /^it fails with exit status (\d+)$/ do |status|
@last_exit_status.should == status.to_i
end
Expand All @@ -12,4 +16,8 @@

Then /^it displays the error message:$/ do |string|
@last_stderr.should == string
end
end

Then /^it reports the current version$/ do
@last_stdout.chomp.should == "reek #{Reek::VERSION}"
end
3 changes: 3 additions & 0 deletions features/support/env.rb
@@ -1,7 +1,10 @@
$:.unshift 'lib'

require 'rubygems'
require 'tempfile'
require 'spec/expectations'
require 'fileutils'
require 'reek'

class CucumberWorld

Expand Down
21 changes: 0 additions & 21 deletions spec/slow/script_spec.rb
@@ -1,26 +1,5 @@
require 'reek'

describe 'version number' do
it 'should report the correct value' do
actual = `ruby -Ilib bin/reek --version`.split
$?.exitstatus.should == 0
actual[0].should == 'reek'
actual[1].should == Reek::VERSION
end
end

describe 'exit status', 'when reek is used incorrectly' do
it 'should return non-zero status on bad option' do
`ruby -Ilib bin/reek --no-such-option`
$?.exitstatus.should == 1
end

it 'should return non-zero status on missing argument' do
`ruby -Ilib bin/reek -f 2>/dev/null`
$?.exitstatus.should == 1
end
end

describe 'exit status', 'when reek is used correctly' do
it 'should return non-zero status when smells are reported' do
`echo "def x() 3; end" | ruby -Ilib bin/reek`
Expand Down

0 comments on commit 5c1055a

Please sign in to comment.