Setup project for testing
* Remove unecessary parts of Rails * Write tests * Document usage
This commit is contained in:
parent
acbd5d1462
commit
4d2661ec5e
13 changed files with 60 additions and 29 deletions
5
Gemfile
5
Gemfile
|
@ -18,6 +18,8 @@ gem 'bootsnap', '>= 1.4.2', require: false
|
|||
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
|
||||
# gem 'rack-cors'
|
||||
|
||||
gem 'psenv-rails'
|
||||
|
||||
group :development, :test do
|
||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
||||
|
@ -25,9 +27,6 @@ end
|
|||
|
||||
group :development do
|
||||
gem 'listen', '>= 3.0.5', '< 3.2'
|
||||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
||||
gem 'spring'
|
||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||
end
|
||||
|
||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||
|
|
25
Gemfile.lock
25
Gemfile.lock
|
@ -56,6 +56,18 @@ GEM
|
|||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.1, >= 2.1.8)
|
||||
aws-eventstream (1.0.3)
|
||||
aws-partitions (1.220.0)
|
||||
aws-sdk-core (3.68.1)
|
||||
aws-eventstream (~> 1.0, >= 1.0.2)
|
||||
aws-partitions (~> 1.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-ssm (1.57.0)
|
||||
aws-sdk-core (~> 3, >= 3.61.1)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sigv4 (1.1.0)
|
||||
aws-eventstream (~> 1.0, >= 1.0.2)
|
||||
bootsnap (1.4.5)
|
||||
msgpack (~> 1.0)
|
||||
builder (3.2.3)
|
||||
|
@ -68,6 +80,7 @@ GEM
|
|||
activesupport (>= 4.2.0)
|
||||
i18n (1.6.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jmespath (1.4.0)
|
||||
listen (3.1.5)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
|
@ -88,6 +101,11 @@ GEM
|
|||
nio4r (2.5.2)
|
||||
nokogiri (1.10.4)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
psenv (0.5.16.pre.local)
|
||||
aws-sdk-ssm (~> 1)
|
||||
psenv-rails (0.5.16.pre.local)
|
||||
psenv (= 0.5.16.pre.local)
|
||||
railties (>= 3.2, <= 6.1)
|
||||
puma (3.12.1)
|
||||
rack (2.0.7)
|
||||
rack-test (1.1.0)
|
||||
|
@ -123,10 +141,6 @@ GEM
|
|||
rb-inotify (0.10.0)
|
||||
ffi (~> 1.0)
|
||||
ruby_dep (1.5.0)
|
||||
spring (2.1.0)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 1.2, < 3.0)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
|
@ -150,10 +164,9 @@ DEPENDENCIES
|
|||
bootsnap (>= 1.4.2)
|
||||
byebug
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
psenv-rails
|
||||
puma (~> 3.11)
|
||||
rails (~> 6.0.0)
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
tzinfo-data
|
||||
|
||||
RUBY VERSION
|
||||
|
|
39
README.md
39
README.md
|
@ -1,24 +1,27 @@
|
|||
# README
|
||||
# psenv-test
|
||||
|
||||
This README would normally document whatever steps are necessary to get the
|
||||
application up and running.
|
||||
Used for testing the psenv-rails gem to validate.
|
||||
|
||||
Things you may want to cover:
|
||||
## Usage
|
||||
|
||||
* Ruby version
|
||||
* Generate new parameter store variable in AWS
|
||||
* `/psenv/test/API_KEY` with value "api_key_value"
|
||||
* `PARAMETER_STORE_PATH=/psenv/test bundle exec rails test`
|
||||
|
||||
* System dependencies
|
||||
## New Versions
|
||||
|
||||
* Configuration
|
||||
To test new versions of the gem, you can install the psenv-rails gem locally and
|
||||
reference it:
|
||||
|
||||
* Database creation
|
||||
|
||||
* Database initialization
|
||||
|
||||
* How to run the test suite
|
||||
|
||||
* Services (job queues, cache servers, search engines, etc.)
|
||||
|
||||
* Deployment instructions
|
||||
|
||||
* ...
|
||||
1. Clone psenv and complete work
|
||||
1. Likely updating Railtie requirements
|
||||
1. Update psenv lib/psenv/version.rb
|
||||
1. Example version name: `0.5.16-local`
|
||||
1. Run `bundle exec rake install` in psenv directory
|
||||
1. Note new gem version installed locally
|
||||
1. Example gem version: `0.5.16.pre.local`
|
||||
1. Open psenv-test project
|
||||
1. Update Gemfile with test version
|
||||
1. `gem 'psenv-rails', '0.5.16.pre.local'`
|
||||
1. `bundle install`
|
||||
1. `PARAMETER_STORE_PATH=/psenv/test bundle exec rails test`
|
||||
|
|
5
app/services/environment_tester.rb
Normal file
5
app/services/environment_tester.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class EnvironmentTester
|
||||
def self.call
|
||||
ENV.fetch('API_KEY', '')
|
||||
end
|
||||
end
|
|
@ -20,7 +20,7 @@ Rails.application.configure do
|
|||
'Cache-Control' => "public, max-age=#{2.days.to_i}"
|
||||
}
|
||||
else
|
||||
config.action_controller.perform_caching = false
|
||||
# config.action_controller.perform_caching = false
|
||||
|
||||
config.cache_store = :null_store
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
|
||||
config.cache_classes = false
|
||||
|
||||
# Do not eager load code on boot. This avoids loading your whole application
|
||||
|
|
0
test/fixtures/.keep
vendored
0
test/fixtures/.keep
vendored
0
test/fixtures/files/.keep
vendored
0
test/fixtures/files/.keep
vendored
10
test/services/environment_tester_test.rb
Normal file
10
test/services/environment_tester_test.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EnvironmentTesterTest < Minitest::Test
|
||||
describe '.call' do
|
||||
subject { ::EnvironmentTester.call }
|
||||
it 'returns the environment variable value' do
|
||||
assert_equal 'api_key_value', subject
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,7 @@
|
|||
ENV['RAILS_ENV'] ||= 'test'
|
||||
require_relative '../config/environment'
|
||||
require 'rails/test_help'
|
||||
require 'minitest/spec'
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
# Run tests in parallel with specified workers
|
||||
|
|
Reference in a new issue