summaryrefslogtreecommitdiff
path: root/spec/ruby/library/set/shared/inspect.rb
blob: 69fbdd12f6bc9e7a17895db796da67531317f676 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
describe "set_inspect", shared: true do
  it "returns a String representation of self" do
    Set[].send(@method).should be_kind_of(String)
    Set[nil, false, true].send(@method).should be_kind_of(String)
    Set[1, 2, 3].send(@method).should be_kind_of(String)
    Set["1", "2", "3"].send(@method).should be_kind_of(String)
    Set[:a, "b", Set[?c]].send(@method).should be_kind_of(String)
  end

  it "correctly handles self-references" do
    (set = Set[]) << set
    set.send(@method).should be_kind_of(String)
    set.send(@method).should include("#<Set: {...}>")
  end
end