Skip to content

Commit

Permalink
Library now handles new attributes in API without issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bjeanes authored and Integrum committed Jun 5, 2010
1 parent b59ac48 commit a0cd475
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/octopi/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def initialize(attributes={})
# puts caller.first.inspect
# puts "#{self.class.inspect} #{attributes.keys.map { |s| s.to_sym }.inspect}"
attributes.each do |key, value|
raise "no attr_accessor set for #{key} on #{self.class}" if !respond_to?("#{key}=")
self.send("#{key}=", value)
method = "#{key}="
self.send(method, value) if respond_to? method
end
end

Expand Down
20 changes: 20 additions & 0 deletions test/base_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require File.join(File.dirname(__FILE__), 'test_helper')

class BaseTest < Test::Unit::TestCase
class SparseUser < Octopi::Base
include Octopi::Resource

attr_accessor :some_attribute

find_path "/user/search/:query"
resource_path "/user/show/:id"
end

def setup
fake_everything
end

should "not raise an error if it doesn't know about the attributes that GitHub API provides" do
assert_nothing_raised { SparseUser.find("radar") }
end
end

0 comments on commit a0cd475

Please sign in to comment.