Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

rspec change matcher

require "counter"

RSpec.describe Counter, "#increment" do
  it "should increment the count" do
    expect { Counter.increment }.to change { Counter.count }.from(0).to(1)
  end

  # deliberate failure
  it "should increment the count by 2" do
    expect { Counter.increment }.to change { Counter.count }.by(2)
  end
end
Source by relishapp.com #
 
PREVIOUS NEXT
Tagged: #rspec #change #matcher
ADD COMMENT
Topic
Name
4+2 =