Sha256: df3502655831ce2c9be1207a023bc503c23947b85b1373dd5053b98884b841c3

Contents?: true

Size: 1.86 KB

Versions: 15

Compression:

Stored size: 1.86 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::ResponseWrapper, '#eql?' do
  let(:env) {
     { :status => 404, :body => 'some',
      :response_headers => {'Content-Type' => 'text/plain'} }
  }
  let(:res) { Faraday::Response.new env }
  let(:object) { described_class.new res, nil }

  subject { object.eql?(other) }

  context 'with the same object' do
    let(:other) { object }

    it { expect(object.body).to eql('some') }

    it { should be_true }

    it 'is symmetric' do
      should eql(other.eql?(object))
    end
  end

  context 'with an equivalent object' do
    let(:other) { object.dup }

    it { should be_true }

    it 'is symmetric' do
      should eql(other.eql?(object))
    end
  end

  context 'with object having a nil body' do
    let(:other_env) { { :body => nil }}
    let(:other_res) { Faraday::Response.new other_env }
    let(:other) { described_class.new(other_res, nil) }

    it { expect(other.body).to be_nil }

    it { should be_false }

    it 'is symmetric' do
      should eql(other.eql?(object))
    end
  end

  context 'with object having different body' do
    let(:other_env) { { :body => ["some"] }}
    let(:other_res) { Faraday::Response.new other_env }
    let(:other) { described_class.new(other_res, nil) }

    it { expect(other.body).to eql(["some"]) }

    it { should be_false }

    it 'is symmetric' do
      should eql(other.eql?(object))
    end
  end

  context 'with object having no environment' do
    let(:other) {
      ::Class.new do
        def body; ['some'] end
      end.new
    }

    it { should be_false }

    it 'is symmetric' do
      should eql(other.eql?(object))
    end
  end

  context 'with object having no body' do
    let(:other) {
      ::Class.new do
        def env; end
      end.new
    }

    it { should be_false }

    it 'is symmetric' do
      should eql(other.eql?(object))
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
github_api-0.12.3 spec/github/response_wrapper/eql_spec.rb
github_api-0.12.2 spec/github/response_wrapper/eql_spec.rb
github_api-0.12.1 spec/github/response_wrapper/eql_spec.rb
github_api-0.12.0 spec/github/response_wrapper/eql_spec.rb
github_api-0.11.3 spec/github/response_wrapper/eql_spec.rb
github_api-0.11.2 spec/github/response_wrapper/eql_spec.rb
github_api-0.11.1 spec/github/response_wrapper/eql_spec.rb
github_api-0.11.0 spec/github/response_wrapper/eql_spec.rb
github_api-0.10.2 spec/github/response_wrapper/eql_spec.rb
github_api-0.10.1 spec/github/response_wrapper/eql_spec.rb
github_api-0.10.0 spec/github/response_wrapper/eql_spec.rb
github_api-0.9.7 spec/github/response_wrapper/eql_spec.rb
github_api-0.9.6 spec/github/response_wrapper/eql_spec.rb
github_api-0.9.5 spec/github/response_wrapper/eql_spec.rb
github_api-0.9.4 spec/github/response_wrapper/eql_spec.rb