Sha256: 0e86ddcb7f7dad5b65bb1af62c3cb19003af25d8c1c98f025a7219461a1852a4

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Roodi::Checks::EmptyRescueBodyCheck do
  before(:each) do
    @roodi = Roodi::Core::ParseTreeRunner.new(Roodi::Checks::EmptyRescueBodyCheck.new)
  end
  
  it "should accept a rescue body with content and no parameter" do
    content = <<-END
    begin
      call_method
    rescue
      puts "Recover from the call"
    end
    END
    @roodi.check_content(content)
    @roodi.errors.should be_empty
  end

  it "should accept a rescue body with content and a parameter" do
    content = <<-END
    begin
      call_method
    rescue Exception => e
      puts "Recover from the call"
    end
    END
    @roodi.check_content(content)
    @roodi.errors.should be_empty
  end

  it "should reject an empty rescue block with no parameter" do
    content = <<-END
    begin
      call_method
    rescue
    end
    END
    @roodi.check_content(content)
    errors = @roodi.errors
    errors.should_not be_empty
    errors[0].should eql("dummy-file.rb:3 - Rescue block should not be empty.")
  end

  it "should reject an empty rescue block with a parameter" do
    content = <<-END
    begin
      call_method
    rescue Exception => e
    end
    END
    @roodi.check_content(content)
    errors = @roodi.errors
    errors.should_not be_empty
    errors[0].should eql("dummy-file.rb:3 - Rescue block should not be empty.")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roodi-1.2.0 spec/roodi/checks/empty_rescue_body_check_spec.rb
roodi-1.3.0 spec/roodi/checks/empty_rescue_body_check_spec.rb