Sha256: d800fefc0e0774796156bbb4937f6d3201511450b33e4a9db483046c554f0b81
Contents?: true
Size: 1.87 KB
Versions: 6
Compression:
Stored size: 1.87 KB
Contents
require File.join(File.dirname(__FILE__), 'test_helper') class AuthenticatedTest < Test::Unit::TestCase include Octopi def setup fake_everything @user = User.find("fcoury") end context "following" do should "not be able to follow anyone if not authenticated" do exception = assert_raise AuthenticationRequired do Api.me.follow!("rails") end end should "be able to follow a user" do auth do assert_not_nil Api.me.follow!("rails") end end end context "unfollowing" do should "not be able to follow anyone if not authenticated" do exception = assert_raise AuthenticationRequired do Api.me.unfollow!("rails") end end should "be able to follow a user" do auth do assert_not_nil Api.me.unfollow!("rails") end end end context "invalid user" do should "raise Octopi::InvalidLogin" do # This simulates the [bad] response returned from the GitHub API due to bug 569 # http://support.github.com/discussions/site/569-using-the-v2-api-attempting-to-show-a-nonexistent-user-gives-a-500-error FakeWeb.register_uri(:get, "http://#{yaml_api}/user/show/invalid_user?", :status => ["404", "Not Found"], :body => "<html>:\n</html>") assert_raise Octopi::NotFound do Api.api.get("/user/show/invalid_user?", {}) end end end context "keys" do should "not be able to see keys if not authenticated" do exception = assert_raise AuthenticationRequired do Api.me.keys end assert_equal "To view keys, you must be authenticated", exception.message end should "have some keys" do auth do keys = Api.me.keys assert keys.is_a?(KeySet) assert_equal 2, keys.size end end end end
Version data entries
6 entries across 6 versions & 1 rubygems