Module: Saharspec::Its::Call
- Defined in:
- lib/saharspec/its/call.rb
Instance Method Summary collapse
-
#its_call(*args, &block) ⇒ Object
For
#call-able subject, creates nested example where subject is called with arguments provided, allowing to apply block matchers like.to change(something)or.to raise_errorto different calls in a DRY way.
Instance Method Details
#its_call(*args, &block) ⇒ Object
For #call-able subject, creates nested example where subject is called with arguments
provided, allowing to apply block matchers like .to change(something) or .to raise_error
to different calls in a DRY way.
Also, plays really well with #ret block matcher.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/saharspec/its/call.rb', line 26 def its_call(*args, &block) # rubocop:disable Lint/NestedMethodDefinition describe("(#{args.map(&:inspect).join(', ')})") do let(:__call_subject) do warn 'No need to use its_call without arguments, just it {} will work' if args.empty? -> { subject.call(*args) } end def is_expected expect(__call_subject) end example(nil, &block) end # rubocop:enable Lint/NestedMethodDefinition end |