spec/cases/api_spec.rb in koala-3.0.0.beta2 vs spec/cases/api_spec.rb in koala-3.0.0.beta3
- old
+ new
@@ -4,10 +4,30 @@
before :each do
@service = Koala::Facebook::API.new
end
let(:dummy_response) { double("fake response", data: {}, status: 200, body: "", headers: {}) }
+ it "defaults to the globally configured token if one's provided" do
+ token = "Foo"
+
+ Koala.configure do |config|
+ config.access_token = token
+ end
+
+ expect(Koala::Facebook::API.new.access_token).to eq(token)
+ end
+
+ it "defaults to the globally configured app_secret if one's provided" do
+ app_secret = "Foo"
+
+ Koala.configure do |config|
+ config.app_secret = app_secret
+ end
+
+ expect(Koala::Facebook::API.new.app_secret).to eq(app_secret)
+ end
+
it "doesn't include an access token if none was given" do
expect(Koala).to receive(:make_request).with(
anything,
hash_not_including('access_token' => 1),
anything,
@@ -44,22 +64,10 @@
args = {}.freeze
service.api('anything', args)
end
- it "has an attr_reader for access token" do
- token = 'adfadf'
- service = Koala::Facebook::API.new token
- expect(service.access_token).to eq(token)
- end
-
- it "has an attr_reader for app_secret" do
- secret = double
- service = Koala::Facebook::API.new(@token, secret)
- expect(service.app_secret).to eq(secret)
- end
-
it "turns arrays of non-enumerables into comma-separated arguments by default" do
args = [12345, {:foo => [1, 2, "3", :four]}]
expected = ["/12345", {:foo => "1,2,3,four"}, "get", {}]
response = double('Mock KoalaResponse', :body => '', :status => 200)
expect(Koala).to receive(:make_request).with(*expected).and_return(response)
@@ -216,10 +224,10 @@
expect { @service.graph_call(KoalaTest.user1, {}) }.to raise_exception(Koala::Facebook::APIError)
end
it "passes the results through GraphCollection.evaluate" do
allow(@service).to receive(:api).and_return(dummy_response)
- expect(Koala::Facebook::API::GraphCollection).to receive(:evaluate).with(dummy_response.data, @service)
+ expect(Koala::Facebook::API::GraphCollection).to receive(:evaluate).with(dummy_response, @service)
@service.graph_call("/me")
end
it "returns the results of GraphCollection.evaluate" do
expected = {}