RSpec 2.7 and hash should have_key RSpec 2.7 and hash should have_key ruby ruby

RSpec 2.7 and hash should have_key


You can actually have RSpec matchers outside "it" blocks. You just need to include RSpec::Matchers.

[ ~/work/mobile_server (master)]$ irb>> require 'rspec'true>> include RSpec::MatchersObject < BasicObject>> {a: 1}.should have_key(:a)true


You need to actually do this inside an RSpec example, I don't think you can write that kind of code anywhere.

describe "" do  it "has a key" do     ...  endend