summaryrefslogtreecommitdiff
path: root/spec/support/taskable_shared_examples.rb
blob: 927c72c74098f000ea1cd0be098009ba79da13f4 (plain)
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
32
# Specs for task state functionality for issues and merge requests.
#
# Requires a context containing:
#   subject { Issue or MergeRequest }
shared_examples 'a Taskable' 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('5 tasks')
    expect(subject.task_status).to match('2 completed')
    expect(subject.task_status).to match('3 remaining')
  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
end