Sha256: 1926145d7dbc2cf3a152c2a27b97cf19447cf2c5e5e97abd3b3aacf6eb1c336d

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

require 'helper'

describe Recurator do
  let :recur do
    Recurator.new({
      "one" => {
        "two" => {
          "three" => 3
        }
      }
    })
  end

  it "initialize" do
    expect(Recurator.new([])).to be_a_instance_of(Recurator)
    expect(Recurator.new({})).to be_a_instance_of(Recurator)
    expect([].to_recur).to be_a_instance_of(Recurator)
    expect({}.to_recur).to be_a_instance_of(Recurator)
  end

  it "include Enumerable" do
    expect(Recurator).to include(Enumerable)
    expect(Recurator.new({}).to_enum).to be_a_instance_of(Enumerator)
  end

  it "each" do
    ret = []
    recur.each {|o|
      ret << o
    }
    expect(ret).to eq([["one",{"two"=>{"three"=>3}}], ["two",{"three"=>3}], ["three",3]])
  end

  it "keys" do
    expect(recur.keys).to eq(["one","two","three"])
  end

  it "values" do
    expect(recur.values).to eq([{"two"=>{"three"=>3}}, {"three"=>3}, 3])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recurator-0.0.2 spec/recurator_spec.rb