|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe GrapeSwagger::DocMethods::Produces do |
| 4 | + describe ":json (default)" do |
| 5 | + subject { described_class.call } |
| 6 | + |
| 7 | + specify do |
| 8 | + expect(subject).to eql( ['application/json'] ) |
| 9 | + end |
| 10 | + end |
| 11 | + |
| 12 | + describe "accept symbols of" do |
| 13 | + describe "single" do |
| 14 | + subject { described_class.call(:xml) } |
| 15 | + |
| 16 | + specify do |
| 17 | + expect(subject).to eql( ['application/xml'] ) |
| 18 | + end |
| 19 | + end |
| 20 | + |
| 21 | + describe "multiple" do |
| 22 | + subject { described_class.call(:xml, :serializable_hash, :json, :binary, :txt) } |
| 23 | + |
| 24 | + specify do |
| 25 | + expect(subject).to eql( [ |
| 26 | + 'application/xml', |
| 27 | + 'application/json', |
| 28 | + 'application/octet-stream', |
| 29 | + 'text/plain' |
| 30 | + ] ) |
| 31 | + end |
| 32 | + end |
| 33 | + end |
| 34 | + |
| 35 | + describe "accept mime_types of" do |
| 36 | + describe "single" do |
| 37 | + subject { described_class.call('application/xml') } |
| 38 | + |
| 39 | + specify do |
| 40 | + expect(subject).to eql( ['application/xml'] ) |
| 41 | + end |
| 42 | + end |
| 43 | + |
| 44 | + describe "multiple" do |
| 45 | + subject { described_class.call( |
| 46 | + 'application/xml', |
| 47 | + 'application/json', |
| 48 | + 'application/octet-stream', |
| 49 | + 'text/plain' |
| 50 | + ) } |
| 51 | + |
| 52 | + specify do |
| 53 | + expect(subject).to eql( [ |
| 54 | + 'application/xml', |
| 55 | + 'application/json', |
| 56 | + 'application/octet-stream', |
| 57 | + 'text/plain' |
| 58 | + ] ) |
| 59 | + end |
| 60 | + end |
| 61 | + end |
| 62 | + |
| 63 | + describe "mix it up" do |
| 64 | + subject { described_class.call( |
| 65 | + :xml, |
| 66 | + :serializable_hash, |
| 67 | + 'application/json', |
| 68 | + 'application/octet-stream', |
| 69 | + :txt |
| 70 | + ) } |
| 71 | + |
| 72 | + specify do |
| 73 | + expect(subject).to eql( [ |
| 74 | + 'application/xml', |
| 75 | + 'application/json', |
| 76 | + 'application/octet-stream', |
| 77 | + 'text/plain' |
| 78 | + ] ) |
| 79 | + end |
| 80 | + |
| 81 | + subject { described_class.call( [ |
| 82 | + :xml, |
| 83 | + :serializable_hash, |
| 84 | + 'application/json', |
| 85 | + 'application/octet-stream', |
| 86 | + :txt |
| 87 | + ] ) } |
| 88 | + |
| 89 | + specify do |
| 90 | + expect(subject).to eql( [ |
| 91 | + 'application/xml', |
| 92 | + 'application/json', |
| 93 | + 'application/octet-stream', |
| 94 | + 'text/plain' |
| 95 | + ] ) |
| 96 | + end |
| 97 | + end |
| 98 | +end |
0 commit comments