Sha256: 4e27b5559aa853dd7555ac762ed374c7cb5f0935f80f7bb4c0dd12fed83a4024

Contents?: true

Size: 918 Bytes

Versions: 3

Compression:

Stored size: 918 Bytes

Contents

require 'git_tracker/branch'

describe GitTracker::Branch do
  subject { described_class }

  def stub_branch(ref)
    subject.stub('`') { ref }
  end

  context "Current branch has a story number" do
    before do
      stub_branch('refs/heads/a_very_descriptive_name_#8675309')
    end

    it "shells out to git, looking for the current HEAD" do
      subject.should_receive('`').with('git symbolic-ref HEAD')
      subject.story_number
    end

    it "finds the story" do
      subject.story_number.should == '8675309'
    end
  end

  context "The current branch doesn't have a story number" do
    it "finds no story" do
      stub_branch('refs/heads/a_very_descriptive_name_without_a_#number')
      subject.story_number.should_not be
    end
  end

  context "Not on a branch (HEAD doesn't exist)" do
    it "finds no story" do
      stub_branch('')
      subject.story_number.should_not be
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_tracker-1.0.1 spec/git_tracker/branch_spec.rb
git_tracker-1.0.0 spec/git_tracker/branch_spec.rb
git_tracker-0.0.1 spec/git_tracker/branch_spec.rb