Sha256: 84f19d2bd40836e1ec93073ced0b7e325285ec06b0899bcb1a576c511194051a
Contents?: true
Size: 1.42 KB
Versions: 25
Compression:
Stored size: 1.42 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Github::Repos::Keys, '#create' do let(:user) { 'peter-murach' } let(:repo) { 'github' } let(:request_path) { "/repos/#{user}/#{repo}/keys" } let(:inputs) { {:title => "octocat@octomac", :key => "ssh-rsa AAA..." } } before { stub_post(request_path).with(inputs). to_return(:body => body, :status => status, :headers => {:content_type => "application/json; charset=utf-8"}) } after { reset_authentication_for(subject) } context "resource created" do let(:body) { fixture("repos/key.json") } let(:status) { 201 } it "should fail to create resource if 'title' input is missing" do expect { subject.create user, repo, :key => 'ssh-rsa AAA...' }.to raise_error(Github::Error::RequiredParams) end it "should fail to create resource if 'key' input is missing" do expect { subject.create user, repo, :title => 'octocat@octomac' }.to raise_error(Github::Error::RequiredParams) end it "should create the resource" do subject.create user, repo, inputs a_post(request_path).with(inputs).should have_been_made end it "should get the key information back" do key = subject.create user, repo, inputs key.title.should == 'octocat@octomac' end end it_should_behave_like 'request failure' do let(:requestable) { subject.create user, repo, inputs } end end # create
Version data entries
25 entries across 25 versions & 1 rubygems