メタデータ、シンボルを使ってインクルード、エクステンドする

>### Background
```rb
module Helpers
  def help
    :available
  end
end
```
#### 一部のexampleグループだけでモジュールをインクルードする
>### Include a module in only some example groups
```rb
require './helpers'

RSpec.configure do |c|
  c.include Helpers, :foo => :bar
end

RSpec.describe "an example group with matching metadata", :foo => :bar do
  it "has access to the helper methods defined in the module" do
    expect(help).to be(:available)
  end
end

RSpec.describe "an example group without matching metadata" do
  it "does not have access to the helper methods defined in the module" do
    expect { help }.to raise_error(NameError) # 
  end

  it "does have access when the example has matching metadata", :foo => :bar do
    expect(help).to be(:available)
  end
end
```
```
Run options: include {:full_description=>/an\ example\ group\ with\ matching\ metadata/}
1 example, 0 failures, 1 passed
```
```
Run options: include {:full_description=>/an\ example\ group\ without\ matching\ metadata/}
2 examples, 0 failures, 2 passed
```
#### :barだけだとエラーが出る、:foo => :barだと成功する
```rb
RSpec.describe "an example group with matching metadata", :bar do
  it "has access to the helper methods defined in the module" do
    expect(help).to be(:available)
  end
end
```
```
Run options: include {:full_description=>/an\ example\ group\ with\ matching\ metadata/}

NameError: undefined local variable or method `help' for #<RSpec::ExampleGroups::AnExampleGroupWithMatchingMetadata "has access to the helper methods defined in the module" (./spec/models/user_spec.rb:22)>

  0) an example group with matching metadata has access to the helper methods defined in the module
     Failure/Error: expect(help).to be(:available)

     NameError:
       undefined local variable or method `help' for #<RSpec::ExampleGroups::AnExampleGroupWithMatchingMetadata "has access to the helper methods defined in the module" (./spec/models/user_spec.rb:22)>
     # ./spec/models/user_spec.rb:23:in `block (2 levels) in <top (required)>'
1 example, 1 failure, 0 passed
```
#### 一部のexampleグループだけでモジュールをエクステンドできる
>### Extend a module in only some example groups
```rb
require './helpers'

RSpec.configure do |c|
  c.extend Helpers, :foo => :bar
end

RSpec.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

RSpec.describe "an example group without matching metadata" do
  puts "In a non-matching group, help is #{help rescue 'not available'}"

  it "does not have access to the helper methods defined in the module" do
    expect { help }.to raise_error(NameError)
  end
end
```
```
In a matching group, help is available
In a non-matching group, help is not available
Run options: include {:full_description=>/an\ example\ group\ with\ matching\ metadata/}
1 example, 0 failures, 1 passed
```
```
In a matching group, help is available
In a non-matching group, help is not available
Run options: include {:full_description=>/an\ example\ group\ without\ matching\ metadata/}
1 example, 0 failures, 1 passed
```

#### putsはグループ(?)が違っても読み込まれる
```rb
RSpec.describe "an example group with matching metadata", :foo => :bar do
  puts "In a non-matching group, help is #{help rescue 'not available'}"


end

RSpec.describe "an example group without matching metadata" do
  puts "In a non-matching group, help is #{help rescue 'not available'}"


end
```
```
In a non-matching group, help is available
In a non-matching group, help is not available
Run options: include {:full_description=>/an\ example\ group\ with\ matching\ metadata/}

All examples were filtered out
0 examples, 0 failures, 0 passed
```
#### メタデータとしてシンボルを使う
>### Use symbols as metadata
```rb
require './helpers'

RSpec.configure do |c|
  c.include Helpers, :include_helpers # シンボルだけでも呼び出せる https://rspec.info/features/3-13/rspec-core/helper-methods/modules/#:~:text=You%20can%20also%20specify%20metadata%20using%20only%20symbols.
  c.extend  Helpers, :extend_helpers
end

RSpec.describe "an example group with matching include metadata", :include_helpers do
  puts "In a group not matching the extend filter, help is #{help rescue 'not available'}"

  it "has access to the helper methods defined in the module" do
    expect(help).to be(:available)
  end
end

RSpec.describe "an example group with matching extend metadata", :extend_helpers do
  puts "In a group matching the extend filter, 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
```
```
In a group not matching the extend filter, help is not available
In a group matching the extend filter, help is available
Run options: include {:full_description=>/an\ example\ group\ with\ matching\ include\ metadata/}
1 example, 0 failures, 1 passed
```
```
In a group not matching the extend filter, help is not available
In a group matching the extend filter, help is available
Run options: include {:full_description=>/an\ example\ group\ with\ matching\ extend\ metadata/}
1 example, 0 failures, 1 passed
```

https://rspec.info/features/3-13/rspec-core/helper-methods/modules/