Today I Learned

hashrocket A Hashrocket project

About `:aggregate_failures` for rspec

When writing rspec tests you can separate your test cases as in:

describe "foo" do
  specify { expect(some_behavior).to be_well_behaved }
  specify { expect(some_other_behavior).to be_well_behaved }
end

Or if you prefer to write:

describe "foo" do
  it "handles some behaviors" do
    expect(some_behavior).to be_well_behaved
    expect(some_other_behavior).to be_well_behaved
  end
end

The second example has the downside that it will fail out of the it block if the first expect doesn't pass. To get around this, you can use:

describe "foo" do
  it "handles some behaviors", :aggregate_failures do
    expect(some_behavior).to be_well_behaved
    expect(some_other_behavior).to be_well_behaved
  end
end

Which will run the specs and collect their failures.

See More #testing TILs