Permalink
Browse files

fix specs

  • Loading branch information...
tongueroo committed Nov 22, 2017
1 parent ed76dcf commit e430b8370ff40a32a8649f48fcdc89b20dc46215
@@ -0,0 +1,2 @@
local: dynamodb-local # port 8000
admin: env AWS_ACCESS_KEY_ID=$DYNAMODB_ADMIN_AWS_ACCESS_KEY_ID PORT=8001 dynamodb-admin # port 8001
@@ -13,12 +13,14 @@ def config
@config ||= RecursiveOpenStruct.new
end

# Jets' the default config/application.rb is loaded,
# then the project's config/application.rb is loaded.
def load_configs
require File.expand_path("../default/application.rb", __FILE__)
app_config = "#{Jets.root}config/application.rb"
require app_config if File.exist?(app_config)
set_aliases!
normalize_environment!
normalize_env_vars!
end

# Use the shorter name in stack names, but use the full name when it
@@ -48,9 +50,10 @@ def set_aliases!
end
end

# It is pretty easy to attempt to environment variables without the correct
# AWS Environment.Variables path struture. We auto-fix it for convenience.
def normalize_environment!
# It is pretty easy to attempt to set environment variables without
# the correct AWS Environment.Variables path struture.
# Auto-fix it for convenience.
def normalize_env_vars!
environment = config.function.environment
if environment and !environment.to_h.key?(:variables)
config.function.environment = {
@@ -12,6 +12,7 @@
config.extra_autoload_paths = []

# function properties defaults
config.function = RecursiveOpenStruct.new
config.function.timeout = 10
config.function.runtime = "nodejs6.10"
config.function.memory_size = 1536
@@ -30,11 +30,14 @@ def config
Jets.application.config
end

# Calling application triggers load of configs.
# Jets' the default config/application.rb is loaded,
# then the project's config/application.rb is loaded.
@@application = nil
def application
return @@application if @@application
@@application = Jets::Application.new
@@application.load_configs # triggers load of application configs
@@application.load_configs
@@application
end

@@ -55,8 +55,7 @@
properties = resources["StoresControllerIndexLambdaFunction"]["Properties"]

expect(properties["MemorySize"]).to eq 1000
# should not pascalize the keys under Variables section
expect(properties["DeadLetterConfig"]).to eq "arn"
expect(properties["Timeout"]).to eq 20
end
end

@@ -34,7 +34,7 @@
# pp props
# testing properties(...)
expect(props["MemorySize"]).to eq 1000
expect(props["Role"]).to eq "myrole"
expect(props["Role"]).to eq("Ref"=>"IamRole")
expect(props["Timeout"]).to eq 20
end
end
@@ -1,6 +1,26 @@
require "spec_helper"

class TestPropertiesController < ApplicationController
properties(
dead_letter_config: "arn", timeout: 20, role: "myrole", memory_size: 1000
)
def index
end
end

describe Jets::Lambda::Dsl do
context "TestPropertiesController" do
let(:controller) { TestPropertiesController.new({}, nil, "index") }

it "tasks" do
index_task = TestPropertiesController.all_tasks[:index]
expect(index_task).to be_a(Jets::Lambda::Task)
expect(index_task.properties).to eq(
dead_letter_config: "arn", timeout: 20, role: "myrole", memory_size: 1000
)
end
end

context "StoresController" do
let(:controller) { StoresController.new({}, nil, "new") }

@@ -10,9 +30,6 @@

index_task = StoresController.all_tasks[:index]
expect(index_task).to be_a(Jets::Lambda::Task)
expect(index_task.properties).to eq(
dead_letter_config: "arn", timeout: 20, role: "myrole", memory_size: 1000
)
end

it "timeout" do
@@ -36,6 +36,15 @@ def json_file(path)
end
end

# pretty hacky way of stubbing out md5_code_zipfile
Jets::Naming # autoload it
class Jets::Naming
# override this for specs
def self.md5_code_zipfile
"/tmp/jets/demo/code/code-2e0e18f6.zip"
end
end

RSpec.configure do |c|
c.before(:suite) do
Aws.config.update(stub_responses: true)

0 comments on commit e430b83

Please sign in to comment.