Sha256: 5b93d63e01bf37e5ad5a49125607b790e7a325c709861c7549b5dfe2d1992e13
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe LHS::OptionBlocks do let(:status) { 200 } before do class Record < LHS::Record endpoint 'http://records' end stub_request(:get, 'http://records/?id=1234') .with(headers: { 'Tracking-Id' => 1 }) .to_return(status: status) end it 'allows to apply options to all requests made within a certain block' do LHS.options(headers: { 'Tracking-Id': 1 }) do Record.find(1234) end end it 'ensures that option blocks are reset after the block has been executed' do expect(LHS::OptionBlocks::CurrentOptionBlock.options).to eq nil LHS.options(headers: { 'Tracking-Id': 1 }) do Record.find(1234) end expect(LHS::OptionBlocks::CurrentOptionBlock.options).to eq nil end context 'failing request' do let(:status) { 400 } it 'ensures that option blocks are reset when an exception occures in the block' do expect(LHS::OptionBlocks::CurrentOptionBlock.options).to eq nil LHS.options(headers: { 'Tracking-Id': 1 }) do begin Record.find(1234) rescue LHC::Error end end expect(LHS::OptionBlocks::CurrentOptionBlock.options).to eq nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lhs-19.8.0 | spec/option_blocks/main_spec.rb |
lhs-19.7.0 | spec/option_blocks/main_spec.rb |