Sha256: ef6f060733704a3556a5699afef01f3725be0f766eb2148e0794ba432475753d

Contents?: true

Size: 1.58 KB

Versions: 11

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%20message' }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
apiaryio-0.10.1 spec/apiary/command/publish_spec.rb
apiaryio-0.9.1 spec/apiary/command/publish_spec.rb
apiaryio-0.9.0 spec/apiary/command/publish_spec.rb
apiaryio-0.8.1 spec/apiary/command/publish_spec.rb
apiaryio-0.8.0 spec/apiary/command/publish_spec.rb
apiaryio-0.7.0 spec/apiary/command/publish_spec.rb
apiaryio-0.6.1 spec/apiary/command/publish_spec.rb
apiaryio-0.6.0 spec/apiary/command/publish_spec.rb
apiaryio-0.5.2 spec/apiary/command/publish_spec.rb
apiaryio-0.5.1 spec/apiary/command/publish_spec.rb
apiaryio-0.5.0 spec/apiary/command/publish_spec.rb