[rspec-users] Understanding of extend/include

Gordon
Mon, 05 Dec 2011 00:15:08 -0000

hi, there

 I have been looking at
https://www.relishapp.com/rspec/rspec-core/docs/helper-methods/define-helper-methods-in-a-module.

This is the documentation for usage of extend and include.

In the section, "Scenario: extend a module in only some example
groups",
I refer  to the setup in RSpec.configure, "c.extend Helpers, :foo
=> :bar"
implies that the methods in Helpers are available to examples with the
metadata, ":foo=>:bar".

------------- Extract start ---------------

describe "an example group with matching metadata", :foo => :bar do
  puts "In a matching group, help is #{help}"

  it "does not have access to the helper methods defined in the
module" do
    expect { help }.to raise_error(NameError)
  end
end

------------- Extract end   ---------------

Question: Why is the example expected to fail (ie.
raise_error(NameError))
when the meta data matches and it''s expected to pass?