Sha256: c1d6f7f15ed704637de24a41397367ddfa0255acd8520cf7d18687da002487ba

Contents?: true

Size: 1.7 KB

Versions: 5

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'
module Quickl
  describe "Quickl.valid_read_file!" do
    
    let(:r){ Quickl }
    
    describe "with default options" do
    
      it "should raise a Quickl::IOAccessError with a friendly message" do
        begin
          r.valid_read_file!("nosuchone.nosuchextension") 
          true.should == false
        rescue Quickl::IOAccessError => ex
          ex.message.should =~ /Not a file/ 
          ex.message.should =~ /nosuchone.nosuchextension/
        end
      end
      
    end # with default options
    
    describe "with specific error class" do

      it "should raise it with a default message" do
        begin
          r.valid_read_file!("nosuchone.nosuchextension", ArgumentError) 
          true.should == false
        rescue ArgumentError => ex
          ex.message.should =~ /Not a file/ 
          ex.message.should =~ /nosuchone.nosuchextension/
        end
      end

    end # with specific message

    describe "with specific message" do

      it "should raise a Quickl::IOAccessError with a specific message" do
        begin
          r.valid_read_file!("nosuchone.nosuchextension", nil, "specific") 
          true.should == false
        rescue Quickl::IOAccessError => ex
          ex.message.should == "specific"
        end
      end

    end # with specific message
    
    describe 'with specific message and error class' do

      it "should raise a Quickl::IOAccessError with a specific message" do
        begin
          r.valid_read_file!("nosuchone.nosuchextension", ArgumentError, "specific") 
          true.should == false
        rescue ArgumentError => ex
          ex.message.should == "specific"
        end
      end

    end
    
  end
end # module Quickl

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
quickl-0.4.3 spec/quickl/test_valid_read_file.rb
quickl-0.4.2 spec/quickl/test_valid_read_file.rb
quickl-0.4.1 spec/quickl/test_valid_read_file.rb
quickl-0.4.0 spec/quickl/test_valid_read_file.rb
quickl-0.3.0 spec/quickl/test_valid_read_file.rb