Sha256: c95783d35ae8c56cc3ad2298d91b6a864335a9a766032a65ed18afc35ac7d329

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

require_relative '../test_helper'

class ParametersHelperTest < MiniTest::Test
  def setup
    @parameters = Helper::Parameters.new(:do_it)
  end

  def test_has_an_action_key
    assert_equal 'DoIt', @parameters.fetch('Action')
  end

  def test_formats_timestamps
    ts = Minitest::Mock.new
    ts.expect(:iso8601, 'formatted')
    @parameters.store('a timestamp', ts)
    assert_equal 'formatted', @parameters.timestamp!.fetch('a timestamp')
  end

  def test_formats_structured_lists
    @parameters.store(:order_status, 'foo')
    assert_equal 'foo', @parameters.format_structured_lists!.fetch('OrderStatus.Status.1')
  end

  def test_camelizes_keys
    @parameters.store(:underscored_key, 'baz')
    refute @parameters.camelize_keys!.has_key?(:underscored_key)
    assert @parameters.has_key?('UnderscoredKey')
  end

  def test_updates_delegated_hash
    assert_kind_of Helper::Parameters, @parameters.update(key: 'value')
    assert_equal 'value', @parameters.fetch(:key)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mws-orders-0.0.2 test/helpers/parameters_test.rb
mws-orders-0.0.1 test/helpers/parameters_test.rb