Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4633

Issue with config template in BOSH release

$
0
0

I need some help with my first Bosh release, please? I am learning Bosh currently. Following is the spec file inside a job called 'rubyweb':

---name: rubywebtemplates:  ctl.erb: bin/ctl  config.erb: cfg/config.ymlpackages:- ruby-2.7properties:  port:    description: "Specify the port for the Web-app to listen on"    default: 8080  bootstrap:    description: "Specify the main file used to run the app"    default: "app.rb"

Following is the config.erb file:

port: <%=port = p('port')if (!port.eql? 8080) || (!port.eql? 8081)  raise "Invalid port number"endport%>

Following is the test case that is failing:

let(:conf_template) {job.template('cfg/config.yml')}it 'raises error if configs are wrong' do  expect {conf_template.render('port' => 1024)}.to raise_error 'Invalid port number'  expect {conf_template.render('port' => 7999)}.to raise_error 'Invalid port number'  expect {conf_template.render('port' => 8080)}.not_to raise_error endit 'raises error if yml is not parsable or malformed' do   parsable = true  begin    yml = YAML.load(conf_template.render('port' => 8080))  rescue StandardError => e    parsable = false  end    expect(parsable).to be true    expect(yml['port']).to eq(8080)end

Following is the error when the test is ran:

Failures:  1) ruby app main job: config template raises error if configs are wrong     Failure/Error: expect {conf_template.render('port' => 1024)}.to raise_error 'Invalid port number'       expected Exception with "Invalid port number", got #<ArgumentError: wrong number of arguments (given 0, expected 1)> with backtrace:         # /var/lib/gems/3.1.0/gems/bosh-template-2.3.0/lib/bosh/template/test/template.rb:14:in `render'         # ./spec/job_spec.rb:86:in `block (4 levels) in <top (required)>'         # ./spec/job_spec.rb:86:in `block (3 levels) in <top (required)>'     # ./spec/job_spec.rb:86:in `block (3 levels) in <top (required)>'  2) ruby app main job: config template raises error if yml is not parsable or malformed     Failure/Error: expect(parsable).to be true       expected true            got false     # ./spec/job_spec.rb:98:in `block (3 levels) in <top (required)>'

Viewing all articles
Browse latest Browse all 4633

Latest Images

Trending Articles



Latest Images