Skip to content

Commit

Permalink
Raise exception instead of removed warn method.
Browse files Browse the repository at this point in the history
  • Loading branch information
rejeep committed Feb 6, 2011
1 parent 8b3d917 commit c290491
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
10 changes: 4 additions & 6 deletions lib/mactag/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ def has_gems?
class << self
def create
unless gem_home_exists?
# EXCEPTION
Mactag.warn 'Gem home path does not exist on your system'
raise Mactag::MactagError.new("Specified gem home directory does not exist: #{Mactag::Config.gem_home}")
end

if @builder.has_gems?
if builder.has_gems?
Mactag::Ctags.new(@builder.files, Mactag::Config.tags_file).create

puts "Successfully generated TAGS file"
puts 'Successfully generated TAGS file'
else
# EXCEPTION
Mactag.warn 'You did not specify anything to tag'
raise Mactag::MactagError.new('Nothing to tag')
end
end

Expand Down
19 changes: 18 additions & 1 deletion spec/mactag/builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,26 @@
end
end

describe '#create' do
it 'raises error when gem home does not exist' do
Mactag::Builder.stub(:gem_home_exists?) { false }
proc {
Mactag::Builder.create
}.should raise_exception(Mactag::MactagError)
end

it 'raises errors when gem home exists but there are no gems' do
Mactag::Builder.stub(:gem_home_exists?) { true }
Mactag::Builder.stub(:builder) { mock(:has_gems? => false) }
proc {
Mactag::Builder.create
}.should raise_exception(Mactag::MactagError)
end
end

describe '#generate' do
it 'accepts a block as argument' do
lambda {
proc {
Mactag::Builder.generate {}
}.should_not raise_exception
end
Expand Down

0 comments on commit c290491

Please sign in to comment.