Sha256: 80f94eb8cae034241b717c6debcb4b5d30069371ef263536a3673d69cda18287

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require_relative 'matchers/create_command'
require_relative 'matchers/single_create_command'

def is_required(*params)
  params.each do |param|
    it ":#{param} parameter must be required" do
      expect(subject.class.input_filters.required_inputs).to include(param)
    end
  end
end

def is_optional(*params)
  params.each do |param|
    it ":#{param} parameter must be required" do
      expect(subject.class.input_filters.optional_inputs).to include(param)
    end
  end
end

def service_request_with(param, value, &block)
  context "when :#{param} = #{value.inspect}" do
    let(:params) do
      super().merge({ param => value })
    end
    it { yield(response.result) }
  end
end

def service_should_map(param, map)
  context param do
    map.each do |value, expected|
      service_request_with(param, value) { |r| r[param].should == expected }
    end
  end
end

def it_is(status)
  it "is :#{status}" do
    expect(response.success?).to eq(false)
    expect(response.result).to eq({})
    expect(response.status).to eq(:forbidden)
  end
end

def it_succeeds(message='succeeds', &block)
  it message do
    expect(response.success?).to eq(true)
    instance_eval(&block)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
restpack_service-0.0.69 lib/restpack_service/support/matchers.rb
restpack_service-0.0.68 lib/restpack_service/support/matchers.rb