Sha256: f0580246da2775ff8c7628dd3756130ebd91b6c19a100c41ec65ed4887e1af53

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

require_relative '../../spec_helper'

class MyArr < Array
    attr_accessor :stuff
end

describe Enumerable do

    before( :all ) do
        @v = []
        @v << 'string'
        @v << 'str'
        @v << 'str'
        @v << :k
        @v << 'my value'
    end

    describe '#realsize' do
        it 'returns the sum of the real size of its elements' do
            c = @v.dup
            v = @v.dup

            a = [ v.pop, [ v.pop, [ v.pop, { v.pop => v.pop } ] ] ]
            a.realsize.should == c.reduce(0) { |s, i| s += i.size }
        end

        context 'when the instance has variables' do
            it 'adds their size to the sum' do
                ma = MyArr.new( @v )
                ma.stuff = 'my stuff'

                ma.realsize.should > @v.realsize
            end
        end
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arachni-0.4.2 spec/arachni/ruby/enumerable_spec.rb