koala 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,27 +5,27 @@ describe "legacy APIs" do
5
5
 
6
6
  it "deprecates the REST API" do
7
7
  api = Koala::Facebook::API.new
8
- api.stub(:api)
9
- Koala::Utils.should_receive(:deprecate)
8
+ allow(api).to receive(:api)
9
+ expect(Koala::Utils).to receive(:deprecate)
10
10
  api.rest_call("stuff")
11
11
  end
12
12
 
13
13
  describe Koala::Facebook::GraphAPI do
14
14
  describe "class consolidation" do
15
15
  before :each do
16
- Koala::Utils.stub(:deprecate) # avoid actual messages to stderr
16
+ allow(Koala::Utils).to receive(:deprecate) # avoid actual messages to stderr
17
17
  end
18
18
 
19
19
  it "still allows you to instantiate a GraphAndRestAPI object" do
20
- api = Koala::Facebook::GraphAPI.new("token").should be_a(Koala::Facebook::GraphAPI)
20
+ api = expect(Koala::Facebook::GraphAPI.new("token")).to be_a(Koala::Facebook::GraphAPI)
21
21
  end
22
22
 
23
23
  it "ultimately creates an API object" do
24
- api = Koala::Facebook::GraphAPI.new("token").should be_a(Koala::Facebook::API)
24
+ api = expect(Koala::Facebook::GraphAPI.new("token")).to be_a(Koala::Facebook::API)
25
25
  end
26
26
 
27
27
  it "fires a depreciation warning" do
28
- Koala::Utils.should_receive(:deprecate)
28
+ expect(Koala::Utils).to receive(:deprecate)
29
29
  api = Koala::Facebook::GraphAPI.new("token")
30
30
  end
31
31
  end
@@ -34,19 +34,19 @@ describe "legacy APIs" do
34
34
  describe Koala::Facebook::RestAPI do
35
35
  describe "class consolidation" do
36
36
  before :each do
37
- Koala::Utils.stub(:deprecate) # avoid actual messages to stderr
37
+ allow(Koala::Utils).to receive(:deprecate) # avoid actual messages to stderr
38
38
  end
39
39
 
40
40
  it "still allows you to instantiate a GraphAndRestAPI object" do
41
- api = Koala::Facebook::RestAPI.new("token").should be_a(Koala::Facebook::RestAPI)
41
+ api = expect(Koala::Facebook::RestAPI.new("token")).to be_a(Koala::Facebook::RestAPI)
42
42
  end
43
43
 
44
44
  it "ultimately creates an API object" do
45
- api = Koala::Facebook::RestAPI.new("token").should be_a(Koala::Facebook::API)
45
+ api = expect(Koala::Facebook::RestAPI.new("token")).to be_a(Koala::Facebook::API)
46
46
  end
47
47
 
48
48
  it "fires a depreciation warning" do
49
- Koala::Utils.should_receive(:deprecate)
49
+ expect(Koala::Utils).to receive(:deprecate)
50
50
  api = Koala::Facebook::RestAPI.new("token")
51
51
  end
52
52
  end
@@ -55,19 +55,19 @@ describe "legacy APIs" do
55
55
  describe Koala::Facebook::GraphAndRestAPI do
56
56
  describe "class consolidation" do
57
57
  before :each do
58
- Koala::Utils.stub(:deprecate) # avoid actual messages to stderr
58
+ allow(Koala::Utils).to receive(:deprecate) # avoid actual messages to stderr
59
59
  end
60
60
 
61
61
  it "still allows you to instantiate a GraphAndRestAPI object" do
62
- api = Koala::Facebook::GraphAndRestAPI.new("token").should be_a(Koala::Facebook::GraphAndRestAPI)
62
+ api = expect(Koala::Facebook::GraphAndRestAPI.new("token")).to be_a(Koala::Facebook::GraphAndRestAPI)
63
63
  end
64
64
 
65
65
  it "ultimately creates an API object" do
66
- api = Koala::Facebook::GraphAndRestAPI.new("token").should be_a(Koala::Facebook::API)
66
+ api = expect(Koala::Facebook::GraphAndRestAPI.new("token")).to be_a(Koala::Facebook::API)
67
67
  end
68
68
 
69
69
  it "fires a depreciation warning" do
70
- Koala::Utils.should_receive(:deprecate)
70
+ expect(Koala::Utils).to receive(:deprecate)
71
71
  api = Koala::Facebook::GraphAndRestAPI.new("token")
72
72
  end
73
73
  end
@@ -76,40 +76,40 @@ describe "legacy APIs" do
76
76
  {:typhoeus => Koala::TyphoeusService, :net_http => Koala::NetHTTPService}.each_pair do |adapter, module_class|
77
77
  describe module_class.to_s do
78
78
  it "responds to deprecated_interface" do
79
- module_class.should respond_to(:deprecated_interface)
79
+ expect(module_class).to respond_to(:deprecated_interface)
80
80
  end
81
81
 
82
82
  it "issues a deprecation warning" do
83
- Koala::Utils.should_receive(:deprecate)
83
+ expect(Koala::Utils).to receive(:deprecate)
84
84
  module_class.deprecated_interface
85
85
  end
86
86
 
87
87
  it "sets the default adapter to #{adapter}" do
88
88
  module_class.deprecated_interface
89
- Faraday.default_adapter.should == adapter
89
+ expect(Faraday.default_adapter).to eq(adapter)
90
90
  end
91
91
  end
92
92
  end
93
93
 
94
94
  describe "moved classes" do
95
95
  it "allows you to access Koala::HTTPService::MultipartRequest through the Koala module" do
