assert response body based on spec examples

This commit is contained in:
domaindrivendev
2016-02-23 00:30:10 -08:00
parent 071239727a
commit 9ad7a49e6d
16 changed files with 218 additions and 59 deletions

View File

@@ -1,14 +1,22 @@
class BlogsController < ApplicationController
wrap_parameters Blog
respond_to :json
# POST /blogs
def create
render json: {}
@blog = Blog.create(params[:blog])
respond_with @blog
end
# GET /blogs
def index
render json: {}
@blogs = Blog.all
respond_with @blogs
end
# GET /blogs/1
def show
render json: {}
@blog = Blog.find(params[:id])
respond_with @blog
end
end

View File

@@ -0,0 +1,10 @@
class Blog < ActiveRecord::Base
attr_accessible :content, :title
def as_json(options)
{
title: title,
content: content
}
end
end

View File

@@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>