Skip to content

Instantly share code, notes, and snippets.

@matsuda
Created April 27, 2009 06:09
Show Gist options
  • Save matsuda/102357 to your computer and use it in GitHub Desktop.
Save matsuda/102357 to your computer and use it in GitHub Desktop.
# github_api_test.rb
require 'rubygems'
require 'test/unit'
require 'fakeweb'
require File.join(File.dirname(__FILE__), 'github_api.rb')
class Test::Unit::TestCase
end
class GitHubApiTest < Test::Unit::TestCase
def test_repositories_search
response = DATA.read
FakeWeb.register_uri(:get, "http://github.com/api/v2/yaml/repos/show/foo/hoge", :string => response)
repository = GitHubApi.new.repository("foo", "hoge")
# リポジトリのオーナーが"foo"であることの確認
assert (repository["repository"][:owner] == "foo")
assert !(repository["repository"][:owner] == "bar")
# リポジトリ名が"hoge"であることの確認
assert (repository["repository"][:name] == "hoge")
assert !(repository["repository"][:name] == "rails")
FakeWeb.clean_registry
end
end
__END__
repository:
:description: My hoge project
:forks: false
:name: hoge
:watchers: 1
:private: false
:url: http://github.com/foo/hoge
:fork: 0
:owner: foo
:homepage: http://foo.example.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment