koala 1.8.0 → 1.9.0rc1

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.
@@ -16,7 +16,7 @@ describe "Koala::UploadableIO" do
16
16
  :tempfile => tempfile,
17
17
  :original_filename => "bar"
18
18
  )
19
- tempfile.stub(:respond_to?).with(:path).and_return(true)
19
+ allow(tempfile).to receive(:respond_to?).with(:path).and_return(true)
20
20
 
21
21
  [tempfile, uploaded_file]
22
22
  end
@@ -39,15 +39,15 @@ describe "Koala::UploadableIO" do
39
39
  end
40
40
 
41
41
  it "returns an UploadIO with the same file path" do
42
- Koala::UploadableIO.new(*@koala_io_params).io_or_path.should == @path
42
+ expect(Koala::UploadableIO.new(*@koala_io_params).io_or_path).to eq(@path)
43
43
  end
44
44
 
45
45
  it "returns an UploadIO with the same content type" do
46
- Koala::UploadableIO.new(*@koala_io_params).content_type.should == @stub_type
46
+ expect(Koala::UploadableIO.new(*@koala_io_params).content_type).to eq(@stub_type)
47
47
  end
48
48
 
49
49
  it "returns an UploadIO with the file's name" do
50
- Koala::UploadableIO.new(*@koala_io_params).filename.should == File.basename(@path)
50
+ expect(Koala::UploadableIO.new(*@koala_io_params).filename).to eq(File.basename(@path))
51
51
  end
52
52
  end
53
53
 
@@ -68,16 +68,16 @@ describe "Koala::UploadableIO" do
68
68
  end
69
69
 
70
70
  it "returns an UploadIO with the same io" do
71
- Koala::UploadableIO.new(*@koala_io_params).io_or_path.should == @koala_io_params[0]
71
+ expect(Koala::UploadableIO.new(*@koala_io_params).io_or_path).to eq(@koala_io_params[0])
72
72
  end
73
73
 
74
74
  it "returns an UploadableIO with the same content_type" do
75
75
  content_stub = @koala_io_params[1] = double('Content Type')
76
- Koala::UploadableIO.new(*@koala_io_params).content_type.should == content_stub
76
+ expect(Koala::UploadableIO.new(*@koala_io_params).content_type).to eq(content_stub)
77
77
  end
78
78
 
79
79
  it "returns an UploadableIO with the right filename" do
80
- Koala::UploadableIO.new(*@koala_io_params).filename.should == File.basename(@file.path)
80
+ expect(Koala::UploadableIO.new(*@koala_io_params).filename).to eq(File.basename(@file.path))
81
81
  end
82
82
  end
83
83
 
@@ -100,16 +100,16 @@ describe "Koala::UploadableIO" do
100
100
 
101
101
  it "returns an UploadIO with the same io" do
102
102
  #Problem comparing Tempfile in Ruby 1.8, REE and Rubinius mode 1.8
103
- Koala::UploadableIO.new(*@koala_io_params).io_or_path.path.should == @koala_io_params[0].path
103
+ expect(Koala::UploadableIO.new(*@koala_io_params).io_or_path.path).to eq(@koala_io_params[0].path)
104
104
  end
105
105
 
106
106
  it "returns an UploadableIO with the same content_type" do
107
107
  content_stub = @koala_io_params[1] = double('Content Type')
108
- Koala::UploadableIO.new(*@koala_io_params).content_type.should == content_stub
108
+ expect(Koala::UploadableIO.new(*@koala_io_params).content_type).to eq(content_stub)
109
109
  end
110
110
 
111
111
  it "returns an UploadableIO with the right filename" do
112
- Koala::UploadableIO.new(*@koala_io_params).filename.should == File.basename(@file.path)
112
+ expect(Koala::UploadableIO.new(*@koala_io_params).filename).to eq(File.basename(@file.path))
113
113
  end
114
114
  end
115
115
 
@@ -130,18 +130,18 @@ describe "Koala::UploadableIO" do
130
130
  end
131
131
 
132
132
  it "returns an UploadableIO with the same io" do
133
- Koala::UploadableIO.new(*@koala_io_params).io_or_path.should == @koala_io_params[0]
133
+ expect(Koala::UploadableIO.new(*@koala_io_params).io_or_path).to eq(@koala_io_params[0])
134
134
  end
135
135
 
136
136
  it "returns an UploadableIO with the same content_type" do
137
137
  content_stub = @koala_io_params[1] = double('Content Type')
138
- Koala::UploadableIO.new(*@koala_io_params).content_type.should == content_stub
138
+ expect(Koala::UploadableIO.new(*@koala_io_params).content_type).to eq(content_stub)
139
139
  end
140
140
  end
141
141
 
142
142
  describe "and no content type" do
143
143
  it "raises an exception" do
144
- lambda { Koala::UploadableIO.new(*@koala_io_params) }.should raise_exception(Koala::KoalaError)
144
+ expect { Koala::UploadableIO.new(*@koala_io_params) }.to raise_exception(Koala::KoalaError)
145
145
  end
146
146
  end
147
147
  end
@@ -153,18 +153,18 @@ describe "Koala::UploadableIO" do
153
153
 
154
154
  it "gets the path from the tempfile associated with the UploadedFile" do
155
155
  expected_path = double('Tempfile')
156
- @tempfile.should_receive(:path).and_return(expected_path)
157
- Koala::UploadableIO.new(@uploaded_file).io_or_path.should == expected_path
156
+ expect(@tempfile).to receive(:path).and_return(expected_path)
157
+ expect(Koala::UploadableIO.new(@uploaded_file).io_or_path).to eq(expected_path)
158
158
  end
159
159
 
160
160
  it "gets the content type via the content_type method" do
161
161
  expected_content_type = double('Content Type')
162
- @uploaded_file.should_receive(:content_type).and_return(expected_content_type)
163
- Koala::UploadableIO.new(@uploaded_file).content_type.should == expected_content_type
162
+ expect(@uploaded_file).to receive(:content_type).and_return(expected_content_type)
163
+ expect(Koala::UploadableIO.new(@uploaded_file).content_type).to eq(expected_content_type)
164
164
  end
165
165
 
166
166
  it "gets the filename from the UploadedFile" do
167
- Koala::UploadableIO.new(@uploaded_file).filename.should == @uploaded_file.original_filename
167
+ expect(Koala::UploadableIO.new(@uploaded_file).filename).to eq(@uploaded_file.original_filename)
168
168
  end
169
169
  end
170
170
 
@@ -178,7 +178,7 @@ describe "Koala::UploadableIO" do
178
178
  @file_hash[:tempfile] = expected_file
