Skip to content

Commit

Permalink
Init Spec
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminguttmann-avtq committed Nov 8, 2024
1 parent 9099334 commit 02f141b
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.2
6 changes: 6 additions & 0 deletions spec/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "https://rubygems.org"
ruby '3.2.2'
gem 'bosh-template'
gem 'rspec'
gem 'json'
gem 'yaml'
37 changes: 37 additions & 0 deletions spec/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
GEM
remote: https://rubygems.org/
specs:
bosh-template (2.4.0)
semi_semantic (~> 1.2.0)
diff-lcs (1.5.0)
json (2.6.3)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
semi_semantic (1.2.0)
yaml (0.2.1)

PLATFORMS
x86_64-darwin-22

DEPENDENCIES
bosh-template
json
rspec
yaml

RUBY VERSION
ruby 3.2.2p53

BUNDLED WITH
2.4.10
33 changes: 33 additions & 0 deletions spec/firehose_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'rspec'
require 'json'
require 'yaml'
require 'bosh/template/test'

describe 'firehose_exporter job' do
let(:release) { Bosh::Template::Test::ReleaseDir.new(File.join(File.dirname(__FILE__), '..')) }
let(:job) { release.job('firehose_exporter') }

describe 'config/bpm.yml template' do
let(:template) { job.template('config/bpm.yml') }
let(:rendered_template) { template.render(properties) }
let(:properties) do
{
'firehose_exporter' => {
'metrics' => {
'environment' => 'test'
},
'logging' => {
'url' => 'http://api.yoursystemdomain.here.com'
},
'retro_compat' => {
'disable' => true
}
}
}
end

it 'renders with retro_compat disabled' do
expect(rendered_template).to include('FIREHOSE_EXPORTER_RETRO_COMPAT_DISABLE: true')
end
end
end
23 changes: 23 additions & 0 deletions spec/template_example_group.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# copied from https://github.com/cloudfoundry/bosh/blob/main/spec/template_example_group.rb
shared_examples_for "a rendered file" do
let(:content) { 'file content' }
let(:expected_content) { "file content\n" }
let(:file_name) do
raise 'Override this for file name'
end

let(:properties) do
raise 'Override this for binding properties'
end

let(:template) { File.read(File.join(File.dirname(__FILE__), file_name)) }

subject(:rendered_template) do
binding = Bosh::Template::EvaluationContext.new(properties, nil).get_binding
ERB.new(template).result(binding)
end

it 'should render the content correctly' do
expect(rendered_template).to eq(expected_content)
end
end

0 comments on commit 02f141b

Please sign in to comment.