Skip to content

Commit

Permalink
add failing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Dec 6, 2023
1 parent de5106c commit 3430404
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spec/rails/app/controllers/tables_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def show
end

def create
render json: find_table, status: 201
if params[:name].blank? || params[:name] == 'some_invalid_name'
render json: { error: 'invalid name parameter' }, status: 422
else
render json: find_table, status: 201
end
end

def update
Expand Down
17 changes: 17 additions & 0 deletions spec/requests/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@
}.to_json
expect(response.status).to eq(201)
end

it 'fails to create a table' do
post '/tables', headers: { authorization: 'k0kubun', 'Content-Type': 'application/json' }, params: {
description: 'description',
database_id: 2,
}.to_json
expect(response.status).to eq(422)
end

it 'fails to create a table (2)' do
post '/tables', headers: { authorization: 'k0kubun', 'Content-Type': 'application/json' }, params: {
name: 'some_invalid_name',
description: 'description',
database_id: 2,
}.to_json
expect(response.status).to eq(422)
end
end

describe '#update' do
Expand Down

0 comments on commit 3430404

Please sign in to comment.