lib/nrser/rspex/example_group/describe/describe_called_with.rb
def describe_called_with *args, &body
  args = RSpex::Format::Args.new args

  subject_block = -> { super().call *args }
  
  describe_x Args(*args),
    type: :called_with,
    metadata: {
      called_with_args: args,
    },
    subject_block: subject_block,
    &body
end
# Create a new {RSpec.describe} section where the subject is set by
# calling the parent subject with `args` and evaluate `block` in it.
# 
# @example
#   describe "hi sayer" do
#     subject{ ->( name ) { "Hi #{ name }!" } }
#     
#     describe_called_with 'Mom' do
#       it { is_expected.to eq 'Hi Mom!' }
#     end
#   end
# 
# @param [Array] args
#   Arguments to call `subject` with to produce the new subject.
# 
# @param [#call] body
#   Block to execute in the context of the example group after refining
#   the subject.
# 
# @return [void]
# 
Create a new {RSpec.describe} section where the subject is set by
calling the parent subject with `args` and evaluate `block` in it.
Create a new { RSpec . describe } section where the subject is set by calling the parent subject with ` args ` and evaluate ` block ` in it .
def describe_called_with *args, &body
  args = RSpex::Format::Args.new args
  subject_block = -> { super().call *args }
  describe_x Args(*args),
    type: :called_with,
    metadata: {
      called_with_args: args,
    },
    subject_block: subject_block,
    &body
end
def describe_called_with * args , & body args = RSpex :: Format :: Args . new args subject_block = -> { super ( ) . call * args } describe_x Args ( * args ) , type : :called_with , metadata : { called_with_args : args , } , subject_block : subject_block , & body end
Create a new {RSpec.describe} section where the subject is set by
calling the parent subject with `args` and evaluate `block` in it.
Create a new { RSpec . describe } section where the subject is set by calling the parent subject with ` args ` and evaluate ` block ` in it .
None
void
args
body
body Block to execute in the context of the example group after refining the subject.
body Block to execute in the context of the example group after refining the subject .
example
describe "hi sayer" do subject{ ->( name ) { "Hi #{ name }!" } } describe_called_with 'Mom' do it { is_expected.to eq 'Hi Mom!' } end end
describe " hi sayer " do subject { - > ( name ) { " Hi # { name } ! " } } describe_called_with ' Mom ' do it { is_expected . to eq ' Hi Mom! ' } end end