Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ArticlesController < ApplicationController
@pets_file = 'app/controllers/jsons/pets.json'

@expected_pets = JSON.parse(File.read(@pets_file),symbolize_names: true)
def index
render json: @expected_pets
end
end
178 changes: 178 additions & 0 deletions app/controllers/jsons/pets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
[
{
"species": "Dog",
"breeds": {
"primary": "Labrador Retriever",
"secondary": null,
"mixed": true,
"unknown": false
},
"colors": {
"primary": "Black",
"secondary": "White / Cream",
"tertiary": null
},
"age": "Adult",
"gender": "Male",
"size": "Large",
"coat": "Short",
"attributes": {
"spayed_neutered": true,
"house_trained": true,
"declawed": null,
"special_needs": false,
"shots_current": true
},
"environment": {
"children": null,
"dogs": null,
"cats": null
},
"tags": [
"Friendly",
"Affectionate",
"Playful",
"Smart"
],
"name": "Gucci",
"description": "The allure of Fashion Week, with all its glitz and glamour, have nothing on Gucci, an energetic young pup who..."
},
{
"species": "Cat",
"breeds": {
"primary": "Domestic Short Hair",
"secondary": null,
"mixed": false,
"unknown": false
},
"colors": {
"primary": "Blue Cream",
"secondary": null,
"tertiary": null
},
"age": "Baby",
"gender": "Male",
"size": "Large",
"coat": "Short",
"attributes": {
"spayed_neutered": true,
"house_trained": true,
"declawed": false,
"special_needs": false,
"shots_current": true
},
"environment": {
"children": true,
"dogs": null,
"cats": true
},
"tags": [
"Friendly",
"Gentle",
"Playful",
"Affectionate",
"Curious"
],
"name": "Fred",
"description": null
},
{
"species": "Cat",
"breeds": {
"primary": "Domestic Short Hair",
"secondary": null,
"mixed": false,
"unknown": false
},
"colors": {
"primary": "Black",
"secondary": null,
"tertiary": null
},
"age": "Young",
"gender": "Male",
"size": "Medium",
"coat": "Short",
"attributes": {
"spayed_neutered": true,
"house_trained": false,
"declawed": false,
"special_needs": false,
"shots_current": true
},
"environment": {
"children": null,
"dogs": null,
"cats": null
},
"tags": [],
"name": "Neuron",
"description": "Meet Neron!Neron is a sweet and shy 1 1/2 year old cat looking for his forever home! He came..."
},
{
"species": "Cat",
"breeds": {
"primary": "Domestic Short Hair",
"secondary": null,
"mixed": true,
"unknown": false
},
"colors": {
"primary": null,
"secondary": null,
"tertiary": null
},
"age": "Young",
"gender": "Female",
"size": "Medium",
"coat": null,
"attributes": {
"spayed_neutered": false,
"house_trained": false,
"declawed": false,
"special_needs": false,
"shots_current": true
},
"environment": {
"children": null,
"dogs": null,
"cats": null
},
"tags": [],
"name": "Keebler Elf",
"description": "Primary Color: Brown Tabby Age: 0yrs 8mths 1wks"
},
{
"species": "Cat",
"breeds": {
"primary": "Domestic Short Hair",
"secondary": null,
"mixed": true,
"unknown": false
},
"colors": {
"primary": null,
"secondary": null,
"tertiary": null
},
"age": "Adult",
"gender": "Male",
"size": "Medium",
"coat": null,
"attributes": {
"spayed_neutered": true,
"house_trained": false,
"declawed": false,
"special_needs": false,
"shots_current": true
},
"environment": {
"children": null,
"dogs": null,
"cats": null
},
"tags": [],
"name": "Mooney",
"description": "Primary Color: Grey Tabby Secondary Color: White Weight: 11.5lbs Age: 3yrs 3mths 2wks Animal has been Neutered"
}
]
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

# Defines the root path route ("/")
# root "articles#index"
# get '/articles', to: 'articles#index'

resources :articles, only: [:index]
end
11 changes: 11 additions & 0 deletions spec/routing/articles_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'rails_helper'

RSpec.describe '/article routes' do
it 'routes' do
aggregate_failures do
#expect(get '/articles').to route_to(controller: 'articles', action: 'index')
expect(get '/articles').to route_to('articles#index')
expect(get '/articles?page[number]=3').to route_to('articles#index', page: { number: 3})
end
end
end