Sha256: 89c50b12603098a4b15816640e9ee0813b183e3d27aa4caf86e2c29503835e04

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Orgs::Members, '#member?' do
  let(:org)    { 'github' }
  let(:member) { 'peter-murach' }
  let(:body) { "" }

  before {
    stub_get(request_path).to_return(:body => body, :status => status,
      :headers => {:content_type => "application/json; charset=utf-8"})
  }

  after { reset_authentication_for(subject) }

  context "when private" do
    let(:request_path) { "/orgs/#{org}/members/#{member}" }

    context "this repo is being watched by the user" do
      let(:status) { 404 }

      it "should fail validation " do
        expect { subject.member?(nil, nil) }.to raise_error(ArgumentError)
      end

      it "should return false if resource not found" do
        membership = subject.member? org, member
        membership.should be_false
      end
    end

    context 'user is member of an organization' do
      let(:status) { 204 }

      it "should return true if resoure found" do
        membership = subject.member? org, member
        membership.should be_true
      end
    end
  end

  context 'when public' do
    let(:request_path) { "/orgs/#{org}/public_members/#{member}" }

    context "this repo is being watched by the user" do
      let(:status) { 404 }

      it "should return false if resource not found" do
        public_member = subject.member? org, member, :public => true
        public_member.should be_false
      end
    end

    context 'user is member of an organization' do
      let(:status) { 204 }

      it "should return true if resoure found" do
        public_member = subject.member? org, member, :public => true
        public_member.should be_true
      end
    end
  end

end # member?

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
github_api-0.9.0 spec/github/orgs/members/member_spec.rb
github_api-0.8.11 spec/github/orgs/members/member_spec.rb
github_api-0.8.10 spec/github/orgs/members/member_spec.rb
github_api-0.8.9 spec/github/orgs/members/member_spec.rb