Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove garnet spec #1306

Merged
merged 2 commits into from
Nov 15, 2022
Merged
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
4 changes: 2 additions & 2 deletions bin/amber_spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ crystal tool format --check
echo "\nRunning 'crystal spec':"
crystal spec

#echo "\nRunning 'crystal spec ./spec/build_spec_granite.cr':"
#crystal spec ./spec/build_spec_granite.cr
echo "\nRunning 'crystal spec ./spec/build_spec_granite.cr':"
crystal spec ./spec/build_spec_granite.cr
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require "../spec_helper"
require "../request_helper"
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def <%= create_model_method %>
model
end

class <%= class_name %>ControllerTest < GarnetSpec::SystemTest
class <%= class_name %>ControllerTest
include RequestHelper
getter handler : Amber::Pipe::Pipeline

def initialize
Expand Down
3 changes: 0 additions & 3 deletions src/amber/cli/templates/app/shard.yml.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ dependencies:
version: ~> 1.0.0

development_dependencies:
garnet_spec:
github: amberframework/garnet-spec
version: 0.4.1
ameba:
github: crystal-ameba/ameba
version: ~> 0.13.4
30 changes: 30 additions & 0 deletions src/amber/cli/templates/app/spec/request_helper.cr.ecr
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require "http"

module RequestHelper
macro included
{% http_read_verbs = %w(get head options trace connect) %}
{% http_write_verbs = %w(post put patch delete) %}
{% http_verbs = http_read_verbs + http_write_verbs %}

{% for method in http_verbs %}
def {{method.id}}(path, headers : HTTP::Headers? = nil, body : String? = nil)
request = HTTP::Request.new("{{method.id}}".upcase, path, headers, body )
{% if http_write_verbs.includes? method %}
request.headers["Content-Type"] ||= "application/x-www-form-urlencoded"
{% end %}
process_request(request)
end
{% end %}
end

private def process_request(request)
io = IO::Memory.new
response = HTTP::Server::Response.new(io)
context = HTTP::Server::Context.new(request, response)
handler.call context
response.close
io.rewind
client_response = HTTP::Client::Response.from_io(io, decompress: false)
client_response
end
end
1 change: 0 additions & 1 deletion src/amber/cli/templates/app/spec/spec_helper.cr.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ENV["AMBER_ENV"] ||= "test"

require "spec"
require "micrate"
require "garnet_spec"

require "../config/application"

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require "../spec_helper"
require "../request_helper"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class <%= class_name %>Channel < Amber::WebSockets::Channel
def handle_joined(client_socket, message)
def handle_joined(client_socket, msg)
end

def handle_message(client_socket, message)
def handle_message(client_socket, msg)
end

def handle_leave(client_socket)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require "../spec_helper"
require "../request_helper"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require "../spec_helper"
require "garnet_spec"
require "../request_helper"
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ describe <%= class_name %>Controller do
end

# Controller Integration Test
class <%= class_name %>ControllerTest < GarnetSpec::SystemTest
class <%= class_name %>ControllerTest
include RequestHelper
getter handler : Amber::Pipe::Pipeline

def initialize
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require "../spec_helper"
require "../request_helper"
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def <%= create_model_method %>
model
end

class <%= class_name %>ControllerTest < GarnetSpec::SystemTest
class <%= class_name %>ControllerTest
include RequestHelper
getter handler : Amber::Pipe::Pipeline

def initialize
Expand Down