-
Notifications
You must be signed in to change notification settings - Fork 1
/
task_spec.rb
30 lines (25 loc) · 877 Bytes
/
task_spec.rb
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
require_relative 'spec_helper.rb'
describe Task do
subject { described_class.new(description: "Feed the cat") }
describe '#to_s' do
it "returns the value of the task's description" do
expect(subject.to_s).to eq('Feed the cat')
end
end
describe '::list_tasks' do
let!(:task1) { Task.create(description: "Feed the Dog") }
let!(:task2) { Task.create(description: "Feed the Cat") }
let!(:task3) { Task.create(description: "Get Eggs") }
let!(:task4) { Task.create(description: "Cook the Fish") }
context 'when page number is 1' do
it 'gives first 2 tasks' do
expect(described_class.list_tasks(1, 2)).to match_array([task1, task2])
end
end
context 'when page number is 2' do
it 'gives last 2 tasks' do
expect(described_class.list_tasks(2, 2)).to eq([task3, task4])
end
end
end
end