filter_run_when_matching

# filter_run_when_matchingでシンボルを使わなくてもfを接頭辞で指定できる。
`filter_run_when_matching`を使う
># Using filter_run_when_matching
`config.filter_run_when_matching`を使って一致したexampleがあった場合のみ適応する条件付きのフィルターを設定できる。これは一般にfocusフィルタリングが使われる
>You can configure a conditional filter that only applies if there are any matching examples using config.filter_run_when_matching. This is commonly used for focus filtering:
```rb
  RSpec.configure do |c|
    c.filter_run_when_matching :focus # 一致したexampleがあれば条件付きフィルターを設定する
  end
```
この設定は`:fucus`メタデータでタグ付けすることによって明確にexampleかグループへフィルタリングすることを許可している。exampleやグループがフォーカスされていない時、(一時的変更であるため、通常であるべき）フィルターは無視されます

>This configuration allows you to filter to specific examples or groups by tagging them with :focus metadata. When no example or groups are focused (which should be the norm since it’s intended to be a temporary change), the filter will be ignored.

RSpecは`focus`メタデータ付きの`it`、`describe`そして`context`に対して`aliases–fit`、`fdescribe`そして`fcontext–as`を省略記法として提供し、fを接頭辞につけることによって一時的にexampleやグループに焦点を合わせることを簡単にさせる
>RSpec also provides `aliases–fit`, `fdescribe` and `fcontext–as` a shorthand for `it`, `discribe` and `context` with :focus metadata, making it easy to temporarily focus an example or group by prefixing an f.

>### Background
```rb
RSpec.configure do |c|
  c.filter_run_when_matching :focus
end
```
```rb
RSpec.describe "A group" do
  it "has a passing example" do
  end

  context "a nested group" do
    it "also has a passing example" do
    end
  end
end
```
焦点を当てるものがない場合、フィルターは無視される
>### The filter is ignored when nothing is focused
```
A group
  has a passing example
  a nested group
    also has a passing example

Finished in 0.05056 seconds (files took 2.67 seconds to load)
2 examples, 0 failures
```
exampleは`fit`で焦点を当てることができる
>### Examples can be focused with fit
```rb
RSpec.describe "A group" do
  fit "has a passing example" do # 
  end

  context "a nested group" do
    it "also has a passing example" do
    end
  end
end
```
```
Run options: include {:focus=>true}

A group
  has a passing example

Finished in 0.02903 seconds (files took 2.19 seconds to load)
1 example, 0 failures
```
#### 試しに`:focus`で明示した
```rb
RSpec.describe "A group" do
  it "has a passing example", :focus do
  end

  context "a nested group" do
    it "also has a passing example" do
    end
  end
end
```
```
Run options: include {:focus=>true}

A group
  has a passing example

Finished in 0.03359 seconds (files took 1.39 seconds to load)
1 example, 0 failures
```
グループは`fdescribe`または`fcontext`で焦点を当てる
>### Groups can be focused with fdescribe or fcontext
#### `fdescribe`
```rb
RSpec.fdescribe "A group" do
  it "has a passing example" do
  end

  context "a nested group" do
    it "also has a passing example" do
    end
  end
end
```
```
Run options: include {:focus=>true}

A group
  has a passing example
  a nested group
    also has a passing example

Finished in 0.03242 seconds (files took 2.21 seconds to load)
2 examples, 0 failures
```
#### `fcontext`
```rb
RSpec.describe "A group" do
  it "has a passing example" do
  end

  fcontext "a nested group" do
    it "also has a passing example" do
    end
  end
end
```
```
Run options: include {:focus=>true}

A group
  a nested group
    also has a passing example

Finished in 0.03307 seconds (files took 2.38 seconds to load)
1 example, 0 failures
```
https://rspec.info/features/3-13/rspec-core/filtering/filter-run-when-matching/