Some suggested updates to the slides in https://github.com/jessitron/generatron. These suggestions are based off of the array of built-in matchers that RSpec 3 provides (https://www.relishapp.com/rspec/rspec-expectations/v/3-0/docs/built-in-matchers). As well as the composability / compounding features now available: http://myronmars.to/n/dev-blog/2014/01/new-in-rspec-3-composable-matchers
expect(influence.relevance).to (be <= 100).and (be >= 0)You can also just make this a range matcher:
def be_in_range(range)
matcher = (be >= range.begin)
if range.exclude_end?
matcher = matcher.and(be < range.end)
else
matcher = matcher.and(be <= range.end)
end
matcher
endThen in the spec:
expect(influence.relevance).to be_in_range(0..100)When comparing hashes or partial hashes, the include and it's alias a_hash_including, and a_collection_including are helpful. I feel like the posted slides are slightly different from what I saw at SCRC14; though it's probably my memory that is off. It doesn't work as well in the PDF slides, but I hope it helps you at work. 😺
# Singular
expect(actual).to eq(event: search)
# There's at least one
expect(actual).to include(event: search)