Skip to content

Commit

Permalink
Adapt unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiQuan0605 committed Jan 8, 2025
1 parent aaf5206 commit d579482
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/v3/source/includes/api_resources/_info.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"description": "Put your apps here!",
"name": "Cloud Foundry",
"version": 123,
"osbapi_version": 456,
"links": {
"self": { "href": "http://api.example.com/v3/info" } ,
"support": { "href": "http://support.example.com" }
Expand All @@ -29,6 +30,7 @@
"description": "",
"name": "",
"version": 0,
"osbapi_version": "",
"links": {
"self": { "href": "http://api.example.com/v3/info" } ,
"support": { "href": "" }
Expand Down
12 changes: 11 additions & 1 deletion spec/request/info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@
description: TestConfig.config[:info][:description],
name: TestConfig.config[:info][:name],
version: TestConfig.config[:info][:version],
osbapi_version: TestConfig.config[:info][:osbapi_version],
links: {
self: { href: "#{link_prefix}/v3/info" },
support: { href: TestConfig.config[:info][:support_address] }
}
}
end

before do
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with(Rails.root.join('config/osbapi_version').to_s).and_return(true)
allow(File).to receive(:read).with(Rails.root.join('config/osbapi_version').to_s).and_return('1.0.0')

TestConfig.override(info: TestConfig.config[:info].merge(osbapi_version: '1.0.0'))
end

it 'includes data from the config' do
get '/v3/info'
expect(Oj.load(last_response.body)).to match_json_response(return_info_json)
Expand All @@ -38,7 +47,7 @@
description: '',
name: '',
version: 0,
osbapi_version: 0,
osbapi_version: '',
links: {
self: { href: "#{link_prefix}/v3/info" },
support: { href: '' }
Expand All @@ -48,6 +57,7 @@

before do
TestConfig.override(info: nil)
allow(File).to receive(:exist?).with(Rails.root.join('config/osbapi_version').to_s).and_return(false)
end

it 'includes has proper empty values' do
Expand Down

0 comments on commit d579482

Please sign in to comment.