Sha256: 4e4da6db44723972060385096e32d1add53ce9111520b5e26a4ff579a1be58c6

Contents?: true

Size: 1.42 KB

Versions: 43

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe HelloSign::Resource::BaseResource do
  let(:data){
    {
      :a => :a1,
      :b => :b1,
      :c => { :c1 => :c2 },
      :d => [:d1, :d2, :d3],
      :e => [{ :e1 => :e11 }, { :e2 => :e21 }, { :e3 => :e31 }]
    }
  }

  describe 'methods' do
    subject(:resource) { HelloSign::Resource::BaseResource.new data }

    it 'can access attributes by calling method with the same name' do
      data.keys.each do |key|
        expect(resource.send key).not_to be_nil
      end
    end

    it 'make a hash value into a new HelloSign::Resource::BaseResource' do
      expect(resource.c).to be_an HelloSign::Resource::BaseResource
    end

    it 'do not touch array value with basic type' do
      expect(resource.d).to eql(data[:d])
    end

    it 'make a array value with each item is a hash into array of HelloSign::Resource::BaseResource' do
      expect(resource.e).to be_an Array
      expect(resource.e[0]).to be_an HelloSign::Resource::BaseResource
    end
  end

  describe '#initialize' do
    context 'without key params' do
      subject(:resource) { HelloSign::Resource::BaseResource.new data }
      it 'have correct data' do
        expect(resource.data).to eql(data)
      end
    end

    context 'without key params' do
      subject(:resource) { HelloSign::Resource::BaseResource.new data, :e }
      it 'have correct data' do
        expect(resource.data).to eql(data[:e])
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
hellosign-ruby-sdk-3.0.6 spec/hello_sign/resource/base_resource_spec.rb
hellosign-ruby-sdk-3.0.5 spec/hello_sign/resource/base_resource_spec.rb
hellosign-ruby-sdk-3.0.4 spec/hello_sign/resource/base_resource_spec.rb