96
- Koala::MultipartRequest.should == Koala::HTTPService::MultipartRequest
96
+ expect(Koala::MultipartRequest).to eq(Koala::HTTPService::MultipartRequest)
97
97
  end
98
98
 
99
99
  it "allows you to access Koala::Response through the Koala module" do
100
- Koala::Response.should == Koala::HTTPService::Response
100
+ expect(Koala::Response).to eq(Koala::HTTPService::Response)
101
101
  end
102
102
 
103
103
  it "allows you to access Koala::Response through the Koala module" do
104
- Koala::UploadableIO.should == Koala::HTTPService::UploadableIO
104
+ expect(Koala::UploadableIO).to eq(Koala::HTTPService::UploadableIO)
105
105
  end
106
106
 
107
107
  it "allows you to access Koala::Facebook::GraphBatchAPI::BatchOperation through the Koala::Facebook module" do
108
- Koala::Facebook::BatchOperation.should == Koala::Facebook::GraphBatchAPI::BatchOperation
108
+ expect(Koala::Facebook::BatchOperation).to eq(Koala::Facebook::GraphBatchAPI::BatchOperation)
109
109
  end
110
110
 
111
111
  it "allows you to access Koala::Facebook::API::GraphCollection through the Koala::Facebook module" do
112
- Koala::Facebook::GraphCollection.should == Koala::Facebook::API::GraphCollection
112
+ expect(Koala::Facebook::GraphCollection).to eq(Koala::Facebook::API::GraphCollection)
113
113
  end
114
114
  end
115
115
  end
@@ -2,65 +2,64 @@ require 'spec_helper'
2
2
 
3
3
  describe Koala::HTTPService::MultipartRequest do
4
4
  it "is a subclass of Faraday::Request::Multipart" do
5
- Koala::HTTPService::MultipartRequest.superclass.should == Faraday::Request::Multipart
5
+ expect(Koala::HTTPService::MultipartRequest.superclass).to eq(Faraday::Request::Multipart)
6
6
  end
7
-
7
+
8
8
  it "defines mime_type as multipart/form-data" do
9
- Koala::HTTPService::MultipartRequest.mime_type.should == 'multipart/form-data'
9
+ expect(Koala::HTTPService::MultipartRequest.mime_type).to eq('multipart/form-data')
10
10
  end
11
-
11
+
12
12
  describe "#process_request?" do
13
13
  before :each do
14
- @env = {}
14
+ @env = Faraday::Env.new
15
15
  @multipart = Koala::HTTPService::MultipartRequest.new
16
- @multipart.stub(:request_type).and_return("")
16
+ allow(@multipart).to receive(:request_type).and_return("")
17
17
  end
18
-
18
+
19
19
  # no way to test the call to super, unfortunately
20
20
  it "returns true if env[:body] is a hash with at least one hash in its values" do
21
21
  @env[:body] = {:a => {:c => 2}}
22
- @multipart.process_request?(@env).should be_true
22
+ expect(@multipart.process_request?(@env)).to be_truthy
23
23
  end
24
24
 
25
25
  it "returns true if env[:body] is a hash with at least one array in its values" do
26
26
  @env[:body] = {:a => [:c, 2]}
27
- @multipart.process_request?(@env).should be_true
27
+ expect(@multipart.process_request?(@env)).to be_truthy
28
28
  end
29
29
 
30
30
  it "returns true if env[:body] is a hash with mixed objects in its values" do
31
31
  @env[:body] = {:a => [:c, 2], :b => {:e => :f}}
32
- @multipart.process_request?(@env).should be_true
32
+ expect(@multipart.process_request?(@env)).to be_truthy
33
33
  end
34
34
 
35
35
  it "returns false if env[:body] is a string" do
36
36
  @env[:body] = "my body"
37
- @multipart.process_request?(@env).should be_false
37
+ expect(@multipart.process_request?(@env)).to be_falsey
38
38
  end
39
39
 
40
40
  it "returns false if env[:body] is a hash without an array or hash value" do
41
41
  @env[:body] = {:a => 3}
42
- @multipart.process_request?(@env).should be_false
43
- end
42
+ expect(@multipart.process_request?(@env)).to be_falsey
43
+ end
44
44
  end
45
-
45
+
46
46
  describe "#process_params" do
47
47
  before :each do
48
48
  @parent = Faraday::Request::Multipart.new
49
- @multipart = Koala::HTTPService::MultipartRequest.new
50
- @block = lambda {|k, v| "#{k}=#{v}"}
49
+ @multipart = Koala::HTTPService::MultipartRequest.new
50
+ @block = lambda {|k, v| "#{k}=#{v}"}
51
51
  end
52
-
52
+
53
53
  it "is identical to the parent for requests without a prefix" do
54
54
  hash = {:a => 2, :c => "3"}
55
- @multipart.process_params(hash, &@block).should == @parent.process_params(hash, &@block)
55
+ expect(@multipart.process_params(hash, &@block)).to eq(@parent.process_params(hash, &@block))
56
56
  end
57
-
57
+
58
58
  it "replaces encodes [ and ] if the request has a prefix" do
59
59
  hash = {:a => 2, :c => "3"}
60
60
  prefix = "foo"
61
61
  # process_params returns an array
62
- @multipart.process_params(hash, prefix, &@block).join("&").should == @parent.process_params(hash, prefix, &@block).join("&").gsub(/\[/, "%5B").gsub(/\]/, "%5D")
62
+ expect(@multipart.process_params(hash, prefix, &@block).join("&")).to eq(@parent.process_params(hash, prefix, &@block).join("&").gsub(/\[/, "%5B").gsub(/\]/, "%5D"))
63
63
  end
64
64
  end
65
-
66
65
  end