require 'test_helper' module SsciInc class ResponseTest < Test::Unit::TestCase subject { Response.new(TEST_ERROR_RESPONSE) } should_have_attr_reader :user_id, :password, :reference_id, :reference, :order_id, :order_status should_have_attr_reader :error_code, :error_description should_have_attr_reader :result_status, :order_status_flag, :screening_results_type, :screening_results_media_type, :screening_results_result_type, :result_url should_have_attr_reader :data context "#new" do context "error response" do subject { Response.new(TEST_ERROR_RESPONSE) } should "have populated error attributes" do assert_equal "x:error", subject.order_status assert_equal "4", subject.error_code assert_equal "Invalid username and/or password.", subject.error_description assert_equal "some_id_value", subject.reference_id assert_equal "ABC Company Inc.", subject.reference end end context "pending response" do subject { Response.new(TEST_PENDING_RESPONSE) } should "have populated order status" do assert_equal "x:pending", subject.order_status assert_equal "12358", subject.order_id assert_equal "some_id_value", subject.reference_id assert_equal "ABC Company Inc.", subject.reference end end context "callback response" do subject { Response.new(TEST_CALLBACK_RESPONSE) } should "have a result status and result info" do assert_equal "x:ready", subject.order_status assert_equal "Pass", subject.result_status assert_equal "FALSE", subject.order_status_flag assert_equal "result", subject.screening_results_type assert_equal "html", subject.screening_results_media_type assert_equal "report", subject.screening_results_result_type assert_equal "display.php", subject.result_url assert_equal "username", subject.user_id assert_equal "password", subject.password assert_equal "12358", subject.order_id assert_equal "some_id_value", subject.reference_id assert_equal "ABC Company Inc.", subject.reference end end end end end