Skip to content

Commit

Permalink
Ruby 1.8.7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dburkes committed Sep 1, 2011
1 parent fff44ed commit d5b4f76
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions databasedotcom.gemspec
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Gem::Specification.new do |s|
s.files = Dir['README.rdoc', 'MIT-LICENSE', 'lib/**/*'] s.files = Dir['README.rdoc', 'MIT-LICENSE', 'lib/**/*']
s.require_paths = ["lib"] s.require_paths = ["lib"]
s.add_dependency('multipart-post', '>=1.1.3') s.add_dependency('multipart-post', '>=1.1.3')
s.add_development_dependency('rspec', '2.5.0') s.add_dependency('json')
s.add_development_dependency('rspec')
s.add_development_dependency('webmock') s.add_development_dependency('webmock')
s.add_development_dependency('rake', '0.8.6') s.add_development_dependency('rake', '0.8.6')
s.add_development_dependency('ruby-debug19')
end end
2 changes: 1 addition & 1 deletion lib/databasedotcom/client.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def list_sobjects
def materialize(classnames) def materialize(classnames)
classes = (classnames.is_a?(Array) ? classnames : [classnames]).collect do |clazz| classes = (classnames.is_a?(Array) ? classnames : [classnames]).collect do |clazz|
original_classname = clazz original_classname = clazz
clazz = original_classname[0].capitalize + original_classname[1..-1] clazz = original_classname[0,1].capitalize + original_classname[1..-1]
unless module_namespace.const_defined?(clazz) unless module_namespace.const_defined?(clazz)
new_class = module_namespace.const_set(clazz, Class.new(Databasedotcom::Sobject::Sobject)) new_class = module_namespace.const_set(clazz, Class.new(Databasedotcom::Sobject::Sobject))
new_class.client = self new_class.client = self
Expand Down
2 changes: 1 addition & 1 deletion lib/databasedotcom/sobject/sobject.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Sobject


# Returns a new Sobject. The default values for all attributes are set based on its description. # Returns a new Sobject. The default values for all attributes are set based on its description.
def initialize(attrs = {}) def initialize(attrs = {})
super super()
self.class.description["fields"].each do |field| self.class.description["fields"].each do |field|
self.send("#{field["name"]}=", field["defaultValueFormula"]) self.send("#{field["name"]}=", field["defaultValueFormula"])
end end
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/shared_behaviors/resource_with_photo.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@


it "uploads the photo and returns a hash containing photo info" do it "uploads the photo and returns a hash containing photo info" do
@client_mock.should_receive(:http_multipart_post).with("/services/data/v23/chatter/#{described_class.resource_name}/foo/photo", an_instance_of(Hash)).and_return(@response) @client_mock.should_receive(:http_multipart_post).with("/services/data/v23/chatter/#{described_class.resource_name}/foo/photo", an_instance_of(Hash)).and_return(@response)
photo = described_class.upload_photo(@client_mock, "foo", StringIO.new("foo"), "image/gif") file_mock = double("file", :read => "foo", :path => "filename")
photo = described_class.upload_photo(@client_mock, "foo", file_mock, "image/gif")
photo.should be_instance_of(Hash) photo.should be_instance_of(Hash)
end end
end end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/sobject/sobject_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ class TestClass < Databasedotcom::Sobject::Sobject
it "coerces datetime fields" do it "coerces datetime fields" do
now = DateTime.now now = DateTime.now
DateTime.stub(:now).and_return(now) DateTime.stub(:now).and_return(now)
TestClass.coerce_params("DateTime_Field" => "2010-04-01T12:05:10Z")["DateTime_Field"].to_time.to_i.should == DateTime.civil(2010, 4, 1, 12, 5, 10).to_time.to_i TestClass.coerce_params("DateTime_Field" => "2010-04-01T12:05:10Z")["DateTime_Field"].to_s.should == DateTime.civil(2010, 4, 1, 12, 5, 10).to_s
TestClass.coerce_params("DateTime_Field" => "bogus")["DateTime_Field"].to_time.to_i.should == now.to_time.to_i TestClass.coerce_params("DateTime_Field" => "bogus")["DateTime_Field"].to_s.should == now.to_s
end end


end end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'webmock/rspec' require 'webmock/rspec'
Encoding.default_external = Encoding::UTF_8 Encoding.default_external = Encoding::UTF_8 if defined?(Encoding)
Dir.glob(File.join(File.dirname(__FILE__), 'lib', 'shared_behaviors', '**', '.', '*.rb')).each do |f| Dir.glob(File.join(File.dirname(__FILE__), 'lib', 'shared_behaviors', '**', '.', '*.rb')).each do |f|
require f require f
end end

0 comments on commit d5b4f76

Please sign in to comment.