BigW Consortium Gitlab

taskable_shared_examples.rb 1.8 KB
Newer Older
Vinnie Okada committed
1 2 3
# Specs for task state functionality for issues and merge requests.
#
# Requires a context containing:
4
#   subject { Issue or MergeRequest }
Vinnie Okada committed
5
shared_examples 'a Taskable' do
6 7 8 9 10 11 12 13 14 15 16 17 18 19
  describe 'with multiple tasks' do
    before do
      subject.description = <<-EOT.strip_heredoc
        * [ ] Task 1
        * [x] Task 2
        * [x] Task 3
        * [ ] Task 4
        * [ ] Task 5
      EOT
    end

    it 'returns the correct task status' do
      expect(subject.task_status).to match('2 of')
      expect(subject.task_status).to match('5 tasks completed')
20 21
      expect(subject.task_status_short).to match('2/')
      expect(subject.task_status_short).to match('5 tasks')
22 23 24 25 26 27 28 29 30 31 32 33
    end

    describe '#tasks?' do
      it 'returns true when object has tasks' do
        expect(subject.tasks?).to eq true
      end

      it 'returns false when object has no tasks' do
        subject.description = 'Now I have no tasks'
        expect(subject.tasks?).to eq false
      end
    end
Vinnie Okada committed
34 35
  end

36 37 38 39 40 41 42 43 44 45
  describe 'with an incomplete task' do
    before do
      subject.description = <<-EOT.strip_heredoc
        * [ ] Task 1
      EOT
    end

    it 'returns the correct task status' do
      expect(subject.task_status).to match('0 of')
      expect(subject.task_status).to match('1 task completed')
46 47
      expect(subject.task_status_short).to match('0/')
      expect(subject.task_status_short).to match('1 task')
48
    end
Vinnie Okada committed
49 50
  end

51 52 53 54 55
  describe 'with a complete task' do
    before do
      subject.description = <<-EOT.strip_heredoc
        * [x] Task 1
      EOT
56
    end
Vinnie Okada committed
57

58 59 60
    it 'returns the correct task status' do
      expect(subject.task_status).to match('1 of')
      expect(subject.task_status).to match('1 task completed')
61 62
      expect(subject.task_status_short).to match('1/')
      expect(subject.task_status_short).to match('1 task')
63
    end
Vinnie Okada committed
64 65
  end
end