diff options
| author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-12-19 19:44:32 +0100 |
|---|---|---|
| committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-01-03 14:18:05 +0100 |
| commit | f10fe3ae97ade4ad73963b86c9ab2d7e4e021c61 (patch) | |
| tree | 20d9a9e3c67d5e38a31e029be51dbdac16785c0e /spec/lib/api/helpers | |
| parent | 128a5e410f4c51bbbcb1540435d3bea0b9a9c04d (diff) | |
| download | gitlab-ce-f10fe3ae97ade4ad73963b86c9ab2d7e4e021c61.tar.gz | |
Add API::Helpers::Version and expose API root URL
This commits adds a new class that is supposed to represent Grape API
version, like `v3` or `v4`.
Diffstat (limited to 'spec/lib/api/helpers')
| -rw-r--r-- | spec/lib/api/helpers/version_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/api/helpers/version_spec.rb b/spec/lib/api/helpers/version_spec.rb new file mode 100644 index 00000000000..63e7e1e6e95 --- /dev/null +++ b/spec/lib/api/helpers/version_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe API::Helpers::Version do + describe '.new' do + it 'is possible to initialize it with existing API version' do + expect(described_class.new('v4').to_s).to eq 'v4' + end + + it 'raises an error when unsupported API version is provided' do + expect { described_class.new('v111') }.to raise_error ArgumentError + end + end + + describe '#root_path' do + it 'returns a root path of the API version' do + expect(described_class.new('v4').root_path).to eq '/api/v4' + end + end + + describe '#root_url' do + it 'returns an URL for a root path for the API version' do + expect(described_class.new('v4').root_url) + .to match %r{^http?://.*/api/v4$} + end + end +end |
