exampleにpendingを使う
Using pending with examples
Rspecはexampleがいくつかのアクションを保留のままにすることを指摘するためのありとあらゆる方法を差し出す
RSpec offers a number of different ways to indicate that an example is disabled pending some action.
失敗でいくつかの恣意的な理由を保留にする
pending any arbitrary reason with a failing example
Given a file named “pendingwithoutblock_spec.rb” with:
RSpec.describe "an example" do
it "is implemented but waiting" do
pending("something else getting finished")
fail
end
end
Pending: something else getting finished
1 example, 0 failures, 0 passed, 1 pending
- 失敗を保留されている
When I run rspec pending_without_block_spec.rb
Then the exit status should be 0
And the output should contain “1 example, 0 failures, 1 pending”
And the output should contain:
>Pending: (Failures listed here are expected and do not affect your suite's status)
>1) an example is implemented but waiting
# something else getting finished
pendingは通っているexampleで恣意的な理由を保留する
pending any arbitrary reason with a passing example
Given a file named “pendingwithpassingexamplespec.rb” with:
RSpec.describe "an example" do
it "is implemented but waiting" do
pending("something else getting finished")
expect(1).to be(1)
end
end
Expected example to fail since it is pending, but it passed.
0) an example is implemented but waiting FIXED
Expected pending 'something else getting finished' to fail. No error was raised.
# ./spec/models/user_spec.rb:15
1 example, 1 failure, 0 passed
When I run rspec pending_with_passing_example_spec.rb
Then the exit status should not be 0
And the output should contain “1 example, 1 failure”
And the output should contain “FIXED”
And the output should contain “Expected pending ‘something else getting finished’ to fail. No error was raised.”
And the output should contain “pendingwithpassingexamplespec.rb:2”.
現在通ったexampleのためのpending
pending for an example that is currently passing
Given a file named “pendingwithpassingblockspec.rb” with:
RSpec.describe "an example" do
pending("something else getting finished") do
expect(1).to eq(1)
end
end
Expected example to fail since it is pending, but it passed.
0) an example something else getting finished FIXED
Expected pending 'No reason given' to fail. No error was raised.
# ./spec/models/user_spec.rb:15
1 example, 1 failure, 0 passed
When I run rspec pending_with_passing_block_spec.rb
Then the exit status should not be 0
And the output should contain “1 example, 1 failure”
And the output should contain “FIXED”
And the output should contain “Expected pending ‘No reason given’ to fail. No error was raised.”
And the output should contain “pendingwithpassingblockspec.rb:2”.
理由付きで現在通っている例のためのpending
pending for an example that is currently passing with a reason
Given a file named “pendingwithpassingblockspec.rb” with:
RSpec.describe "an example" do
example("something else getting finished", :pending => 'unimplemented') do
expect(1).to eq(1)
end
end
Expected example to fail since it is pending, but it passed.
0) an example something else getting finished FIXED
Expected pending 'unimplemented' to fail. No error was raised.
# ./spec/models/user_spec.rb:16
1 example, 1 failure, 0 passed
When I run rspec pending_with_passing_block_spec.rb
Then the exit status should not be 0
And the output should contain “1 example, 1 failure”
And the output should contain “FIXED”
And the output should contain “Expected pending ‘unimplemented’ to fail. No error was raised.”
And the output should contain “pendingwithpassingblockspec.rb:2”.
感想
テストに通っているとpendingにより失敗する
RSpec.describe "an example" do
it "is implemented but waiting" do
pending("something else getting finished")
expect(1).to be(1)
end
end
RSpec.describe "an example" do
pending("something else getting finished") do
expect(1).to eq(1)
end
end
RSpec.describe "an example" do
example("something else getting finished", :pending => 'unimplemented') do
expect(1).to eq(1)
end
end
こういうふうにいろんな形がある
この違いを理解していない。
どうしても通らないときに使おう