Sha256: ade0e9d838276d5698b3f086a202ec4adc8f88b5f85ef2b6a07905d2294c3b20

Contents?: true

Size: 956 Bytes

Versions: 2

Compression:

Stored size: 956 Bytes

Contents

require 'spec_helper'

describe GithubCLI::Util do
  describe '#flatten_has' do
    let(:hash) { { :a => { :b => { :c => 1 }}} }

    it 'preserves original hash' do
      hash = { :a => 1, :b => 2 }
      output = {}
      subject.flatten_hash hash, output
      output.should == hash
    end

    it "reduces multidimensional keys to one dimension" do
      output = {}
      subject.flatten_hash hash, output
      output.should == { :a_b_c => 1 }
    end
  end

  describe '#convert_values' do
    let(:values) { [true, {:a => false }, 'string']}

    it "converts ruby boolean to string" do
      subject.convert_values(values).should include "true"
      subject.convert_values(values).should_not include true
    end

    it "converts recursively" do
      subject.convert_values(values).should include ['false']
    end

    it 'preserves strings' do
      subject.convert_values(values).should include 'string'
    end
  end
end # GithubCLI::Util

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
github_cli-0.3.1 spec/github_cli/util_spec.rb
github_cli-0.3.0 spec/github_cli/util_spec.rb