BigW Consortium Gitlab

repo_spec.rb 1.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
require 'spec_helper'

describe Bitbucket::Representation::Repo do
  describe '#has_wiki?' do
    it { expect(described_class.new({ 'has_wiki' => false }).has_wiki?).to be_falsey }
    it { expect(described_class.new({ 'has_wiki' => true }).has_wiki?).to be_truthy }
  end

  describe '#name' do
    it { expect(described_class.new({ 'name' => 'test' }).name).to eq('test') }
  end

  describe '#valid?' do
    it { expect(described_class.new({ 'scm' => 'hg' }).valid?).to be_falsey }
    it { expect(described_class.new({ 'scm' => 'git' }).valid?).to be_truthy }
  end

  describe '#full_name' do
    it { expect(described_class.new({ 'full_name' => 'test_full' }).full_name).to eq('test_full') }
  end

  describe '#description' do
    it { expect(described_class.new({ 'description' => 'desc' }).description).to eq('desc') }
  end

  describe '#issues_enabled?' do
    it { expect(described_class.new({ 'has_issues' => false }).issues_enabled?).to be_falsey }
    it { expect(described_class.new({ 'has_issues' => true }).issues_enabled?).to be_truthy }
  end

  describe '#owner_and_slug' do
Douwe Maan committed
32
    it { expect(described_class.new({ 'full_name' => 'ben/test' }).owner_and_slug).to eq(%w(ben test)) }
33 34 35 36 37 38 39 40 41 42 43 44
  end

  describe '#owner' do
    it { expect(described_class.new({ 'full_name' => 'ben/test' }).owner).to eq('ben') }
  end

  describe '#slug' do
    it { expect(described_class.new({ 'full_name' => 'ben/test' }).slug).to eq('test') }
  end

  describe '#clone_url' do
    it 'builds url' do
45
      data = { 'links' => { 'clone' => [{ 'name' => 'https', 'href' => 'https://bibucket.org/test/test.git' }] } }
46 47 48 49
      expect(described_class.new(data).clone_url('abc')).to eq('https://x-token-auth:abc@bibucket.org/test/test.git')
    end
  end
end