Skip to content

Commit

Permalink
Fixed bad output in spec matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed Jul 2, 2009
1 parent 9917db8 commit f37fa4b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
1 change: 1 addition & 0 deletions Manifest.txt
Expand Up @@ -71,6 +71,7 @@ spec/reek/smells/nested_iterators_spec.rb
spec/reek/smells/smell_detector_spec.rb
spec/reek/smells/uncommunicative_name_spec.rb
spec/reek/smells/utility_function_spec.rb
spec/reek/spec_spec.rb
spec/samples/corrupt_config_file/corrupt.reek
spec/samples/corrupt_config_file/dirty.rb
spec/samples/empty_config_file/dirty.rb
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/spec.rb
Expand Up @@ -49,7 +49,7 @@ def failure_message_for_should
"Expected source to reek, but it didn't"
end
def failure_message_for_should_not
"Expected no smells, but got:\n#{@source.report}"
"Expected no smells, but got:\n#{@source.full_report}"
end
end

Expand All @@ -73,7 +73,7 @@ def failure_message_for_should
"Expected #{@source} to reek of #{@klass}, but it didn't"
end
def failure_message_for_should_not
"Expected #{@source} not to reek of #{@klass}, but got:\n#{@source.report}"
"Expected #{@source} not to reek of #{@klass}, but got:\n#{@source.freport}"
end
end

Expand Down
68 changes: 68 additions & 0 deletions spec/reek/spec_spec.rb
@@ -0,0 +1,68 @@
require File.dirname(__FILE__) + '/../spec_helper.rb'

require 'reek/spec'

include Reek::Spec

describe ShouldReek, 'checking code in a string' do
before :each do
@clean_code = 'def good() true; end'
@smelly_code = 'def x() y = 4; end'
@matcher = ShouldReek.new
end

it 'matches a smelly String' do
@matcher.matches?(@smelly_code).should be_true
end

it 'doesnt match a fragrant String' do
@matcher.matches?(@clean_code).should be_false
end

it 'reports the smells when should_not fails' do
@matcher.matches?(@smelly_code).should be_true
@matcher.failure_message_for_should_not.should include(@smelly_code.to_source.full_report)
end
end

describe ShouldReek, 'checking code in a Dir' do
before :each do
@clean_dir = Dir['spec/samples/three_clean_files/*.rb']
@smelly_dir = Dir['spec/samples/two_smelly_files/*.rb']
@matcher = ShouldReek.new
end

it 'matches a smelly String' do
@matcher.matches?(@smelly_dir).should be_true
end

it 'doesnt match a fragrant String' do
@matcher.matches?(@clean_dir).should be_false
end

it 'reports the smells when should_not fails' do
@matcher.matches?(@smelly_dir).should be_true
@matcher.failure_message_for_should_not.should include(@smelly_dir.to_source.full_report)
end
end

describe ShouldReek, 'checking code in a File' do
before :each do
@clean_file = File.new(Dir['spec/samples/three_clean_files/*.rb'][0])
@smelly_file = File.new(Dir['spec/samples/two_smelly_files/*.rb'][0])
@matcher = ShouldReek.new
end

it 'matches a smelly String' do
@matcher.matches?(@smelly_file).should be_true
end

it 'doesnt match a fragrant String' do
@matcher.matches?(@clean_file).should be_false
end

it 'reports the smells when should_not fails' do
@matcher.matches?(@smelly_file).should be_true
@matcher.failure_message_for_should_not.should include(@smelly_file.to_source.full_report)
end
end

0 comments on commit f37fa4b

Please sign in to comment.