Sha256: 2e7b2cd91ec1ee545ace051b21e1a88bb6b8c79fa03d1bc25bcbf86b06cce334

Contents?: true

Size: 1.9 KB

Versions: 33

Compression:

Stored size: 1.9 KB

Contents

require './test/test_helper'

class RedemptionTest < Minitest::Test

  def get_first_redemption
    VCR.use_cassette('search redemption by member key') do
      @first_redemption = Access::Redemption.search_by_member('API_RUBY_GEM_TEST').offer_redemptions.first
    end
  end

  def test_search_offer_redemptions_by_member
    VCR.use_cassette('search redemption by member key') do
      redemption_response = Access::Redemption.search_by_member('API_RUBY_GEM_TEST')
      assert redemption_response.success
      assert_kind_of Access::RedemptionResponse, redemption_response
      assert_kind_of Access::Offer, redemption_response.offer_redemptions.first.offer
      assert_kind_of Access::Member, redemption_response.offer_redemptions.first.member
      assert_kind_of Access::Link, redemption_response.links
    end
  end

  def test_find_offer_redemptions_by_member
    get_first_redemption
    VCR.use_cassette('find redemption by member key') do
      redemption_response = Access::Redemption.find_by_member('API_RUBY_GEM_TEST', @first_redemption.usage_redeem_key)
      assert redemption_response.success
      assert_kind_of Access::RedemptionResponse, redemption_response
      assert_kind_of Access::Offer, redemption_response.offer_redemptions.first.offer
      assert_kind_of Access::Member, redemption_response.offer_redemptions.first.member
    end
  end

  def test_search_offer_redemptions_by_member_with_no_redemptions
    VCR.use_cassette('search redemption by member key without redemptions') do
      redemption_response = Access::Redemption.search_by_member('API_RUBY_GEM_TEST_NOREDEMPTIONS')
      refute redemption_response.success
      assert_kind_of Access::RedemptionResponse, redemption_response
      assert_kind_of Access::Error, redemption_response.error
      assert_equal 200, redemption_response.error.status_code
      assert_equal "No redemptions found.", redemption_response.error.message
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
access-2.0.48 test/access/redemption_test.rb
access-2.0.47 test/access/redemption_test.rb
access-2.0.46 test/access/redemption_test.rb
access-2.0.44 test/access/redemption_test.rb
access-2.0.43 test/access/redemption_test.rb
access-2.0.42 test/access/redemption_test.rb
access-2.0.41 test/access/redemption_test.rb
access-2.0.40 test/access/redemption_test.rb
access-2.0.39 test/access/redemption_test.rb
access-2.0.38 test/access/redemption_test.rb
access-2.0.37 test/access/redemption_test.rb
access-2.0.36 test/access/redemption_test.rb
access-2.0.34 test/access/redemption_test.rb
access-2.0.33 test/access/redemption_test.rb
access-2.0.32 test/access/redemption_test.rb
access-2.0.31 test/access/redemption_test.rb
access-2.0.30 test/access/redemption_test.rb
access-2.0.29 test/access/redemption_test.rb
access-2.0.28 test/access/redemption_test.rb
access-2.0.27 test/access/redemption_test.rb