Sha256: dc9fc0dd63b1fd9180dac208c1c2a6683bdfaad69e0be9b3ede4dea68213b47a

Contents?: true

Size: 780 Bytes

Versions: 3

Compression:

Stored size: 780 Bytes

Contents

describe Evil::Client::DSL::Operations do
  let(:operations) { described_class.new }
  let(:settings)   { double(:settings, version: 1, user: "foo", password: "bar") }

  before do
    operations.register(nil) do |settings|
      http_method :post
      security    { basic_auth settings.user, settings.password }
    end

    operations.register(:find_user) do |_|
      http_method :get
      path        { |id:, **| "/users/#{id}" }
    end
  end

  subject { operations.finalize(settings) }

  it "builds a proper schema" do
    find_user = subject[:find_user]

    expect(find_user[:method]).to eq "get"
    expect(find_user[:path].call(id: 7)).to eq "users/7"
    expect(find_user[:security].call)
      .to eq headers: { "authorization" => "Basic Zm9vOmJhcg==" }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evil-client-0.2.3 spec/unit/evil/client/dsl/operations_spec.rb
evil-client-0.2.2 spec/unit/evil/client/dsl/operations_spec.rb
evil-client-0.2.1 spec/unit/evil/client/dsl/operations_spec.rb