1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RSpecのテストを一旦コメントアウトしたいときは、xをつけてpendingにしよう

Last updated at Posted at 2019-07-03

コメントアウトすると、RSpecの実行結果からコメントアウトしていることに気づけない

pasta_spec.rb
describe Pasta, type: :model do
  describe '#boil' do

    context '14mm' do
      # it { expect(Pasta.new(size: 14).boil(min: 8)).to eq TASTE::NICE }
    end
    context '18mm' do
      # it { expect(Pasta.new(size: 18).boil(min: 8)).to eq TASTE::SOLID }
    end
  end

  # ..略(このあと、47個のテストがある)..
end
RSpec
$docker-compose exec web bundle exec rspec spec/models/pasta_spec.rb
...............................................

Finished in 1.55 seconds (files took 3.7 seconds to load)
47 examples, 0 failures

itにxをつけて、xitとすると、実行結果に明示的にpendingと出る

pasta_spec.rb
describe Pasta, type: :model do
  describe '#boil' do

    context '14mm' do
      xit { expect(Pasta.new(size: 14).boil(min: 8)).to eq TASTE::NICE }
    end
    context '18mm' do
      xit { expect(Pasta.new(size: 18).boil(min: 8)).to eq TASTE::SOLID }
    end
  end

  # ..略(このあと、47個のテストがある)..
end
RSpec
$docker-compose exec web bundle exec rspec spec/models/pasta_spec.rb
..**.............................................

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Pasta #boil 14mm 8 min should eq nice
     # Temporarily skipped with xit
     # ./spec/models/pasta_spec.rb:19

  2) Pasta #boil 18mm 8 min should eq かたい
     # Temporarily skipped with xit
     # ./spec/models/pasta_spec.rb:24


49 examples, 0 failures, 2 pending
1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?