forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheql_spec.rb
More file actions
92 lines (68 loc) · 1.86 KB
/
eql_spec.rb
File metadata and controls
92 lines (68 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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