1
0
Fork 0

Merge pull request #1 from atomaka/feature/retriever-specs

Add retriever specs
This commit is contained in:
Andrew Tomaka 2018-04-09 23:24:27 -04:00 committed by GitHub
commit b6061f18ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 107 additions and 21 deletions

View File

@ -1,6 +1,7 @@
AllCops:
Exclude:
- db/schema.rb
- vendor/**/*
Metrics/LineLength:
Description: 'Limit lines to 80 characters.'

View File

@ -1,5 +1,13 @@
sudo: false
cache: bundler
language: ruby
rvm:
- 2.4.2
before_install: gem install bundler -v 1.16.1
jobs:
include:
- stage: analyze
script: bundle exec rubocop
- stage: test
script: bundle exec rspec

View File

@ -1,56 +1,57 @@
PATH
remote: .
specs:
psenv (0.2.0)
psenv (0.2.1)
aws-sdk-ssm (~> 1)
psenv-rails (0.2.0)
psenv (= 0.2.0)
psenv-rails (0.2.1)
psenv (= 0.2.1)
railties (>= 3.2, < 5.2)
GEM
remote: https://rubygems.org/
specs:
actionpack (5.1.5)
actionview (= 5.1.5)
activesupport (= 5.1.5)
actionpack (5.1.6)
actionview (= 5.1.6)
activesupport (= 5.1.6)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.5)
activesupport (= 5.1.5)
actionview (5.1.6)
activesupport (= 5.1.6)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activesupport (5.1.5)
activesupport (5.1.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.4.0)
aws-partitions (1.74.0)
aws-sdk-core (3.18.0)
aws-partitions (1.79.0)
aws-sdk-core (3.19.0)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-ssm (1.8.0)
aws-sdk-ssm (1.10.0)
aws-sdk-core (~> 3)
aws-sigv4 (~> 1.0)
aws-sigv4 (1.0.2)
builder (3.2.3)
coderay (1.1.2)
concurrent-ruby (1.0.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.3)
crass (1.0.4)
diff-lcs (1.3)
erubi (1.7.1)
hashdiff (0.3.7)
i18n (0.9.5)
i18n (1.0.0)
concurrent-ruby (~> 1.0)
jmespath (1.3.1)
jmespath (1.4.0)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
@ -63,6 +64,9 @@ GEM
parser (2.5.0.5)
ast (~> 2.4.0)
powerpack (0.1.1)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.2)
rack (2.0.4)
rack-test (1.0.0)
@ -72,9 +76,9 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.1.5)
actionpack (= 5.1.5)
activesupport (= 5.1.5)
railties (5.1.6)
actionpack (= 5.1.6)
activesupport (= 5.1.6)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
@ -117,6 +121,7 @@ PLATFORMS
DEPENDENCIES
bundler (~> 1.16)
pry
psenv!
psenv-rails!
rake (~> 10.0)

View File

@ -1,3 +1,3 @@
module Psenv
VERSION = "0.2.0".freeze
VERSION = "0.2.1".freeze
end

View File

@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.16"
spec.add_development_dependency "pry"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop", "0.54"

View File

@ -49,6 +49,6 @@ RSpec.describe Psenv::Environment do
it "applies duplicates based on the first provided" do
expect(ENV["B"]).to eq("1")
end
end
end
end

71
spec/retriever_spec.rb Normal file
View File

@ -0,0 +1,71 @@
require "spec_helper"
require "ostruct"
RSpec.describe Psenv::Parameter do
context ".new" do
let(:parameter) do
{
name: "/psenv/test/VARIABLE",
value: "value",
type: "String",
version: 1,
}
end
subject { Psenv::Parameter.new(parameter) }
it "creates a paraemeter object" do
expect(subject).to be_kind_of(Psenv::Parameter)
end
it "stores the correct name" do
expect(subject.name).to eq("VARIABLE")
end
it "stores the value" do
expect(subject.value).to eq("value")
end
end
end
RSpec.describe Psenv::Retriever do
context ".new" do
it "creates a retriever object" do
expect(Psenv::Retriever.new("A")).to be_kind_of(Psenv::Retriever)
end
end
context "#call" do
let(:ssm) { double }
before(:each) { allow(Aws::SSM::Client).to receive(:new) { ssm } }
subject { Psenv::Retriever.new("/psenv/test").call }
context "with a successful request" do
before(:each) do
allow(ssm).to receive(:get_parameters_by_path) {
OpenStruct.new(
parameters: [{
name: "/psenv/test/API_KEY",
value: "value",
type: "String",
version: 1,
}],
)
}
end
it "returns the parsed parameters" do
expect(subject).to eq("API_KEY" => "value")
end
end
context "when the request fails" do
before(:each) { allow(ssm).to receive(:get_parameters_by_path).and_raise }
it "raises a RetrieveError" do
expect { subject }.to raise_error(Psenv::RetrieveError)
end
end
end
end