|
1 | 1 | require 'swagger_helper' |
2 | 2 |
|
3 | | -RSpec.describe RSpec::Rails::Swagger::Helpers::Paths do |
4 | | - let(:klass) do |
5 | | - Class.new do |
6 | | - include RSpec::Rails::Swagger::Helpers::Paths |
7 | | - attr_accessor :metadata |
8 | | - def describe *args ; end |
9 | | - end |
10 | | - end |
11 | | - subject { klass.new } |
12 | | - |
13 | | - it "requires the path start with a /" do |
14 | | - expect{ subject.path("foo") }.to raise_exception(ArgumentError) |
15 | | - expect{ subject.path("/foo") }.not_to raise_exception |
16 | | - end |
17 | | - |
18 | | - describe 'swagger_doc' do |
19 | | - context 'with value specified in parent context' do |
20 | | - before { subject.metadata = {swagger_doc: 'default.json'} } |
21 | | - |
22 | | - it "defaults to the parent value" do |
23 | | - expect(subject).to receive(:describe).with("/ping", { |
24 | | - swagger_object: :path_item, |
25 | | - swagger_doc: 'default.json', |
26 | | - swagger_path_item: {path: '/ping'} |
27 | | - }) |
28 | | - |
29 | | - subject.path('/ping') |
30 | | - end |
31 | | - |
32 | | - it "uses the argument when provided" do |
33 | | - expect(subject).to receive(:describe).with("/ping", { |
34 | | - swagger_object: :path_item, |
35 | | - swagger_doc: 'overridden.json', |
36 | | - swagger_path_item: {path: '/ping'} |
37 | | - }) |
38 | | - |
39 | | - subject.path('/ping', swagger_doc: 'overridden.json') |
40 | | - end |
41 | | - end |
42 | | - |
43 | | - context 'without a parent swagger_doc' do |
44 | | - it "defaults to the first swagger document" do |
45 | | - expect(subject).to receive(:describe).with("/ping", { |
46 | | - swagger_object: :path_item, |
47 | | - swagger_doc: RSpec.configuration.swagger_docs.keys.first, |
48 | | - swagger_path_item: {path: '/ping'} |
49 | | - }) |
50 | | - |
51 | | - subject.path('/ping') |
52 | | - end |
53 | | - |
54 | | - it "uses the argument when provided" do |
55 | | - expect(subject).to receive(:describe).with("/ping", { |
56 | | - swagger_object: :path_item, |
57 | | - swagger_doc: 'overridden.json', |
58 | | - swagger_path_item: {path: '/ping'} |
59 | | - }) |
60 | | - |
61 | | - subject.path('/ping', swagger_doc: 'overridden.json') |
62 | | - end |
63 | | - end |
64 | | - end |
65 | | - |
66 | | - it "passes tags through to the metadata" do |
67 | | - expect(subject).to receive(:describe).with("/ping", { |
68 | | - swagger_object: :path_item, |
69 | | - swagger_doc: RSpec.configuration.swagger_docs.keys.first, |
70 | | - swagger_path_item: {path: '/ping'}, |
71 | | - tags: ['tag1'] |
72 | | - }) |
73 | | - |
74 | | - subject.path('/ping', tags: ['tag1']) |
75 | | - end |
76 | | -end |
77 | | - |
78 | 3 | RSpec.describe RSpec::Rails::Swagger::Helpers::PathItem do |
79 | 4 | let(:klass) do |
80 | 5 | Class.new do |
|
0 commit comments