Sha256: b558fb57058417e4ead5085c0190a9e25dcc6551660f748c06257565adc53df4

Contents?: true

Size: 1.46 KB

Versions: 14

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Orgs::Teams, '#create' do
  let(:org)   { 'github' }
  let(:request_path) { "/orgs/#{org}/teams" }

  let(:inputs) {
    { :name => 'new team',
      :permissions => 'push',
      :repo_names => [ 'github/dotfiles' ]
    }
  }

  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 "resouce created" do
    let(:body) { fixture('orgs/team.json') }
    let(:status) { 201 }

    it "should fail to create resource if 'org_name' param is missing" do
      expect { subject.create }.to raise_error(ArgumentError)
    end

    it "should failt to create resource if 'name' input is missing" do
      expect {
        subject.create org, inputs.except(:name)
      }.to raise_error(Github::Error::RequiredParams)
    end

    it "should create resource successfully" do
      subject.create org, inputs
      a_post(request_path).with(inputs).should have_been_made
    end

    it "should return the resource" do
      team = subject.create org, inputs
      team.should be_a Github::ResponseWrapper
    end

    it "should get the team information" do
      team = subject.create org, inputs
      team.name.should == 'Owners'
    end
  end

  it_should_behave_like 'request failure' do
    let(:requestable) { subject.create org, inputs }
  end

end # create

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
github_api-0.11.3 spec/github/orgs/teams/create_spec.rb
github_api-0.11.2 spec/github/orgs/teams/create_spec.rb
github_api-0.11.1 spec/github/orgs/teams/create_spec.rb
github_api-0.11.0 spec/github/orgs/teams/create_spec.rb
github_api-0.10.2 spec/github/orgs/teams/create_spec.rb
github_api-0.10.1 spec/github/orgs/teams/create_spec.rb
github_api-0.10.0 spec/github/orgs/teams/create_spec.rb
github_api-0.9.7 spec/github/orgs/teams/create_spec.rb
github_api-0.9.6 spec/github/orgs/teams/create_spec.rb
github_api-0.9.5 spec/github/orgs/teams/create_spec.rb
github_api-0.9.4 spec/github/orgs/teams/create_spec.rb
github_api-0.9.3 spec/github/orgs/teams/create_spec.rb
github_api-0.9.2 spec/github/orgs/teams/create_spec.rb
github_api-0.9.1 spec/github/orgs/teams/create_spec.rb