Skip to content

Commit

Permalink
Replaced script_spec by stdin.feature
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed Jun 28, 2009
1 parent a742dd9 commit 71133c4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
33 changes: 33 additions & 0 deletions features/stdin.feature
@@ -0,0 +1,33 @@
@stdin
Feature: Reek reads from $stdin when no files are given
In order to use reek with pipelines
As a developer
I want to pipe source code on stdin

Scenario: return zero status with no smells
When I pass "def simple() @fred = 3 end" to reek
Then it succeeds

Scenario: outputs nothing on empty stdin
When I pass "" to reek
Then it succeeds
And stdout equals ""

Scenario: return non-zero status when there are smells
When I pass "def x() 3; end" to reek
Then it fails with exit status 2

Scenario: output nothing when no smells
When I pass "def simple() @fred = 3; end" to reek
Then it succeeds
And stdout equals ""

Scenario: report smells correctly
When I pass "class Turn; def y() @x = 3; end end" to reek
Then it fails with exit status 2
And it reports:
"""
Turn has the variable name '@x' (Uncommunicative Name)
Turn#y has the name 'y' (Uncommunicative Name)
"""
8 changes: 8 additions & 0 deletions features/step_definitions/reek_steps.rb
Expand Up @@ -2,6 +2,14 @@
run args
end

When /^I pass "([^\"]*)" to reek$/ do |stdin|
run_with_pipe stdin
end

Then /^stdout equals "([^\"]*)"$/ do |report|
@last_stdout.should == report
end

Then /^it succeeds$/ do
@last_exit_status.should == 0
end
Expand Down
8 changes: 8 additions & 0 deletions features/support/env.rb
Expand Up @@ -15,6 +15,14 @@ def run(args)
@last_exit_status = $?.exitstatus
@last_stderr = IO.read(stderr_file.path)
end

def run_with_pipe(stdin)
stderr_file = Tempfile.new('cucumber')
stderr_file.close
@last_stdout = `echo \"#{stdin}\" | ruby -Ilib bin/reek 2> #{stderr_file.path}`
@last_exit_status = $?.exitstatus
@last_stderr = IO.read(stderr_file.path)
end
end

World do
Expand Down
29 changes: 0 additions & 29 deletions spec/slow/script_spec.rb

This file was deleted.

0 comments on commit 71133c4

Please sign in to comment.