diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/Gemfile b/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/Gemfile new file mode 100644 index 0000000000..b566789dfb --- /dev/null +++ b/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/Gemfile @@ -0,0 +1,8 @@ +source "https://rubygems.org" + +gem "httparty" + +group :test do + gem "test-unit" + gem "mocha" +end diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/hello_world/Gemfile b/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/hello_world/Gemfile index b566789dfb..3abba1b8b3 100644 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/hello_world/Gemfile +++ b/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/hello_world/Gemfile @@ -1,8 +1,3 @@ source "https://rubygems.org" gem "httparty" - -group :test do - gem "test-unit" - gem "mocha" -end diff --git a/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/tests/unit/test_handler.rb b/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/tests/unit/test_handler.rb index d496ec1866..df66b969a1 100644 --- a/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/tests/unit/test_handler.rb +++ b/samcli/local/init/templates/cookiecutter-aws-sam-hello-ruby/{{cookiecutter.project_name}}/tests/unit/test_handler.rb @@ -77,6 +77,16 @@ def mock_response end end + def expected_result + { + statusCode: 200, + body: { + message: 'Hello World!', + location: '1.1.1.1' + }.to_json + } + end + def test_lambda_handler HTTParty.expects(:get).with('http://checkip.amazonaws.com/').returns(mock_response) assert_equal(lambda_handler(event: event, context: ''), expected_result)