Sha256: fa6c0ba3c64e108dd6e5723403e2aa4bcbd34a780d8d9693de616d896fc24d53

Contents?: true

Size: 1.91 KB

Versions: 9

Compression:

Stored size: 1.91 KB

Contents

require './test/test_helper'

class MemberTest < Minitest::Test

  def test_register_success
    VCR.use_cassette('member register success') do
      request = Access::Member.register registration_params
      assert request.success
      assert_kind_of Access::MemberResponse, request
      assert_kind_of Array, request.users
      assert_equal 1, request.users.count
      assert_kind_of Access::Member, request.users.first
    end
  end

  def test_register_failure
    VCR.use_cassette('member register failure') do
      request = Access::Member.register registration_params.merge(email: nil)
      refute request.success
      assert_equal 400, request.status
      assert_kind_of Access::MemberResponse, request
      refute_nil request.error
      assert_kind_of Access::Error, request.error
    end
  end

  def test_authenticate_success
    VCR.use_cassette('member authenticate success') do
      request = Access::Member.authenticate email: 'ben@test.com', password: 'password'
      assert request.success
      assert_kind_of Access::MemberResponse, request
      assert_kind_of Array, request.users
      assert_equal 1, request.users.count
      assert_kind_of Access::Member, request.users.first
    end
  end

  def test_authenticate_failure
    VCR.use_cassette('member authenticate failure') do
      request = Access::Member.authenticate email: 'ben@test.com', password: 'bad'
      refute request.success
      assert_equal 401, request.status
      assert_kind_of Access::MemberResponse, request
      refute_nil request.error
      assert_kind_of Access::Error, request.error
    end
  end

  def registration_params
    {
      program_id: 2412,
      first_name: 'RubyGem',
      last_name: 'Test',
      postal_code: 84047,
      email: "rubygemtest-3@accessdevelopment.com",
      password: 'test1234',
      shared_secret: 'thanks',
      program_url: "saversclub.accessdevelopment.com",
      access_timeout: 180
    }
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
access-2.0.25 test/access/member_test.rb
access-2.0.24 test/access/member_test.rb
access-2.0.23 test/access/member_test.rb
access-2.0.22 test/access/member_test.rb
access-2.0.21 test/access/member_test.rb
access-2.0.20 test/access/member_test.rb
access-2.0.19 test/access/member_test.rb
access-2.0.18 test/access/member_test.rb
access-2.0.17 test/access/member_test.rb