rubyrspeccucumberrspec-expectations

Evaluating multiple rspec expectations with cucumber


I am using rspec expectations with cucumber. It seems that when using multiple expects in a cucumber steps, cucumber evaluates them until first of them fails. However I want to continue running also other expects to get a clear picture of what went wrong. Can I somehow achieve this?

Example: -let's suppose that response = "1", code = "2" and status = "3"

expect(response).to eq("0")
expect(code).to eq("2")
expect(status).to eq("1")

Cucumber will fail when evaluating response variable. But I want to check value of other two variables and get output for wrong status value too. Is this possible?


Solution

  • The easiest would be:

    expect({
      response: response,
      code: code,
      status: status}
    ).to eq({ response: "0", code: "2", status: "1" })
    

    If the test fails, you would see two hashes comparead, with a diff clearly visible.