spec/unit/card_spec.rb in trollolo-0.2.0 vs spec/unit/card_spec.rb in trollolo-0.3.0

- old
+ new

@@ -162,6 +162,117 @@ json = board.cards.first.as_json expect(json).to eq(expected_json.chomp) end end + + describe '#label?' do + before do + full_board_mock + trello = TrelloWrapper.new(dummy_settings) + @board = trello.board('53186e8391ef8671265eba9d') + end + + it 'returns true if card has label' do + expect(@board.columns.first.cards.first.label?('Sticky')).to be true + end + + it 'returns false if card does not have label' do + expect(@board.columns.first.cards.first.label?('imnolabel')).to be false + end + end + + describe '#swimlane?' do + let :subject do + Card.new(board_data, 'card_id', settings) + end + + let :settings do + settings = dummy_settings + settings.swimlanes = swimlanes + settings + end + + let :board_data do + { 'cards' => [{ 'id' => 'card_id', 'labels' => labels }] } + end + + let :labels do + [] + end + + context 'no swimlane' do + let :swimlanes do + [] + end + + it 'returns false' do + expect(subject.swimlane?).to be false + end + end + + context 'one swimlane' do + let :swimlanes do + ['a_swimlane'] + end + + context 'matching label' do + let :labels do + [{ 'name' => 'a_swimlane' }] + end + + it 'returns true' do + expect(subject.swimlane?).to be true + end + end + + context 'non-matching label' do + let :labels do + [{ 'name' => 'something_completely_different' }] + end + + it 'returns false' do + expect(subject.swimlane?).to be false + end + end + end + + context 'two swimlanes' do + let :swimlanes do + %w[a_swimlane another_swimlane] + end + + context 'matching label' do + let :labels do + [{ 'name' => 'another_swimlane' }] + end + + it 'returns true' do + expect(subject.swimlane?).to be true + end + end + + context 'one matching label of multiple labels' do + let :labels do + [ + { 'name' => 'something_completely_different' }, + { 'name' => 'another_swimlane' } + ] + end + + it 'returns true' do + expect(subject.swimlane?).to be true + end + end + + context 'non-matching label' do + let :labels do + [{ 'name' => 'something_completely_different' }] + end + + it 'returns false' do + expect(subject.swimlane?).to be false + end + end + end + end end