Skip to content

Instantly share code, notes, and snippets.

@seak0503
Created August 17, 2016 22:23
Show Gist options
  • Save seak0503/8a2201b2eff9c566d2ac7759e60c1e95 to your computer and use it in GitHub Desktop.
Save seak0503/8a2201b2eff9c566d2ac7759e60c1e95 to your computer and use it in GitHub Desktop.
rspecで特定の行のエグザンプルのみを実行する方法
  • 構文
bin/rspec file_path:line number

下記specの11行目のみをテストする場合

1  require 'rails_helper'
2  
3  describe String do
4    describe '#<<' do
5      example '文字の追加' do
6        s = "ABC"
7        s << "D"
8        expect(s.size).to eq(4)
9      end
10  
11      example 'nilは追加できない' do
12        s = "ABC"
13        expect { s << nil }.to raise_error(TypeError)
14      end
15    end
16  end
bin/rspec spec/experiments/string_spec.rb:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment