mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
assert response body based on spec examples
This commit is contained in:
@@ -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
|
||||
|
||||
10
spec/dummy/app/models/blog.rb
Normal file
10
spec/dummy/app/models/blog.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Blog < ActiveRecord::Base
|
||||
attr_accessible :content, :title
|
||||
|
||||
def as_json(options)
|
||||
{
|
||||
title: title,
|
||||
content: content
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user