Permalink
Browse files

Ruby 1.8.7 compatibility

  • Loading branch information...
1 parent fff44ed commit d5b4f764bfa31822290fdaa54a5372ae7dc063a6 @dburkes dburkes committed Sep 1, 2011
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
s.files = Dir['README.rdoc', 'MIT-LICENSE', 'lib/**/*']
s.require_paths = ["lib"]
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('rake', '0.8.6')
- s.add_development_dependency('ruby-debug19')
end
@@ -133,7 +133,7 @@ def list_sobjects
def materialize(classnames)
classes = (classnames.is_a?(Array) ? classnames : [classnames]).collect do |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)
new_class = module_namespace.const_set(clazz, Class.new(Databasedotcom::Sobject::Sobject))
new_class.client = self
@@ -7,7 +7,7 @@ class Sobject
# Returns a new Sobject. The default values for all attributes are set based on its description.
def initialize(attrs = {})
- super
+ super()
self.class.description["fields"].each do |field|
self.send("#{field["name"]}=", field["defaultValueFormula"])
end
@@ -20,7 +20,8 @@
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)
- 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)
end
end
@@ -178,8 +178,8 @@ class TestClass < Databasedotcom::Sobject::Sobject
it "coerces datetime fields" do
now = DateTime.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" => "bogus")["DateTime_Field"].to_time.to_i.should == now.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_s.should == now.to_s
end
end
View
@@ -1,5 +1,5 @@
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|
require f
end

0 comments on commit d5b4f76

Please sign in to comment.