Skip to content

Instantly share code, notes, and snippets.

@odlp
Created July 4, 2017 09:43
Show Gist options
  • Save odlp/724f278505a0dfffbb5825656d21e78d to your computer and use it in GitHub Desktop.
Save odlp/724f278505a0dfffbb5825656d21e78d to your computer and use it in GitHub Desktop.
Example of a negated matcher
require "rails_helper"
RSpec::Matchers.define_negated_matcher :not_be_present, :be_present
RSpec.describe "all matcher" do
it "cooperates with negated matchers" do
expect([nil, "", " "]).to all(not_be_present)
# Whereas this doesn't work:
# expect([nil, "", " "]).to_not all(be_present)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment