Sha256: b963609c0a61e63603eea94752903fa089cd235ac8725b900a276108dd471cb1

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

require_relative '../lib/tracker_fetched_mapper'

describe TrackerFetchedMapper do

  let(:renderer) { mock('renderer') }

  subject { TrackerFetchedMapper.new(renderer) }

  it { should respond_to :fetch }

  describe "#execute" do
    it "calls #map and passes result to Renderer" do
      commit_story = mock('commit_story')
      commit_story_status = mock('commit_story_status')

      subject.should_receive(:map).with(commit_story).and_return(commit_story_status)
      renderer.should_receive(:render).with(commit_story_status)

      subject.execute(commit_story)
    end
  end

  describe '#map' do
    it "maps { story_id => commit } to { commit => { story => story_id, state => state_symbol } }" do
      subject.should_receive(:fetch).with(['123', '234']).and_return({ '123' => :accepted, '234' => :rejected })
      subject.map({ '123' => 'x', '234' => 'y' }).should ==
          {
              'x' => { 'story' => '123', 'state' => :accepted },
              'y' => { 'story' => '234', 'state' => :rejected }
          }
    end

    it "ignores commit that corresponding story is not returned from #fetch" do
      subject.should_receive(:fetch).with(['123', '234']).and_return({ '234' => :rejected })
      subject.map({ '123' => 'x', '234' => 'y' }).should ==
          { 'y' => {'story' => '234', 'state' => :rejected } }
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_story-0.2.1 spec/tracker_fetched_state_spec.rb
git_story-0.2.0 spec/tracker_fetched_state_spec.rb
git_story-0.1.0 spec/tracker_fetched_state_spec.rb