HeavyTechRuby / bddsm

Hard Testing Framework
5 stars 3 forks source link

Need shared context and variables between expect inside one it block #25

Open lain0 opened 1 week ago

lain0 commented 1 week ago

For now, for your snipper there's no variable @calls_count could be shared between two instances of Execute class

BDDSM.describe do
  def with_calls_counted
    @calls_count ||= 0
    @calls_count += 1

    yield
  end

  let(:two) { with_calls_counted { one + 1 } }

  it do
    expect(two).to eq 2
    expect(@calls_count).to eq 1
  end
end
sergio-fry commented 1 week ago

Thanks for this issue.