179
179
 
180
180
  uploadable = Koala::UploadableIO.new(@file_hash)
181
- uploadable.io_or_path.should == expected_file
181
+ expect(uploadable.io_or_path).to eq(expected_file)
182
182
  end
183
183
 
184
184
  it "gets the content type from the :type key" do
@@ -186,12 +186,12 @@ describe "Koala::UploadableIO" do
186
186
  @file_hash[:type] = expected_content_type
187
187
 
188
188
  uploadable = Koala::UploadableIO.new(@file_hash)
189
- uploadable.content_type.should == expected_content_type
189
+ expect(uploadable.content_type).to eq(expected_content_type)
190
190
  end
191
191
 
192
192
  it "gets the content type from the :type key" do
193
193
  uploadable = Koala::UploadableIO.new(@file_hash)
194
- uploadable.filename.should == @file_hash[:filename]
194
+ expect(uploadable.filename).to eq(@file_hash[:filename])
195
195
  end
196
196
  end
197
197
 
@@ -199,12 +199,12 @@ describe "Koala::UploadableIO" do
199
199
  # what that means is tested below
200
200
  it "should accept a file object alone" do
201
201
  params = [BEACH_BALL_PATH]
202
- lambda { Koala::UploadableIO.new(*params) }.should_not raise_exception
202
+ expect { Koala::UploadableIO.new(*params) }.not_to raise_exception
203
203
  end
204
204
 
205
205
  it "should accept a file path alone" do
206
206
  params = [BEACH_BALL_PATH]
207
- lambda { Koala::UploadableIO.new(*params) }.should_not raise_exception
207
+ expect { Koala::UploadableIO.new(*params) }.not_to raise_exception
208
208
  end
209
209
  end
210
210
  end
@@ -212,20 +212,20 @@ describe "Koala::UploadableIO" do
212
212
  describe "getting an UploadableIO" do
213
213
  before(:each) do
214
214
  @upload_io = double("UploadIO")
215
- UploadIO.stub(:new).with(anything, anything, anything).and_return(@upload_io)
215
+ allow(UploadIO).to receive(:new).with(anything, anything, anything).and_return(@upload_io)
216
216
  end
217
217
 
218
218
  context "if no filename was provided" do
219
219
  it "should call the constructor with the content type, file name, and a dummy file name" do
220
- UploadIO.should_receive(:new).with(BEACH_BALL_PATH, "content/type", anything).and_return(@upload_io)
221
- Koala::UploadableIO.new(BEACH_BALL_PATH, "content/type").to_upload_io.should == @upload_io
220
+ expect(UploadIO).to receive(:new).with(BEACH_BALL_PATH, "content/type", anything).and_return(@upload_io)
221
+ expect(Koala::UploadableIO.new(BEACH_BALL_PATH, "content/type").to_upload_io).to eq(@upload_io)
222
222
  end
223
223
  end
224
224
 
225
225
  context "if a filename was provided" do
226
226
  it "should call the constructor with the content type, file name, and the filename" do
227
227
  filename = "file"
228
- UploadIO.should_receive(:new).with(BEACH_BALL_PATH, "content/type", filename).and_return(@upload_io)
228
+ expect(UploadIO).to receive(:new).with(BEACH_BALL_PATH, "content/type", filename).and_return(@upload_io)
229
229
  Koala::UploadableIO.new(BEACH_BALL_PATH, "content/type", filename).to_upload_io
230
230
  end
231
231
  end
@@ -234,33 +234,33 @@ describe "Koala::UploadableIO" do
234
234
  describe "getting a file" do
235
235
  it "returns the File if initialized with a file" do
236
236
  f = File.new(BEACH_BALL_PATH)
237
- Koala::UploadableIO.new(f).to_file.should == f
237
+ expect(Koala::UploadableIO.new(f).to_file).to eq(f)
238
238
  end
239
239
 
240
240
  it "should open up and return a file corresponding to the path if io_or_path is a path" do
241
241
  result = double("File")
242
- File.should_receive(:open).with(BEACH_BALL_PATH).and_return(result)
243
- Koala::UploadableIO.new(BEACH_BALL_PATH).to_file.should == result
242
+ expect(File).to receive(:open).with(BEACH_BALL_PATH).and_return(result)
243
+ expect(Koala::UploadableIO.new(BEACH_BALL_PATH).to_file).to eq(result)
244
244
  end
245
245
  end
246
246
 
247
247
  describe ".binary_content?" do
248
248
  it "returns true for Rails 3 file uploads" do
249
- Koala::UploadableIO.binary_content?(rails_3_mocks.last).should be_true
249
+ expect(Koala::UploadableIO.binary_content?(rails_3_mocks.last)).to be_truthy
250
250
  end
251
251
 
252
252
  it "returns true for Sinatra file uploads" do
253
- Koala::UploadableIO.binary_content?(rails_3_mocks.last).should be_true
253
+ expect(Koala::UploadableIO.binary_content?(rails_3_mocks.last)).to be_truthy
254
254
  end
255
255
 
256
256
  it "returns true for File objects" do
257
- Koala::UploadableIO.binary_content?(File.open(BEACH_BALL_PATH)).should be_true
257
+ expect(Koala::UploadableIO.binary_content?(File.open(BEACH_BALL_PATH))).to be_truthy
258
258
  end
259
259
 
260
260
  it "returns false for everything else" do
261
- Koala::UploadableIO.binary_content?(StringIO.new).should be_false
262
- Koala::UploadableIO.binary_content?(BEACH_BALL_PATH).should be_false
263
- Koala::UploadableIO.binary_content?(nil).should be_false
261
+ expect(Koala::UploadableIO.binary_content?(StringIO.new)).to be_falsey
262
+ expect(Koala::UploadableIO.binary_content?(BEACH_BALL_PATH)).to be_falsey
263
+ expect(Koala::UploadableIO.binary_content?(nil)).to be_falsey
264
264
  end
265
265
  end
266
266
  end # describe UploadableIO
@@ -4,29 +4,29 @@ describe Koala::Utils do
4
4
  describe ".deprecate" do
5
5
  before :each do
6
6
  # unstub deprecate so we can test it
7
- Koala::Utils.unstub(:deprecate)
7
+ allow(Koala::Utils).to receive(:deprecate).and_call_original
8
8
  end
9
9
 
10
10
  it "has a deprecation prefix that includes the words Koala and deprecation" do
11
- Koala::Utils::DEPRECATION_PREFIX.should =~ /koala/i
12
- Koala::Utils::DEPRECATION_PREFIX.should =~ /deprecation/i
11
+ expect(Koala::Utils::DEPRECATION_PREFIX).to match(/koala/i)
12
+ expect(Koala::Utils::DEPRECATION_PREFIX).to match(/deprecation/i)
13
13
  end
