-
Notifications
You must be signed in to change notification settings - Fork 106
/
diagnostic.rb
110 lines (89 loc) · 2.01 KB
/
diagnostic.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# frozen_string_literal: true
require 'rails_helper'
# Instructions:
# The tests you build for this diagnostic are not expected to pass.
# Merely provide a test for each given scenario.
def examples
Example.all
end
def example
Example.first
end
#
# Question 1
#
# In a Ruby comment, explain Behavior Driven Development, how it is meant to be
# used, and how it differs from Test Driven Development.
# your answer here
#
# Question 2
#
# Create a request spec for our Examples API that ensures 'GET /examples'
# responds successfully and lists all examples.
RSpec.describe 'Examples API' do
# your test(s) here
end
#
# Question 3
#
# Create a routing spec for our `Examples` resource that ensures
# GET /examples/:id routes to the examples#show action.
RSpec.describe 'routes for examples' do
# your test(s) here
end
#
# Question 4
#
# Test that a POST action from our ExamplesController is both successful
# and renders a JSON response.
RSpec.describe ExamplesController do
def example_params
{
name: 'Example name',
body: 'What a fantastic example this is...'
}
end
describe 'POST create' do
# your test(s) here
end
end
#
# Question 5
#
# Test that a PATCH action from our ExamplesController is both successful
# and renders a JSON response.
RSpec.describe ExamplesController do
def example_diff
{
body: 'This actually isn\'t that fantastic of an example...'
}
end
describe 'PATCH update' do
# your test(s) here
end
end
#
# Question 6
#
# Test that a DELETE action from our ExamplesController is both successful
# and renders an empty response.
RSpec.describe ExamplesController do
def example
Example.first
end
describe 'DELETE destroy' do
# your test(s) here
end
end
#
# Question 7
#
# Test that the Example model has an association with an
# `other` model. You'll have to build an `association` model
# on your own.
RSpec.describe Example do
describe 'associations' do
# association method here
# test association with `other` here
end
end