templates/crystal/example/spec/handler_spec.cr in faastruby-0.4.18 vs templates/crystal/example/spec/handler_spec.cr in faastruby-0.5.0
- old
+ new
@@ -1,22 +1,27 @@
require "./spec_helper"
-describe "handler(event)" do
- event_hash = {
+private def event_hash
+ {
"body" => nil,
"context" => nil,
"headers" => {"Content-Type" => "application/json"},
"query_params" => {} of String => String
}
- event = Event.from_json(event_hash.to_json)
+end
+private def event
+ Event.from_json(event_hash.to_json)
+end
+
+describe "handler(event)" do
it "should return String" do
body = handler(event).body
- body.class.should eq(String)
+ body.should be_a String
end
+
it "should say Hello, World!" 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
+end
\ No newline at end of file