我在本地工作了。
在aws中,我遇到了错误。
我在本地使用
run_lambda_function.rb
require_relative 'lambda_function'
lambda_handler(event: {},context: Object.new)
哪个电话
lambda_function.rb
require 'aws-sdk-lambda'
require 'json'
require 'rspec'
require 'capybara'
require 'capybara/rspec'
require 'webdrivers'
def lambda_handler(event:,context:)
@@short_sleep = 1 # just for these viewing and debugging purposes :)
Capybara.app_host = 'https://google.com'
RSpec::Core::Runner.run(['spec/google_spec.rb']) #,$stderr,$stdout)
end
使用规范:
spec / google_spec.rb
describe 'Visi Websites',type: :feature do
it 'can visit google' do
visit '/'
expect(page).to have_css('div')
sleep @@short_sleep
end
it 'can visit gogole/forms' do
visit '/forms'
expect(page).to have_css('div')
sleep @@short_sleep
end
end
这在本地运行,但是当我打包编码到供应商/并将其全部压缩后,将其上传到lambda(由于依赖项大于50k,因此通过S3存储桶*)并尝试在aws mgtmt控制台中运行网络驱动程序错误:
也许我可以使用无服务器的方法和其他方法来避免,但是我在学习的同时尽量保持简单和低水平,而没有依赖和帮助。当然可以。没有箍。
- 依赖项
Gemfile
对于在测试时进行本地捆绑,与我上载到/ vendor并将其全部打包的代码无关(我认为)与上传代码无关(因此,它很大并且需要通过s3存储桶进行加载)
source 'http://rubygems.org'
gem 'rspec'
gem 'webdrivers'
gem 'capybara'
gem 'aws-sdk'