Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for ruby-1.8.7

  • Loading branch information...
commit c9f54ec49165c745ada5f733f65e65d74e7c308d 1 parent b7c0b2e
@remiprev authored
View
8 .travis.yml
@@ -1,2 +1,8 @@
-rvm: 1.9.2
+language: ruby
+
+rvm:
+ - 1.9.3
+ - 1.9.2
+ - 1.8.7
+
script: "bundle exec rake spec"
View
2  lib/her/api.rb
@@ -74,7 +74,7 @@ def setup(attrs={}) # {{{
def request(attrs={}) # {{{
method = attrs.delete(:_method)
path = attrs.delete(:_path)
- attrs.delete_if { |key, value| key =~ /^_/ } # Remove all internal parameters
+ attrs.delete_if { |key, value| key.to_s =~ /^_/ } # Remove all internal parameters
response = @connection.send method do |request|
if method == :get
# For GET requests, treat additional parameters as querystring data
View
6 lib/her/model/orm.rb
@@ -31,6 +31,12 @@ def method_missing(method, attrs=nil) # {{{
end
end # }}}
+ # Override the method to prevent from returning the object ID (in ruby-1.8.7)
+ # @private
+ def id # {{{
+ @data[:id] || super
+ end # }}}
+
# Initialize a collection of resources with raw data from an HTTP request
#
# @param [Hash] parsed_data The raw `parsed_data` parsed from the HTTP response
View
2  lib/her/version.rb
@@ -1,3 +1,3 @@
module Her
- VERSION = "0.2.2"
+ VERSION = "0.2.3"
end
View
2  spec/api_spec.rb
@@ -82,7 +82,7 @@ def on_complete(env)
class CustomParser < Faraday::Response::Middleware
def on_complete(env)
- json = JSON.parse(env[:body], :symbolize_names => true)
+ json = MultiJson.load(env[:body], :symbolize_keys => true)
errors = json.delete(:errors) || []
metadata = json.delete(:metadata) || {}
env[:body] = {
View
8 spec/model/introspection_spec.rb
@@ -5,19 +5,19 @@
context "introspecting a resource" do
before do # {{{
Her::API.setup :base_uri => "https://api.example.com"
- FakeWeb.register_uri(:get, "https://api.example.com/users/1", :body => { :id => 1, :name => "Tobias Fünke" }.to_json)
+ FakeWeb.register_uri(:get, "https://api.example.com/users/1", :body => { :id => 1, :name => "Tobias Funke" }.to_json)
spawn_model :User
end # }}}
describe "#inspect" do
it "outputs resource attributs for an existing resource" do # {{{
@user = User.find(1)
- @user.inspect.should == "#<User(/users/1) id=1 name=\"Tobias Fünke\">"
+ ["#<User(/users/1) name=\"Tobias Funke\" id=1>", "#<User(/users/1) id=1 name=\"Tobias Funke\">"].should include(@user.inspect)
end # }}}
it "outputs resource attributs for an not-saved-yet resource" do # {{{
- @user = User.new(:name => "Tobias Fünke")
- @user.inspect.should == "#<User(/users) name=\"Tobias Fünke\">"
+ @user = User.new(:name => "Tobias Funke")
+ @user.inspect.should == "#<User(/users) name=\"Tobias Funke\">"
end # }}}
end
end
View
8 spec/model/paths_spec.rb
@@ -10,13 +10,13 @@
describe "#build_request_path" do
it "builds paths with defaults" do # {{{
- User.build_request_path(id: "foo").should == "/users/foo"
+ User.build_request_path(:id => "foo").should == "/users/foo"
User.build_request_path.should == "/users"
end # }}}
it "builds paths with custom collection path" do # {{{
User.collection_path "/utilisateurs"
- User.build_request_path(id: "foo").should == "/utilisateurs/foo"
+ User.build_request_path(:id => "foo").should == "/utilisateurs/foo"
User.build_request_path.should == "/utilisateurs"
end # }}}
@@ -28,7 +28,7 @@
it "builds paths with custom item path" do # {{{
User.resource_path "/utilisateurs/:id"
- User.build_request_path(id: "foo").should == "/utilisateurs/foo"
+ User.build_request_path(:id => "foo").should == "/utilisateurs/foo"
User.build_request_path.should == "/users"
end # }}}
@@ -46,7 +46,7 @@
describe "#build_request_path" do
it "builds paths with defaults" do # {{{
- Base::User.build_request_path(id: "foo").should == "/users/foo"
+ Base::User.build_request_path(:id => "foo").should == "/users/foo"
Base::User.build_request_path.should == "/users"
end # }}}
end
Please sign in to comment.
Something went wrong with that request. Please try again.