Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- it('case describing conditionalParamter=NOT NULL'):
- expect(conditionalParamter, 'to be a', 'string') // Guard assertion which can FAIL test. Is it OK? Can I simply **SKIP** assertion WITHOUT test failing
- expect(myStub.args, 'to satisfy', [[ nonConditionalParamter, ExpressionWhichUsesNonNullConditionalParamterValue ]])
- it('case describing conditionalParamter= NULL')
- expect(conditionalParamter, 'to be falsy') // Guard assertion. The same issue
- expect(myStub.args, 'to satisfy', [[ nonConditionalParamter, ExpressionForNullConditionalParamterValue ]])
- class Foo
- def bar(required_param, conditional_param = nil)
- return 'abc' if conditional_param.nil?
- '123'
- end
- end
- describe Foo do
- subject(:foo) { described_class.new }
- describe '#bar' do
- subject(:bar) { foo.bar(required_param, conditional_param) }
- let(:required_param) { 'required_param' }
- context 'when conditional_param is nil (not present)' do
- let(:conditional_param) { nil }
- it 'returns abc' do
- expect(bar).to eq('abc')
- end
- end
- context 'when conditional_param is not nil' do
- let(:conditional_param) { true }
- it 'returns 123' do
- expect(bar).to eq('123')
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment