Sha256: c2ab2fa5625eeeb5e28cd40ab970eb216db86184585344a53fe1099d473dbe19

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Arachni::Component::Utilities do

    before( :all ) do
        @utils = Arachni::Component::Utilities
    end

    describe '#read_file' do
        it 'reads a file from a directory with the same name as the caller and return an array of stripped lines' do
            filename = 'read_file.txt'
            filepath = File.expand_path( File.dirname( __FILE__ ) ) + '/utilities_spec/' + filename

            expect(@utils.read_file( filename ).join( "\n" )).to eq(IO.read( filepath ).strip)
        end

        context 'if a block is given' do
            it 'reads a file from a directory with the same name as the caller one stripped line at a time' do
                filename = 'read_file.txt'
                filepath = File.expand_path( File.dirname( __FILE__ ) ) + '/utilities_spec/' + filename

                lines = []
                @utils.read_file( filename ){ |line| lines << line }

                expect(lines.join( "\n" )).to eq(IO.read( filepath ).strip)
            end
        end
    end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
arachni-1.6.1.3 spec/arachni/component/utilities_spec.rb
arachni-1.6.1.2 spec/arachni/component/utilities_spec.rb
arachni-1.6.1.1 spec/arachni/component/utilities_spec.rb
arachni-1.6.1 spec/arachni/component/utilities_spec.rb
arachni-1.6.0 spec/arachni/component/utilities_spec.rb
arachni-1.5.1 spec/arachni/component/utilities_spec.rb
arachni-1.5 spec/arachni/component/utilities_spec.rb
arachni-1.4 spec/arachni/component/utilities_spec.rb
arachni-1.3.2 spec/arachni/component/utilities_spec.rb
arachni-1.3.1 spec/arachni/component/utilities_spec.rb
arachni-1.3 spec/arachni/component/utilities_spec.rb