payout / rester

An exceedingly quick way of creating restful interfaces between Ruby services.
https://www.payout.com
MIT License
2 stars 0 forks source link

Simplify defining stub context in consumer-side testing #69

Open roberthoner opened 8 years ago

roberthoner commented 8 years ago

Currently we set contexts like so:

describe 'something' do
  context 'with my context' do
    around { |ex| MyService.with_context('A stub context') { ex.run } }
    it { is_expected.to eq something }
  end
end

Option 1

# type: :rester or some other tag could add the `rester_context` method.
describe 'something', type: :rester do
  context 'with my context' do
    rester_context MyService, 'A stub context'
    it { is_expected.to eq something }
  end
end

Option 2

describe 'something' do
  # Could make stub contexts case-insensitive.
  context 'a stub context', service: MyService do
    it { is_expected.to eq something }
  end
end

Option 3

describe 'something' do
  # This one might be kind of tricky to implement with rspec.
  context 'with my context', MyService: 'A stub context' do
    it { is_expected.to eq something }
  end
end