:ifと:unlessでもフィルターできる

条件付きフィルター
># Conditional Filters
`:if`と`:unless`メタデータキーは除外するフィルターを設定する必要なしでexampleをフィルタリングを使用することができる
>The :if and :unless metadata keys can be used to filter examples without needing to configure an exclusion filter.

暗黙の`:if`フィルター
>### Implicit :if filter
```rb
RSpec.describe ":if => true group", :if => true do　# trueであれば実行される
  it(":if => true group :if => true example", :if => true) { }
  it(":if => true group :if => false example", :if => false) { }
  it(":if => true group no :if example") { }
end

RSpec.describe ":if => false group", :if => false do　# falseであれば実行される
  it(":if => false group :if => true example", :if => true) { }
  it(":if => false group :if => false example", :if => false) { }
  it(":if => false group no :if example") { }
end

RSpec.describe "no :if group" do # :ifメタデータがなければfalseだけ実行されない　メタデータに何も書かれていないとtrueとみなされるのかな
  it("no :if group :if => true example", :if => true) { }
  it("no :if group :if => false example", :if => false) { }
  it("no :if group no :if example") { }
end
```
```
:if => true group
  :if => true group :if => true example
  :if => true group no :if example

:if => false group
  :if => false group :if => true example

no :if group
  no :if group :if => true example
  no :if group no :if example

Finished in 0.07393 seconds (files took 2.65 seconds to load)
5 examples, 0 failures
```
暗黙的な`:unless`フィルター
>### Implicit :unless filter

```rb
RSpec.describe ":unless => true group", :unless => true do　 # trueでなければ実行される
  it(":unless => true group :unless => true example", :unless => true) { }
  it(":unless => true group :unless => false example", :unless => false) { }
  it(":unless => true group no :unless example") { }
end

RSpec.describe ":unless => false group", :unless => false do　# falseでなければ実行される
  it(":unless => false group :unless => true example", :unless => true) { }
  it(":unless => false group :unless => false example", :unless => false) { }
  it(":unless => false group no :unless example") { }
end

RSpec.describe "no :unless group" do # unlessだとfalseとメタデータなしが通る
  it("no :unless group :unless => true example", :unless => true) { }
  it("no :unless group :unless => false example", :unless => false) { }
  it("no :unless group no :unless example") { }
end
```
```
:unless => true group
  :unless => true group :unless => false example

:unless => false group
  :unless => false group :unless => false example
  :unless => false group no :unless example

no :unless group
  no :unless group :unless => false example
  no :unless group no :unless example

Finished in 0.0283 seconds (files took 1.31 seconds to load)
5 examples, 0 failures
```
明白なinclusionフィルターと暗黙的なフィルターを結合する
>### Combining implicit filter with explicit inclusion filter

```rb
RSpec.configure do |c|
  c.filter_run :focus => true # 
end

RSpec.describe "group with :focus", :focus => true do　# 多分省略されているがif=>trueがある
  it("focused example") { }
  it("focused :if => true example", :if => true) { } # fucusがtrueならば実行
  it("focused :if => false example", :if => false) { }　# focusがfalseならば実行
  it("focused :unless => true example", :unless => true) { }
  it("focused :unless => false example", :unless => false) { }
end

RSpec.describe "group without :focus" do  # メタデータで指定されていないので作動しない
  it("unfocused example") { }
  it("unfocused :if => true example", :if => true) { }
  it("unfocused :if => false example", :if => false) { }
  it("unfocused :unless => true example", :unless => true) { }
  it("unfocused :unless => false example", :unless => false) { }
end
```
```
Run options: include {:focus=>true}

group with :focus
  focused example
  focused :if => true example
  focused :unless => false example

Finished in 0.03204 seconds (files took 2.32 seconds to load)
3 examples, 0 failures
```
明白な除外フィルターと暗黙的なフィルターを結合する
>### Combining implicit filter with explicit exclusion filter
```rb
RSpec.configure do |c|
  c.filter_run_excluding :broken => true
end

RSpec.describe "unbroken group" do　# このグループのtrueだけが実行されている
  it("included example") { }
  it("included :if => true example", :if => true) { }
  it("included :if => false example", :if => false) { }
  it("included :unless => true example", :unless => true) { }
  it("included :unless => false example", :unless => false) { }
end

RSpec.describe "broken group", :broken => true do
  it("excluded example") { }
  it("excluded :if => true example", :if => true) { }
  it("excluded :if => false example", :if => false) { }
  it("excluded :unless => true example", :unless => true) { }
  it("excluded :unless => false example", :unless => false) { }
end
```
明示的にinclusionsがある時`:if`と`:unless`の除外が有効のままです
>### The :if and :unless exclusions stay in effect when there are explicit inclusions
```rb
RSpec.describe "Using inclusions" do
  context "inclusion target" do
    it "is filtered out by :if", :if => false do
    end

    it 'is filtered out by :unless', :unless => true do
    end

    it 'is still run according to :if', :if => true do
    end

    it 'is still run according to :unless', :unless => false do
    end
  end
end
```
```
Using inclusions
  inclusion target
    is still run according to :if
    is still run according to :unless

Finished in 0.03923 seconds (files took 2.37 seconds to load)
2 examples, 0 failures
```