Skip to content

Commit aa7b000

Browse files
committed
Add specs to very response bodies
Signed-off-by: David Celis <[email protected]>
1 parent c3f408e commit aa7b000

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

spec/grape_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
it 'should give a Total header' do
2020
expect(total).to eq(10)
2121
end
22+
23+
it 'should list all numbers in the response body' do
24+
body = '[1,2,3,4,5,6,7,8,9,10]'
25+
expect(last_response.body).to eq(body)
26+
end
2227
end
2328

2429
context 'with existing Link headers' do

spec/rails_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
it 'should give a Total header' do
2222
expect(total).to eq(10)
2323
end
24+
25+
it 'should list all numbers in the response body' do
26+
body = '[1,2,3,4,5,6,7,8,9,10]'
27+
expect(response.body).to eq(body)
28+
end
2429
end
2530

2631
context 'with existing Link headers' do

spec/support/shared_examples/first_page.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@
1818
it 'should give a Total header' do
1919
expect(total).to eq(100)
2020
end
21+
22+
it 'should list the first page of numbers in the response body' do
23+
body = '[1,2,3,4,5,6,7,8,9,10]'
24+
if defined?(response)
25+
expect(response.body).to eq(body)
26+
else
27+
expect(last_response.body).to eq(body)
28+
end
29+
end
2130
end

spec/support/shared_examples/last_page.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,14 @@
1818
it 'should give a Total header' do
1919
expect(total).to eq(100)
2020
end
21+
22+
it 'should list the last page of numbers in the response body' do
23+
body = '[91,92,93,94,95,96,97,98,99,100]'
24+
25+
if defined?(response)
26+
expect(response.body).to eq(body)
27+
else
28+
expect(last_response.body).to eq(body)
29+
end
30+
end
2131
end

spec/support/shared_examples/middle_page.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,14 @@
99
it 'should give a Total header' do
1010
expect(total).to eq(100)
1111
end
12+
13+
it 'should list a middle page of numbers in the response body' do
14+
body = '[11,12,13,14,15,16,17,18,19,20]'
15+
16+
if defined?(response)
17+
expect(response.body).to eq(body)
18+
else
19+
expect(last_response.body).to eq(body)
20+
end
21+
end
1222
end

0 commit comments

Comments
 (0)