Sha256: 875fcce2733a1e16504d977c0bd70f6d7138919e09b5d10607837b3875c4d449

Contents?: true

Size: 820 Bytes

Versions: 7

Compression:

Stored size: 820 Bytes

Contents

require 'spec_helper'

describe "Authy::Response" do
  before :each do
    @fake_response = OpenStruct.new
    @fake_response.body = {'v1' => 'r1','v2' => 42}.to_json
    @fake_response.status = 200

    @response = Authy::Response.new(@fake_response)
  end

  it "should parse to json the body" do
    @response['v2'].should == 42
  end

  it "should be ok if the return code is 200" do
    @response.ok?.should be_true

    @fake_response.status = 401
    @response = Authy::Response.new(@fake_response)
    @response.ok?.should be_false
  end

  it "should return the error message" do
    @response.error_msg.should == "No error"

    @fake_response.body = 'invalid json'
    @fake_response.status = 401
    @response = Authy::Response.new(@fake_response)

    @response.error_msg.should == "invalid json"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
authy-2.3.1 spec/authy/response_spec.rb
authy-2.3.0 spec/authy/response_spec.rb
authy-2.2.0 spec/authy/response_spec.rb
authy-2.1.0 spec/authy/response_spec.rb
authy-2.0.1 spec/authy/response_spec.rb
authy-1.1.0 spec/authy/response_spec.rb
authy-1.0.0 spec/authy/response_spec.rb