Forum: Ruby on Rails ActiveResource as API test rig?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Marc B. (Guest)
on 2009-05-21 02:58
(Received via mailing list)
Hi,

I'm using ActiveResource as an API test rig for an API we're developing
for
our PHP app - the goal being to validate that we're following some
externally validated conventions for ReSTful API and that we can support
at
least one external framework.  ;^)  I'm open to opinions on the wisdom
of
this approach.

Meanwhile, I'm getting some strange behavior when running from command
line
vs. running w/in rails:

First, from command line:
require 'rubygems'
require 'activesupport'
require 'activeresource'

class Channel < ActiveResource::Base
  self.site = "http://192.168.1.101/"
  self.format = :json
end

c = Channel.find(:all , :params => {:owner => "iamwill"})

Result is:
/var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/json/decoding.rb:14:in
`decode': Invalid JSON string (ActiveSupport::JSON::ParseError)
    from
/var/lib/gems/1.8/gems/activeresource-2.3.2/lib/active_resource/formats/json_format.rb:19:in
`decode'
    from
/var/lib/gems/1.8/gems/activeresource-2.3.2/lib/active_resource/connection.rb:116:in
`get'
    from
/var/lib/gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:576:in
`find_every'
    from
/var/lib/gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:519:in
`find'
    from channels.rb:10

But when I run from rails, it parses no problem.

I gave the rails version malformed json to cause it to choke to figure
out
the difference:

vendor/rails/activesupport/lib/active_support/json/decoding.rb:14:in
`decode'


Is it possible to coerce the non-rails version to use the rails json
parser?  Why are there two different versions?

Thanks,


m
This topic is locked and can not be replied to.