Sha256: b97d44bf53e3fc77f1833db8879d5ba1371dd87373965b5eb93b79f049e5ca89

Contents?: true

Size: 953 Bytes

Versions: 13

Compression:

Stored size: 953 Bytes

Contents

require 'spec_helper'
require 'support/oauth2_helper'

describe SparkApi::Authentication::OAuth2Impl::SparkbarFaradayMiddleware do
  subject { SparkApi::Authentication::OAuth2Impl::SparkbarFaradayMiddleware.new("test") }
  # Make sure the client boostraps the right plugin based on configuration.
  it "should parse token on successful response" do
    env = {
      :body => '{"token":"sp4rkb4rt0k3n"}',
      :status => 201
    }
    subject.on_complete env
    expect(env[:body]["token"]).to eq("sp4rkb4rt0k3n")
  end
  
  it "should raise error on unsuccessful response" do
    env = {
      :body => '{"token":"sp4rkb4rt0k3n"}',
      :status => 500
    }
    expect {subject.on_complete env }.to raise_error(SparkApi::ClientError)
  end

  it "should raise error on invalid json" do
    env = {
      :body => '{"BORKBORKBORK"}',
      :status => 200
    }
    expect {subject.on_complete env }.to raise_error(MultiJson::DecodeError)
  end
  
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
spark_api-2.0.0 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.6.3 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.6.2 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.6.1 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.5.7 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.6.0 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.5.6 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.5.5 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.5.4 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.5.3 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.5.2 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.5.1 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb
spark_api-1.5.0 spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb