Sha256: 669e4084f027dafee0cf59c274f0eea4fc0d1b6579a770eeb63b25335c2b3e32

Contents?: true

Size: 1015 Bytes

Versions: 1

Compression:

Stored size: 1015 Bytes

Contents

# frozen_string_literal: true
require 'spec_helper'

describe BitBucket::Response::Mashify do
  # let(:mashify) { described_class.new }
  describe 'parse' do
    before do
      @mashify = BitBucket::Response::Mashify.new
      @string = 'Fantastic week!'
      @array = %w[Monday Tuesday]
      @hash = { one: 'one', two: 'two', three: 'three' }
      @array_with_hash = ['banana', 'apple', { third: 'mango' }]
    end
    it 'parses a hash an returns a hashie mash' do
      hashie_mash = @mashify.parse(@hash)
      expect(hashie_mash.one).to eq('one')
    end

    it 'parses a hash that is within an array' do
      array_hashie_mash = @mashify.parse(@array_with_hash)
      expect(array_hashie_mash[2].third).to eq('mango')
    end

    it 'returns same object if the object does not contain a hash' do
      string = @mashify.parse(@string)
      array = @mashify.parse(@array)

      expect(string).to eq(@string)
      expect(array.length).to eq(2)
      expect(array[0]).to eq('Monday')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitbuckets-0.2.0 spec/bitbucket_rest_api/response/mashify_spec.rb