Sha256: 464e44c34446937ba0f3c0d2b3aabf3adff79f91ad4d8bbf8ec0b56d54c01ff9

Contents?: true

Size: 831 Bytes

Versions: 4

Compression:

Stored size: 831 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 'should return 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 'should add 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

4 entries across 4 versions & 1 rubygems

Version Path
arachni-0.4.1.3 spec/arachni/ruby/enumerable_spec.rb
arachni-0.4.1.2 spec/arachni/ruby/enumerable_spec.rb
arachni-0.4.1.1 spec/arachni/ruby/enumerable_spec.rb
arachni-0.4.1 spec/arachni/ruby/enumerable_spec.rb