Sha256: 4648b21b6587a9fdbc874b098d81eb8a8bed49081ece672dae76fa675f0ad91b

Contents?: true

Size: 761 Bytes

Versions: 4

Compression:

Stored size: 761 Bytes

Contents

require "./spec_helper"

describe "handler(event)" do
  body = {"name" => "Ruby"}.to_json
  event_hash = {
    "body" => body,
    "context" => nil,
    "headers" => {"Content-Type" => "application/json"},
    "query_params" => {} of String => String
  }
  event = Event.from_json(event_hash.to_json)

  it "should return Hash, String or Array" do
    body = handler(event).body
    body.class.should eq(String)
  end
  it "should add the name to the response string" do
    body = handler(event).body
    body.should eq("Hello, Ruby!\n")
  end
  it "should say Hello, World! when name is not present" do
    event_hash["body"] = nil
    event = Event.from_json(event_hash.to_json)
    body = handler(event).body
    body.should eq("Hello, World!\n")
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
faastruby-0.4.0 templates/crystal/example/spec/handler_spec.cr
faastruby-0.3.8 templates/crystal/example/spec/handler_spec.cr
faastruby-0.3.7 templates/crystal/example/spec/handler_spec.cr
faastruby-0.3.6 templates/crystal/example/spec/handler_spec.cr