Sha256: caf4e57b1d60edfbf8d9b7bd55dd362ef21463dbb8834deed6ca24213af86708

Contents?: true

Size: 1.58 KB

Versions: 13

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe Apiary::Command::Publish do
  context 'when constructed without a message' do
    let(:message) do
      Apiary::Command::Publish.new(api_name: 'myapi',
                                   path: 'spec/fixtures/apiary.apib',
                                   api_key: 'testkey').options.message
    end

    it 'uses the default message' do
      expect(message).to eq('Saving API Description Document from apiary-client')
    end
  end

  context 'when constructed with a message' do
    let(:message) do
      Apiary::Command::Publish.new(api_name: 'myapi',
                                   message: 'Custom message',
                                   path: 'spec/fixtures/apiary.apib',
                                   api_key: 'testkey').options.message
    end

    it 'stores the message in the opts' do
      expect(message).to eq('Custom message')
    end
  end

  describe '#execute' do
    context 'when calling with a custom message' do
      before(:all) do
        WebMock.stub_request(:post, 'https://api.apiary.io/blueprint/publish/myapi')
        Apiary::Command::Publish.new(api_name: 'myapi',
                                     message: 'Custom message',
                                     path: 'spec/fixtures/apiary.apib',
                                     api_key: 'testkey').execute
      end

      it 'sends the message when publishing' do
        expect(WebMock).to have_requested(:post, 'https://api.apiary.io/blueprint/publish/myapi')
          .with { |request| request.body.include? 'messageToSave=Custom+message' }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
apiaryio-0.17.0 spec/apiary/command/publish_spec.rb
apiaryio-0.16.1 spec/apiary/command/publish_spec.rb
apiaryio-0.16.0 spec/apiary/command/publish_spec.rb
apiaryio-0.15.2 spec/apiary/command/publish_spec.rb
apiaryio-0.15.1 spec/apiary/command/publish_spec.rb
apiaryio-0.15.0 spec/apiary/command/publish_spec.rb
apiaryio-0.14.1 spec/apiary/command/publish_spec.rb
apiaryio-0.14.0 spec/apiary/command/publish_spec.rb
apiaryio-0.13.0 spec/apiary/command/publish_spec.rb
apiaryio-0.12.0 spec/apiary/command/publish_spec.rb
apiaryio-0.11.1 spec/apiary/command/publish_spec.rb
apiaryio-0.11.0 spec/apiary/command/publish_spec.rb
apiaryio-0.10.2 spec/apiary/command/publish_spec.rb