14
14
 
15
15
  it "prints a warning with Kernel.warn" do
16
16
  message = Time.now.to_s + rand.to_s
17
- Kernel.should_receive(:warn)
17
+ expect(Kernel).to receive(:warn)
18
18
  Koala::Utils.deprecate(message)
19
19
  end
20
20
 
21
21
  it "prints the deprecation prefix and the warning" do
22
22
  message = Time.now.to_s + rand.to_s
23
- Kernel.should_receive(:warn).with(Koala::Utils::DEPRECATION_PREFIX + message)
23
+ expect(Kernel).to receive(:warn).with(Koala::Utils::DEPRECATION_PREFIX + message)
24
24
  Koala::Utils.deprecate(message)
25
25
  end
26
26
 
27
27
  it "only prints each unique message once" do
28
28
  message = Time.now.to_s + rand.to_s
29
- Kernel.should_receive(:warn).once
29
+ expect(Kernel).to receive(:warn).once
30
30
  Koala::Utils.deprecate(message)
31
31
  Koala::Utils.deprecate(message)
32
32
  end
@@ -34,20 +34,20 @@ describe Koala::Utils do
34
34
 
35
35
  describe ".logger" do
36
36
  it "has an accessor for logger" do
37
- Koala::Utils.methods.map(&:to_sym).should include(:logger)
38
- Koala::Utils.methods.map(&:to_sym).should include(:logger=)
37
+ expect(Koala::Utils.methods.map(&:to_sym)).to include(:logger)
38
+ expect(Koala::Utils.methods.map(&:to_sym)).to include(:logger=)
39
39
  end
40
40
 
41
41
  it "defaults to the standard ruby logger with level set to ERROR" do |variable|
42
- Koala::Utils.logger.should be_kind_of(Logger)
43
- Koala::Utils.logger.level.should == Logger::ERROR
42
+ expect(Koala::Utils.logger).to be_kind_of(Logger)
43
+ expect(Koala::Utils.logger.level).to eq(Logger::ERROR)
44
44
  end
45
45
 
46
46
  logger_methods = [:debug, :info, :warn, :error, :fatal]
47
47
 
48
48
  logger_methods.each do |logger_method|
49
49
  it "should delegate #{logger_method} to the attached logger" do
50
- Koala::Utils.logger.should_receive(logger_method)
50
+ expect(Koala::Utils.logger).to receive(logger_method)
51
51
  Koala::Utils.send(logger_method, "Test #{logger_method} message")
52
52
  end
53
53
  end
data/spec/spec_helper.rb CHANGED
@@ -1,22 +1,3 @@
1
- if RUBY_VERSION == '1.9.2' && RUBY_PATCHLEVEL < 290 && RUBY_ENGINE != "macruby"
2
- # In Ruby 1.9.2 versions before patchlevel 290, the default Psych
3
- # parser has an issue with YAML merge keys, which
4
- # fixtures/mock_facebook_responses.yml relies heavily on.
5
- #
6
- # Anyone using an earlier version will see missing mock response
7
- # errors when running the test suite similar to this:
8
- #
9
- # RuntimeError:
10
- # Missing a mock response for graph_api: /me/videos: source=[FILE]: post: with_token
11
- # API PATH: /me/videos?source=[FILE]&format=json&access_token=*
12
- #
13
- # For now, it seems the best fix is to just downgrade to the old syck YAML parser
14
- # for these troubled versions.
15
- #
16
- # See https://github.com/tenderlove/psych/issues/8 for more details
17
- YAML::ENGINE.yamler = 'syck'
18
- end
19
-
20
1
  # load the library
21
2
  require 'koala'
22
3
 
@@ -7,14 +7,14 @@ RSpec::Matchers.define :match_url do |url|
7
7
  original_query_hash = query_to_params(original_query_string)
8
8
 
9
9
  # the base URLs need to match
10
- base.should == original_base
10
+ expect(base).to eq(original_base)
11
11
 
12
12
  # the number of parameters should match (avoid one being a subset of the other)
13
- query_hash.values.length.should == original_query_hash.values.length
13
+ expect(query_hash.values.length).to eq(original_query_hash.values.length)
14
14
 
15
15
  # and ensure all the keys and values match
16
16
  query_hash.each_pair do |key, value|
17
- original_query_hash[key].should == value
17
+ expect(original_query_hash[key]).to eq(value)
18
18
  end
19
19
  end
20
20
 
@@ -3,7 +3,7 @@ shared_examples_for "Koala GraphAPI" do
3
3
 
4
4
  # API
5
5
  it "never uses the rest api server" do
