spec/github/repos/keys_spec.rb in github_api-0.1.1 vs spec/github/repos/keys_spec.rb in github_api-0.1.2

- old
+ new

@@ -94,11 +94,11 @@ describe "create_key" do let(:inputs) { {:title => "octocat@octomac", :key => "ssh-rsa AAA..." } } context "resource created" do before do - stub_post("/repos/#{user}/#{repo}/keys"). + stub_post("/repos/#{user}/#{repo}/keys").with(inputs). to_return(:body => fixture("repos/key.json"), :status => 201) end it "should fail to create resource if 'title' input is missing" do expect { @@ -112,11 +112,11 @@ }.to raise_error(ArgumentError) end it "should create the resource" do github.repos.create_key(user, repo, inputs) - a_post("/repos/#{user}/#{repo}/keys").should have_been_made + a_post("/repos/#{user}/#{repo}/keys").with(inputs).should have_been_made end it "should get the key information back" do key = github.repos.create_key(user, repo, inputs) key.title.should == 'octocat@octomac' @@ -178,10 +178,21 @@ let(:key_id) { 1 } context "resource found successfully" do before do stub_delete("/repos/#{user}/#{repo}/keys/#{key_id}"). - to_return(:body => "", :status => 204) + to_return(:body => "", :status => 204, :headers => { :content_type => "application/json; charset=utf-8"} ) + end + + it "should fail to delete without 'user/repo' parameters" do + github.user, github.repo = nil, nil + expect { github.repos.delete_key }.to raise_error(ArgumentError) + end + + it "should fail to delete resource without key id" do + expect { + github.repos.delete_key user, repo, nil + }.to raise_error(ArgumentError) end it "should delete the resource" do github.repos.delete_key(user, repo, key_id) a_delete("/repos/#{user}/#{repo}/keys/#{key_id}").should have_been_made