I got it working locally.
In aws i am getting an error.
Locally I use
run_lambda_function.rb
require_relative 'lambda_function'
lambda_handler(event: {}, context: Object.new)
Which calls
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
which uses spec:
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
This runs locally but when I bundle to code to vendor/ and zip it all up, upload it to lambda (via S3 bucket due to size > 50k for dependencies*) and try to run it in aws mgtmt console I get an error in webdrivers:
I might be able to avoid with serverless and other approaches perhaps but I am trying to stay as simple and low-level without dependencies and aids while I am learning. Within reason of course. No hoops.
- dependencies
Gemfile
for locally bundling while testing, not relevant (I think) to uploaded code as I bundled that to /vendor and zipped it all (hence the large size and need for load via s3 bucket)
source 'http://rubygems.org'
gem 'rspec'
gem 'webdrivers'
gem 'capybara'
gem 'aws-sdk'