6
- Koala.should_receive(:make_request).with(
6
+ expect(Koala).to receive(:make_request).with(
7
7
  anything,
8
8
  anything,
9
9
  anything,
@@ -16,42 +16,45 @@ shared_examples_for "Koala GraphAPI" do
16
16
  # GRAPH CALL
17
17
  describe "graph_call" do
18
18
  it "passes all arguments to the api method" do
19
- args = [KoalaTest.user1, {}, "get", {:a => :b}]
20
- @api.should_receive(:api).with(*args)
21
- @api.graph_call(*args)
19
+ user = KoalaTest.user1
20
+ args = {}
21
+ verb = 'get'
22
+ opts = {:a => :b}
23
+ expect(@api).to receive(:api).with(user, args, verb, opts)
24
+ @api.graph_call(user, args, verb, opts)
22
25
  end
23
26
 
24
27
  it "throws an APIError if the result hash has an error key" do
25
- Koala.stub(:make_request).and_return(Koala::HTTPService::Response.new(500, '{"error": "An error occurred!"}', {}))
26
- lambda { @api.graph_call(KoalaTest.user1, {}) }.should raise_exception(Koala::Facebook::APIError)
28
+ allow(Koala).to receive(:make_request).and_return(Koala::HTTPService::Response.new(500, '{"error": "An error occurred!"}', {}))
29
+ expect { @api.graph_call(KoalaTest.user1, {}) }.to raise_exception(Koala::Facebook::APIError)
27
30
  end
28
31
 
29
32
  it "passes the results through GraphCollection.evaluate" do
30
33
  result = {}
31
- @api.stub(:api).and_return(result)
32
- Koala::Facebook::GraphCollection.should_receive(:evaluate).with(result, @api)
34
+ allow(@api).to receive(:api).and_return(result)
35
+ expect(Koala::Facebook::GraphCollection).to receive(:evaluate).with(result, @api)
33
36
  @api.graph_call("/me")
34
37
  end
35
38
 
36
39
  it "returns the results of GraphCollection.evaluate" do
37
40
  expected = {}
38
- @api.stub(:api).and_return([])
39
- Koala::Facebook::GraphCollection.should_receive(:evaluate).and_return(expected)
40
- @api.graph_call("/me").should == expected
41
+ allow(@api).to receive(:api).and_return([])
42
+ expect(Koala::Facebook::GraphCollection).to receive(:evaluate).and_return(expected)
43
+ expect(@api.graph_call("/me")).to eq(expected)
41
44
  end
42
45
 
43
46
  it "returns the post_processing block's results if one is supplied" do
44
47
  other_result = [:a, 2, :three]
45
48
  block = Proc.new {|r| other_result}
46
- @api.stub(:api).and_return({})
47
- @api.graph_call("/me", {}, "get", {}, &block).should == other_result
49
+ allow(@api).to receive(:api).and_return({})
50
+ expect(@api.graph_call("/me", {}, "get", {}, &block)).to eq(other_result)
48
51
  end
49
52
  end
50
53
 
51
54
  # SEARCH
52
55
  it "can search" do
53
56
  result = @api.search("facebook")
54
- result.length.should be_an(Integer)
57
+ expect(result.length).to be_an(Integer)
55
58
  end
56
59
 
57
60
  # DATA
@@ -61,71 +64,71 @@ shared_examples_for "Koala GraphAPI" do
61
64
  it "gets public data about a user" do
62
65
  result = @api.get_object(KoalaTest.user1)
63
66
  # the results should have an ID and a name, among other things
64
- (result["id"] && result["name"]).should_not be_nil
67
+ expect(result["id"] && result["name"]).not_to be_nil
65
68
  end
66
69
 
67
70
  it "gets public data about a Page" do
68
71
  result = @api.get_object(KoalaTest.page)
69
72
  # the results should have an ID and a name, among other things
70
- (result["id"] && result["name"]).should
73
+ expect(result["id"] && result["name"]).to be_truthy
71
74
  end
72
75
 
73
76
  it "returns [] from get_objects if passed an empty array" do
74
77
  results = @api.get_objects([])
75
- results.should == []
78
+ expect(results).to eq([])
76
79
  end
77
80
 
78
81
  it "gets multiple objects" do
79
82
  results = @api.get_objects([KoalaTest.page, KoalaTest.user1])
80
- results.should have(2).items
83
+ expect(results.size).to eq(2)
81
84
  end
82
85
 
83
86
  it "gets multiple objects if they're a string" do
84
87
  results = @api.get_objects("facebook,#{KoalaTest.user1}")
85
- results.should have(2).items
88
+ expect(results.size).to eq(2)
86
89
  end
87
90
 
88
91
  describe "#get_picture" do
89
92
  it "can access a user's picture" do
90
- @api.get_picture(KoalaTest.user2).should =~ /http[s]*\:\/\//
93
+ expect(@api.get_picture(KoalaTest.user2)).to match(/http[s]*\:\/\//)
91
94
  end
92
95
 
93
96
  it "can access a user's picture, given a picture type" do
94
- @api.get_picture(KoalaTest.user2, {:type => 'large'}).should =~ /^http[s]*\:\/\//
97
+ expect(@api.get_picture(KoalaTest.user2, {:type => 'large'})).to match(/^http[s]*\:\/\//)
95
98
  end
96
99
 
97
100
  it "works even if Facebook returns nil" do
98
- @api.stub(:graph_call).and_return(nil)
99
- @api.get_picture(KoalaTest.user2, {:type => 'large'}).should be_nil
101
+ allow(@api).to receive(:graph_call).and_return(nil)
102
+ expect(@api.get_picture(KoalaTest.user2, {:type => 'large'})).to be_nil
100
103
  end
101
104
  end
102
105
 
103
106
  it "can access connections from public Pages" do
104
107
  result = @api.get_connections(KoalaTest.page, "photos")
105
- result.should be_a(Array)
108
+ expect(result).to be_a(Array)
106
109
  end
107
110
 
108
111
  it "can access comments for a URL" do
109
112
  result = @api.get_comments_for_urls(["http://developers.facebook.com/blog/post/472"])
110
- (result["http://developers.facebook.com/blog/post/472"]).should
113
+ expect(result["http://developers.facebook.com/blog/post/472"]).to be_truthy
111
114
  end
112
115
 
113
116
  it "can access comments for 2 URLs" do
114
117
  result = @api.get_comments_for_urls(["http://developers.facebook.com/blog/post/490", "http://developers.facebook.com/blog/post/472"])
115
- (result["http://developers.facebook.com/blog/post/490"] && result["http://developers.facebook.com/blog/post/472"]).should
118
+ expect(result["http://developers.facebook.com/blog/post/490"] && result["http://developers.facebook.com/blog/post/472"]).to be_truthy
116
119
  end
117
120
 
118
121
  # SEARCH
119
122
  it "can search" do
120
123
  result = @api.search("facebook")
121
- result.length.should be_an(Integer)
124
+ expect(result.length).to be_an(Integer)
122
125
  end
123
126
 
124
127
  # PAGING THROUGH COLLECTIONS
125
128
  # see also graph_collection_tests
126
129
  it "makes a request for a page when provided a specific set of page params" do
127
130
  query = [1, 2]
128
- @api.should_receive(:graph_call).with(*query)
131
+ expect(@api).to receive(:graph_call).with(*query)
129
132
  @api.get_page(query)
130
133
  end
131
134
 
@@ -133,41 +136,41 @@ shared_examples_for "Koala GraphAPI" do
133
136
  it "can use the beta tier" do
134
137
  result = @api.get_object(KoalaTest.user1, {}, :beta => true)
135
138
  # the results should have an ID and a name, among other things
136
- (result["id"] && result["name"]).should_not be_nil
139
+ expect(result["id"] && result["name"]).to be_truthy
137
140
  end
138
141
 
139
142
  # FQL
140
143
  describe "#fql_query" do
141
144
  it "makes a request to /fql" do
142
- @api.should_receive(:get_object).with("fql", anything, anything)
145
+ expect(@api).to receive(:get_object).with("fql", anything, anything)
143
146
  @api.fql_query double('query string')
144
147
  end
145
148
 
146
149
  it "passes a query argument" do
147
150
  query = double('query string')
148
- @api.should_receive(:get_object).with(anything, hash_including(:q => query), anything)
151
+ expect(@api).to receive(:get_object).with(anything, hash_including(:q => query), anything)
149
152
  @api.fql_query(query)
150
153
  end
151
154
 
152
155
  it "passes on any other arguments provided" do
153
156
  args = {:a => 2}
154
- @api.should_receive(:get_object).with(anything, hash_including(args), anything)
157
+ expect(@api).to receive(:get_object).with(anything, hash_including(args), anything)
155
158
  @api.fql_query("a query", args)
156
159
  end
157
160
  end
158
161
 
159
162
  describe "#fql_multiquery" do
160
163
  it "makes a request to /fql" do
161
- @api.should_receive(:get_object).with("fql", anything, anything)
164
+ expect(@api).to receive(:get_object).with("fql", anything, anything)
162
165
  @api.fql_multiquery 'query string'
163
166
  end
164
167
 
165
168
  it "passes a queries argument" do
166
169
  queries = double('query string')
167
170
  queries_json = "some JSON"
168
- MultiJson.stub(:dump).with(queries).and_return(queries_json)
171
+ allow(MultiJson).to receive(:dump).with(queries).and_return(queries_json)
169
172
 
170
- @api.should_receive(:get_object).with(anything, hash_including(:q => queries_json), anything)
173
+ expect(@api).to receive(:get_object).with(anything, hash_including(:q => queries_json), anything)
171
174
  @api.fql_multiquery(queries)
172
175
  end
173
176
 
@@ -181,14 +184,14 @@ shared_examples_for "Koala GraphAPI" do
181
184
  "query2" => [:a, :b, :c]
182
185
  }
183
186
 
184
- @api.stub(:get_object).and_return(raw_results)
187
+ allow(@api).to receive(:get_object).and_return(raw_results)
185
188
  results = @api.fql_multiquery({:query => true})
186
- results.should == expected_results
189
+ expect(results).to eq(expected_results)
187
190
  end
188
191
 
189
192
  it "passes on any other arguments provided" do
190
193
  args = {:a => 2}
191
- @api.should_receive(:get_object).with(anything, hash_including(args), anything)
194
+ expect(@api).to receive(:get_object).with(anything, hash_including(args), anything)
192
195
  @api.fql_multiquery("a query", args)
193
196
  end
194
197
  end
@@ -199,28 +202,28 @@ shared_examples_for "Koala GraphAPI with an access token" do
199
202
  it "gets private data about a user" do
200
203
  result = @api.get_object(KoalaTest.user1)
201
204
  # updated_time should be a pretty fixed test case
202
- result["updated_time"].should_not be_nil
205
+ expect(result["updated_time"]).not_to be_nil
203
206
  end
204
207
 
205
208
  it "gets data about 'me'" do
206
209
  result = @api.get_object("me")
207
- result["updated_time"].should
210
+ expect(result["updated_time"]).to be_truthy
208
211
  end
209
212
 
210
213
  it "gets multiple objects" do
211
214
  result = @api.get_objects([KoalaTest.page, KoalaTest.user1])
212
- result.length.should == 2
215
+ expect(result.length).to eq(2)
213
216
  end
214
217
  it "can access connections from users" do
215
218
  result = @api.get_connections(KoalaTest.user2, "friends")
216
- result.length.should > 0
219
+ expect(result.length).to be > 0
217
220
  end
218
221
 
219
222
  # PUT
220
223
  it "can write an object to the graph" do
221
224
  result = @api.put_wall_post("Hello, world, from the test suite!")
222
225
  @temporary_object_id = result["id"]
223
- @temporary_object_id.should_not be_nil
226
+ expect(@temporary_object_id).not_to be_nil
224
227
  end
225
228
 
226
229
  # DELETE
@@ -228,7 +231,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
228
231
  result = @api.put_wall_post("Hello, world, from the test suite delete method!")
229
232
  object_id_to_delete = result["id"]
230
233
  delete_result = @api.delete_object(object_id_to_delete)
231
- delete_result.should == true
234
+ expect(delete_result).to eq(true)
232
235
  end
233
236
 
234
237
  it "can delete likes" do
@@ -236,7 +239,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
236
239
  @temporary_object_id = result["id"]
237
240
  @api.put_like(@temporary_object_id)
238
241
  delete_like_result = @api.delete_like(@temporary_object_id)
239
- delete_like_result.should == true
242
+ expect(delete_like_result).to eq(true)
240
243
  end
241
244
 
242
245
  # additional put tests
@@ -247,13 +250,13 @@ shared_examples_for "Koala GraphAPI with an access token" do
247
250
  get_result = @api.get_object(@temporary_object_id)
248
251
 
249
252
  # make sure the message we sent is the message that got posted
250
- get_result["message"].should == message
253
+ expect(get_result["message"]).to eq(message)
251
254
  end
252
255
 
253
256
  it "can post a message with an attachment to a feed" do
254
257
  result = @api.put_wall_post("Hello, world, from the test suite again!", {:name => "OAuth Playground", :link => "http://oauth.twoalex.com/"})
255
258
  @temporary_object_id = result["id"]
256
- @temporary_object_id.should_not be_nil
259
+ expect(@temporary_object_id).not_to be_nil
257
260
  end
258
261
 
259
262
  it "can post a message whose attachment has a properties dictionary" do
@@ -271,11 +274,11 @@ shared_examples_for "Koala GraphAPI with an access token" do
271
274
 
272
275
  result = @api.put_wall_post("body", args)
273
276
  @temporary_object_id = result["id"]
274
- @temporary_object_id.should_not be_nil
277
+ expect(@temporary_object_id).not_to be_nil
275
278
 
276
279
  # ensure the properties dictionary is there
277
280
  api_data = @api.get_object(@temporary_object_id)
278
- api_data["properties"].should_not be_nil
281
+ expect(api_data["properties"]).not_to be_nil
279
282
  end
280
283
 
281
284
  describe "#put_picture" do
@@ -285,7 +288,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
285
288
 
286
289
  result = @api.put_picture(file, content_type)
287
290
  @temporary_object_id = result["id"]
288
- @temporary_object_id.should_not be_nil
291
+ expect(@temporary_object_id).not_to be_nil
289
292
  end
290
293
 
291
294
  it "can post photos to the user's wall without an open file object" do
@@ -294,7 +297,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
294
297
 
295
298
  result = @api.put_picture(file_path, content_type)
296
299
  @temporary_object_id = result["id"]
297
- @temporary_object_id.should_not be_nil
300
+ expect(@temporary_object_id).not_to be_nil
298
301
  end
299
302
 
300
303
  it "can verify a photo posted to a user's wall" do
@@ -305,10 +308,10 @@ shared_examples_for "Koala GraphAPI with an access token" do
305
308
 
306
309
  result = @api.put_picture(file_path, content_type, :message => expected_message)
307
310
  @temporary_object_id = result["id"]
308
- @temporary_object_id.should_not be_nil
311
+ expect(@temporary_object_id).not_to be_nil
309
312
 
310
313
  get_result = @api.get_object(@temporary_object_id)
311
- get_result["name"].should == expected_message
314
+ expect(get_result["name"]).to eq(expected_message)
312
315
  end
313
316
 
314
317
 
@@ -320,13 +323,13 @@ shared_examples_for "Koala GraphAPI with an access token" do
320
323
  it "can post photo to the user's wall using a URL" do
321
324
  result = @api.put_picture(@url)
322
325
  @temporary_object_id = result["id"]
323
- @temporary_object_id.should_not be_nil
326
+ expect(@temporary_object_id).not_to be_nil
324
327
  end
325
328
 
326
329
  it "can post photo to the user's wall using a URL and an additional param" do
327
330
  result = @api.put_picture(@url, :message => "my message")
328
331
  @temporary_object_id = result["id"]
329
- @temporary_object_id.should_not be_nil
332
+ expect(@temporary_object_id).not_to be_nil
330
333
  end
331
334
  end
332
335
  end
@@ -339,9 +342,9 @@ shared_examples_for "Koala GraphAPI with an access token" do
339
342
 
340
343
  it "sets options[:video] to true" do
341
344
  source = double("UploadIO")
342
- Koala::UploadableIO.stub(:new).and_return(source)
343
- source.stub(:requires_base_http_service).and_return(false)
344
- Koala.should_receive(:make_request).with(anything, anything, anything, hash_including(:video => true)).and_return(Koala::HTTPService::Response.new(200, "[]", {}))
345
+ allow(Koala::UploadableIO).to receive(:new).and_return(source)
346
+ allow(source).to receive(:requires_base_http_service).and_return(false)
347
+ expect(Koala).to receive(:make_request).with(anything, anything, anything, hash_including(:video => true)).and_return(Koala::HTTPService::Response.new(200, "[]", {}))
345
348
  @api.put_video("foo")
346
349
  end
347
350
 
@@ -350,13 +353,13 @@ shared_examples_for "Koala GraphAPI with an access token" do
350
353
 
351
354
  result = @api.put_video(file, @content_type)
352
355
  @temporary_object_id = result["id"]
353
- @temporary_object_id.should_not be_nil
356
+ expect(@temporary_object_id).not_to be_nil
354
357
  end
355
358
 
356
359
  it "can post videos to the user's wall without an open file object" do
357
360
  result = @api.put_video(@cat_movie, @content_type)
358
361
  @temporary_object_id = result["id"]
359
- @temporary_object_id.should_not be_nil
362
+ expect(@temporary_object_id).not_to be_nil
360
363
  end
361
364
 
362
365
  # note: Facebook doesn't post videos immediately to the wall, due to processing time
@@ -372,7 +375,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
372
375
 
373
376
  # make sure the result we fetch includes all the parameters we sent
374
377
  it_matches = attachment.inject(true) {|valid, param| valid && (get_result[param[0]] == attachment[param[0]])}
375
- it_matches.should == true
378
+ expect(it_matches).to eq(true)
376
379
  end
377
380
 
378
381
  it "can comment on an object" do
@@ -381,7 +384,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
381
384
 
382
385
  # this will be deleted when the post gets deleted
383
386
  comment_result = @api.put_comment(@temporary_object_id, "it's my comment!")
384
- comment_result.should_not be_nil
387
+ expect(comment_result).not_to be_nil
385
388
  end
386
389
 
387
390
  it "can verify a comment posted about an object" do
@@ -395,38 +398,38 @@ shared_examples_for "Koala GraphAPI with an access token" do
395
398
  get_result = @api.get_object(comment_result["id"])
396
399
 
397
400
  # make sure the text of the comment matches what we sent
398
- get_result["message"].should == comment_text
401
+ expect(get_result["message"]).to eq(comment_text)
399
402
  end
400
403
 
401
404
  it "can like an object" do
402
405
  result = @api.put_wall_post("Hello, world, from the test suite, testing liking!")
403
406
  @temporary_object_id = result["id"]
404
407
  like_result = @api.put_like(@temporary_object_id)
405
- like_result.should be_true
408
+ expect(like_result).to be_truthy
406
409
  end
407
410
 
408
411
  # Page Access Token Support
409
412
  describe "#get_page_access_token" do
410
413
  it "gets the page object with the access_token field" do
411
414
  # we can't test this live since test users (or random real users) can't be guaranteed to have pages to manage
412
- @api.should_receive(:api).with("my_page", hash_including({:fields => "access_token"}), "get", anything)
415
+ expect(@api).to receive(:api).with("my_page", hash_including({:fields => "access_token"}), "get", anything)
413
416
  @api.get_page_access_token("my_page")
414
417
  end
415
418
 
416
419
  it "merges in any other arguments" do
417
420
  # we can't test this live since test users (or random real users) can't be guaranteed to have pages to manage
418
421
  args = {:a => 3}
419
- @api.should_receive(:api).with("my_page", hash_including(args), "get", anything)
422
+ expect(@api).to receive(:api).with("my_page", hash_including(args), "get", anything)
420
423
  @api.get_page_access_token("my_page", args)
421
424
  end
422
425
  end
423
426
 
424
427
  it "can get information about an access token" do
425
428
  result = @api.debug_token(KoalaTest.app_access_token)
426
- result.should be_kind_of(Hash)
427
- result["data"].should be_kind_of(Hash)
428
- result["data"]["app_id"].to_s.should == KoalaTest.app_id.to_s
429
- result["data"]["application"].should_not be_nil
429
+ expect(result).to be_kind_of(Hash)
430
+ expect(result["data"]).to be_kind_of(Hash)
431
+ expect(result["data"]["app_id"].to_s).to eq(KoalaTest.app_id.to_s)
432
+ expect(result["data"]["application"]).not_to be_nil
430
433
  end
431
434
 
432
435
  describe "#set_app_restrictions" do
@@ -438,31 +441,31 @@ shared_examples_for "Koala GraphAPI with an access token" do
438
441
  end
439
442
 
440
443
  it "makes a POST to /app_id" do
441
- @app_api.should_receive(:graph_call).with(KoalaTest.app_id, anything, "post", anything)
444
+ expect(@app_api).to receive(:graph_call).with(KoalaTest.app_id, anything, "post", anything)
442
445
  @app_api.set_app_restrictions(KoalaTest.app_id, @restrictions)
443
446
  end
444
447
 
445
448
  it "JSON-encodes the restrictions" do
446
- @app_api.should_receive(:graph_call).with(anything, hash_including(:restrictions => MultiJson.dump(@restrictions)), anything, anything)
449
+ expect(@app_api).to receive(:graph_call).with(anything, hash_including(:restrictions => MultiJson.dump(@restrictions)), anything, anything)
447
450
  @app_api.set_app_restrictions(KoalaTest.app_id, @restrictions)
448
451
  end
449
452
 
450
453
  it "includes the other arguments" do
451
454
  args = {:a => 2}
452
- @app_api.should_receive(:graph_call).with(anything, hash_including(args), anything, anything)
455
+ expect(@app_api).to receive(:graph_call).with(anything, hash_including(args), anything, anything)
453
456
  @app_api.set_app_restrictions(KoalaTest.app_id, @restrictions, args)
454
457
  end
455
458
 
456
459
  it "works" do
457
- @app_api.set_app_restrictions(KoalaTest.app_id, @restrictions).should be_true
460
+ expect(@app_api.set_app_restrictions(KoalaTest.app_id, @restrictions)).to be_truthy
458
461
  end
459
462
  end
460
463
 
461
464
  it "can access public information via FQL" do
462
465
  result = @api.fql_query("select uid, first_name from user where uid = #{KoalaTest.user2_id}")
463
- result.size.should == 1
464
- result.first['first_name'].should == KoalaTest.user2_name
465
- result.first['uid'].should == KoalaTest.user2_id.to_i
466
+ expect(result.size).to eq(1)
467
+ expect(result.first['first_name']).to eq(KoalaTest.user2_name)
468
+ expect(result.first['uid']).to eq(KoalaTest.user2_id.to_i)
466
469
  end
467
470
 
468
471
  it "can access public information via FQL.multiquery" do
@@ -470,11 +473,11 @@ shared_examples_for "Koala GraphAPI with an access token" do
470
473
  :query1 => "select uid, first_name from user where uid = #{KoalaTest.user2_id}",
471
474
  :query2 => "select uid, first_name from user where uid = #{KoalaTest.user1_id}"
472
475
  )
473
- result.size.should == 2
476
+ expect(result.size).to eq(2)
474
477
  # this should check for first_name, but there's an FB bug currently
475
- result["query1"].first['uid'].should == KoalaTest.user2_id.to_i
478
+ expect(result["query1"].first['uid']).to eq(KoalaTest.user2_id.to_i)
476
479
  # result["query1"].first['first_name'].should == KoalaTest.user2_name
477
- result["query2"].first['first_name'].should == KoalaTest.user1_name
480
+ expect(result["query2"].first['first_name']).to eq(KoalaTest.user1_name)
478
481
  end
479
482
 
480
483
  it "can access protected information via FQL" do
@@ -488,9 +491,9 @@ shared_examples_for "Koala GraphAPI with an access token" do
488
491
  # now send a query about your permissions
489
492
  result = @api.fql_query("select read_stream from permissions where uid = #{id}")
490
493
 
491
- result.size.should == 1
494
+ expect(result.size).to eq(1)
492
495
  # we've verified that you have read_stream permissions, so we can test against that
493
- result.first["read_stream"].should == 1
496
+ expect(result.first["read_stream"]).to eq(1)
494
497
  end
495
498
 
496
499
  it "can access protected information via FQL.multiquery" do
@@ -499,8 +502,8 @@ shared_examples_for "Koala GraphAPI with an access token" do
499
502
  :query2 => "select fromid from comment where post_id in (select post_id from #query1)",
500
503
  :query3 => "select uid, name from user where uid in (select fromid from #query2)"
501
504
  )
502
- result.size.should == 3
503
- result.keys.should include("query1", "query2", "query3")
505
+ expect(result.size).to eq(3)
506
+ expect(result.keys).to include("query1", "query2", "query3")
504
507
  end
505
508
 
506
509
  # test all methods to make sure they pass data through to the API
@@ -532,7 +535,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
532
535
  it "passes http options through for #{method_name}" do
533
536
  options = {:a => 2}
534
537
  # graph call should ultimately receive options as the fourth argument
535
- @api.should_receive(:graph_call).with(anything, anything, anything, options)
538
+ expect(@api).to receive(:graph_call).with(anything, anything, anything, options)
536
539
 
537
540
  # if we supply args, use them (since some methods process params)
538
541
  # the method should receive as args n-1 anythings and then options
@@ -546,7 +549,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
546
549
  it "passes http options through for get_picture" do
547
550
  options = {:a => 2}
548
551
  # graph call should ultimately receive options as the fourth argument
549
- @api.should_receive(:graph_call).with(anything, anything, anything, hash_including(options)).and_return({})
552
+ expect(@api).to receive(:graph_call).with(anything, anything, anything, hash_including(options)).and_return({})
550
553
  @api.send(:get_picture, "x", {}, options)
551
554
  end
552
555
  end
@@ -559,35 +562,35 @@ shared_examples_for "Koala GraphAPI with GraphCollection" do
559
562
  # GraphCollection methods
560
563
  it "gets a GraphCollection when getting connections" do
561
564
  @result = @api.get_connections(KoalaTest.page, "photos")
562
- @result.should be_a(Koala::Facebook::GraphCollection)
565
+ expect(@result).to be_a(Koala::Facebook::GraphCollection)
563
566
  end
564
567
 
565
568
  it "returns nil if the get_collections call fails with nil" do
566
569
  # this happens sometimes
567
- @api.should_receive(:graph_call).and_return(nil)
568
- @api.get_connections(KoalaTest.page, "photos").should be_nil
570
+ expect(@api).to receive(:graph_call).and_return(nil)
571
+ expect(@api.get_connections(KoalaTest.page, "photos")).to be_nil
569
572
  end
570
573
 
571
574
  it "gets a GraphCollection when searching" do
572
575
  result = @api.search("facebook")
573
- result.should be_a(Koala::Facebook::GraphCollection)
576
+ expect(result).to be_a(Koala::Facebook::GraphCollection)
574
577
  end
575
578
 
576
579
  it "returns nil if the search call fails with nil" do
577
580
  # this happens sometimes
578
- @api.should_receive(:graph_call).and_return(nil)
579
- @api.search("facebook").should be_nil
581
+ expect(@api).to receive(:graph_call).and_return(nil)
582
+ expect(@api.search("facebook")).to be_nil
580
583
  end
581
584
 
582
585
  it "gets a GraphCollection when paging through results" do
583
586
  @results = @api.get_page(["search", {"q"=>"facebook", "limit"=>"25", "until"=> KoalaTest.search_time}])
584
- @results.should be_a(Koala::Facebook::GraphCollection)
587
+ expect(@results).to be_a(Koala::Facebook::GraphCollection)
585
588
  end
586
589
 
587
590
  it "returns nil if the page call fails with nil" do
588
591
  # this happens sometimes
589
- @api.should_receive(:graph_call).and_return(nil)
590
- @api.get_page(["search", {"q"=>"facebook", "limit"=>"25", "until"=> KoalaTest.search_time}]).should be_nil
592
+ expect(@api).to receive(:graph_call).and_return(nil)
593
+ expect(@api.get_page(["search", {"q"=>"facebook", "limit"=>"25", "until"=> KoalaTest.search_time}])).to be_nil
591
594
  end
592
595
  end
593
596
  end
@@ -597,57 +600,57 @@ shared_examples_for "Koala GraphAPI without an access token" do
597
600
  it "can't get private data about a user" do
598
601
  result = @api.get_object(KoalaTest.user1)
599
602
  # updated_time should be a pretty fixed test case
600
- result["updated_time"].should be_nil
603
+ expect(result["updated_time"]).to be_nil
601
604
  end
602
605
 
603
606
  it "can't get data about 'me'" do
604
- lambda { @api.get_object("me") }.should raise_error(Koala::Facebook::ClientError)
607
+ expect { @api.get_object("me") }.to raise_error(Koala::Facebook::ClientError)
605
608
  end
606
609
 
607
610
  it "can't access connections from users" do
608
- lambda { @api.get_connections(KoalaTest.user2, "friends") }.should raise_error(Koala::Facebook::ClientError)
611
+ expect { @api.get_connections(KoalaTest.user2, "friends") }.to raise_error(Koala::Facebook::ClientError)
609
612
  end
610
613
 
611
614
  it "can't put an object" do
612
- lambda { @result = @api.put_connections(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::AuthenticationError)
615
+ expect { @result = @api.put_connections(KoalaTest.user2, "feed", :message => "Hello, world") }.to raise_error(Koala::Facebook::AuthenticationError)
613
616
  # legacy put_object syntax
614
- lambda { @result = @api.put_object(KoalaTest.user2, "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::AuthenticationError)
617
+ expect { @result = @api.put_object(KoalaTest.user2, "feed", :message => "Hello, world") }.to raise_error(Koala::Facebook::AuthenticationError)
615
618
  end
616
619
 
617
620
  # these are not strictly necessary as the other put methods resolve to put_connections,
618
621
  # but are here for completeness
619
622
  it "can't post to a feed" do
620
- (lambda do
623
+ expect(lambda do
621
624
  attachment = {:name => "OAuth Playground", :link => "http://oauth.twoalex.com/"}
622
625
  @result = @api.put_wall_post("Hello, world", attachment, "facebook")
623
- end).should raise_error(Koala::Facebook::AuthenticationError)
626
+ end).to raise_error(Koala::Facebook::AuthenticationError)
624
627
  end
625
628
 
626
629
  it "can't comment on an object" do
627
630
  # random public post on the facebook wall
628
- lambda { @result = @api.put_comment("7204941866_119776748033392", "The hackathon was great!") }.should raise_error(Koala::Facebook::AuthenticationError)
631
+ expect { @result = @api.put_comment("7204941866_119776748033392", "The hackathon was great!") }.to raise_error(Koala::Facebook::AuthenticationError)
629
632
  end
630
633
 
631
634
  it "can't like an object" do
632
- lambda { @api.put_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::AuthenticationError)
635
+ expect { @api.put_like("7204941866_119776748033392") }.to raise_error(Koala::Facebook::AuthenticationError)
633
636
  end
634
637
 
635
638
  # DELETE
636
639
  it "can't delete posts" do
637
640
  # test post on the Ruby SDK Test application
638
- lambda { @result = @api.delete_object("115349521819193_113815981982767") }.should raise_error(Koala::Facebook::AuthenticationError)
641
+ expect { @result = @api.delete_object("115349521819193_113815981982767") }.to raise_error(Koala::Facebook::AuthenticationError)
639
642
  end
640
643
 
641
644
  it "can't delete a like" do
642
- lambda { @api.delete_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::AuthenticationError)
645
+ expect { @api.delete_like("7204941866_119776748033392") }.to raise_error(Koala::Facebook::AuthenticationError)
643
646
  end
644
647
 
645
648
  # FQL_QUERY
646
649
  describe "when making a FQL request" do
647
650
  it "can access public information via FQL" do
648
651
  result = @api.fql_query("select uid, first_name from user where uid = #{KoalaTest.user2_id}")
649
- result.size.should == 1
650
- result.first['first_name'].should == KoalaTest.user2_name
652
+ expect(result.size).to eq(1)
653
+ expect(result.first['first_name']).to eq(KoalaTest.user2_name)
651
654
  end
652
655
 
653
656
  it "can access public information via FQL.multiquery" do
@@ -655,23 +658,23 @@ shared_examples_for "Koala GraphAPI without an access token" do
655
658
  :query1 => "select uid, first_name from user where uid = #{KoalaTest.user2_id}",
656
659
  :query2 => "select uid, first_name from user where uid = #{KoalaTest.user1_id}"
657
660
  )
658
- result.size.should == 2
659
- result["query1"].first['first_name'].should == KoalaTest.user2_name
660
- result["query2"].first['first_name'].should == KoalaTest.user1_name
661
+ expect(result.size).to eq(2)
662
+ expect(result["query1"].first['first_name']).to eq(KoalaTest.user2_name)
663
+ expect(result["query2"].first['first_name']).to eq(KoalaTest.user1_name)
661
664
  end
662
665
 
663
666
  it "can't access protected information via FQL" do
664
- lambda { @api.fql_query("select read_stream from permissions where uid = #{KoalaTest.user2_id}") }.should raise_error(Koala::Facebook::APIError)
667
+ expect { @api.fql_query("select read_stream from permissions where uid = #{KoalaTest.user2_id}") }.to raise_error(Koala::Facebook::APIError)
665
668
  end
666
669
 
667
670
  it "can't access protected information via FQL.multiquery" do
668
- lambda {
671
+ expect {
669
672
  @api.fql_multiquery(
670
673
  :query1 => "select post_id from stream where source_id = me()",
671
674
  :query2 => "select fromid from comment where post_id in (select post_id from #query1)",
672
675
  :query3 => "select uid, name from user where uid in (select fromid from #query2)"
673
676
  )
674
- }.should raise_error(Koala::Facebook::APIError)
677
+ }.to raise_error(Koala::Facebook::APIError)
675
678
  end
676
679
  end
677
680
  end