Permalink
Browse files

Adjust naming, remove unnecessary return type check

  • Loading branch information...
1 parent 6c7b456 commit b5ea96f4d6c670fb6a4ea15924ce79e842e8d85c @dburkes dburkes committed Sep 2, 2011
View
8 lib/databasedotcom/client.rb
@@ -148,13 +148,9 @@ def materialize(classnames)
end
# Returns an Array of Hashes listing the properties for every type of _Sobject_ in the database. Raises SalesForceError if an error occurs.
- def describe_global
+ def describe_sobjects
result = http_get("/services/data/v#{self.version}/sobjects")
- if result.is_a?(Net::HTTPOK)
- JSON.parse(result.body)["sobjects"]
- elsif result.is_a?(Net::HTTPBadRequest)
- raise SalesForceError.new(result)
- end
+ JSON.parse(result.body)["sobjects"]
end
# Returns a description of the Sobject specified by _class_name_. The description includes all fields and their properties for the Sobject.
View
0 ...bject/describe_global_error_response.json → ...ect/describe_sobjects_error_response.json
File renamed without changes.
View
0 ...ect/describe_global_success_response.json → ...t/describe_sobjects_success_response.json
File renamed without changes.
View
12 spec/lib/client_spec.rb
@@ -273,28 +273,28 @@
end
end
- describe "#describe_global" do
+ describe "#describe_sobjects" do
context "with a successful request" do
before do
- @response_body = File.read(File.join(File.dirname(__FILE__), "../fixtures/sobject/describe_global_success_response.json"))
+ @response_body = File.read(File.join(File.dirname(__FILE__), "../fixtures/sobject/describe_sobjects_success_response.json"))
stub_request(:get, "https://na1.salesforce.com/services/data/v23.0/sobjects").to_return(:body => @response_body, :status => 200)
end
it "returns an array of hashes listing the properties for available sobjects with a given version" do
- @client.describe_global.first["name"].should == "Account"
- @client.describe_global.first["createable"].should == true
+ @client.describe_sobjects.first["name"].should == "Account"
+ @client.describe_sobjects.first["createable"].should be_true
end
end
context "with a failed request" do
before do
- @response_body = File.read(File.join(File.dirname(__FILE__), "../fixtures/sobject/describe_global_error_response.json"))
+ @response_body = File.read(File.join(File.dirname(__FILE__), "../fixtures/sobject/describe_sobjects_error_response.json"))
stub_request(:get, "https://na1.salesforce.com/services/data/v23.0/sobjects").to_return(:body => @response_body, :status => 400)
end
it "raises a Databasedotcom::Sobject::SalesForceError" do
lambda {
- @client.describe_global
+ @client.describe_sobjects
}.should raise_error(Databasedotcom::SalesForceError)
end
end

0 comments on commit b5ea96f

Please sign in to comment.