Sha256: f0eec58181c23a760892064c6035bc2bbf07c3fada9626e25311a71073cc6822

Contents?: true

Size: 1.44 KB

Versions: 52

Compression:

Stored size: 1.44 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe "Array#inspect" do
  it "returns a string" do
    [1, 2, 3].inspect.should be_kind_of(String)
  end

  it "calls inspect on its elements" do
    items = Array.new(3) do |i|
      obj = mock("#{i}")
      obj.should_receive(:inspect).and_return("items[#{i}]")
      obj
    end
    str = items.inspect
    str.should include('items[0]')
    str.should include('items[1]')
    str.should include('items[2]')
  end

  it "handles recursive arrays" do
    x = [1, 2]
    x << x << 4
    lambda{ x.inspect }.should_not raise_error

    x = [1, 2]
    y = [3, 4]
    x << y
    y << x
    lambda{ x.inspect }.should_not raise_error
    lambda{ y.inspect }.should_not raise_error
  end

  it "taints the result String if the Array is tainted" do
    a = [1, 2].taint
    a.inspect.tainted?.should be_true
  end

  it "taints the result String if an element is tainted" do
    a = [1, "str".taint, 2]
    a.inspect.tainted?.should be_true
  end

  it "does not taint the result String if the Array is empty" do
    a = []
    a.taint
    a.inspect.tainted?.should be_false
  end

  ruby_version_is "1.9" do
    it "propagates untrust from itself or elements" do
      x = [1, 2]
      x.untrust
      s = x.inspect
      s.untrusted?.should == true

      x = [1, s]
      x.untrust
      s = x.inspect
      s.untrusted?.should == true
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/array/inspect_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/array/inspect_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/array/inspect_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/array/inspect_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/array/inspect_spec.rb