Add retriever specs
This commit is contained in:
parent
a6f8135a17
commit
0029c81275
5 changed files with 79 additions and 2 deletions
|
@ -41,6 +41,7 @@ GEM
|
|||
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)
|
||||
|
@ -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)
|
||||
|
@ -117,6 +121,7 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
bundler (~> 1.16)
|
||||
pry
|
||||
psenv!
|
||||
psenv-rails!
|
||||
rake (~> 10.0)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Psenv
|
||||
VERSION = "0.2.0".freeze
|
||||
VERSION = "0.2.1".freeze
|
||||
end
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
71
spec/retriever_spec.rb
Normal 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
|
Loading…
Reference in a new issue