Skip to content

Instantly share code, notes, and snippets.

@seak0503
Created August 17, 2016 22:27
Show Gist options
  • Save seak0503/6cca2d006a7ed28fa806f9ba098409d5 to your computer and use it in GitHub Desktop.
Save seak0503/6cca2d006a7ed28fa806f9ba098409d5 to your computer and use it in GitHub Desktop.
rspecで特定のタグが付いたエグザンプルのみを実行する方法
  • 構文

下記のテストで、:exceptionシンボルをつけたテストのみを実行する

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は追加できない', :exception do
12        s = "ABC"
13        expect { s << nil }.to raise_error(TypeError)
14      end
15    end
16  end
bin/rspec spec --tag=exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment