Skip to content

Commit

Permalink
Use shared_examples
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiIto committed Jul 19, 2014
1 parent fb0a27e commit 31c6476
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions message_filter_spec.rb
@@ -1,14 +1,17 @@
require_relative 'message_filter'

shared_examples 'MessageFilter with argument "foo"' do
it { is_expected.to be_detect('hello from foo') }
it { is_expected.not_to be_detect('hello, world!') }
end

describe MessageFilter, 'with argument "foo"' do
subject { MessageFilter.new('foo') }
it { is_expected.to be_detect('hello from foo') }
it { is_expected.not_to be_detect('hello, world') }
it_behaves_like 'MessageFilter with argument "foo"'
end

describe MessageFilter, 'with argument "foo","bar"' do
subject { MessageFilter.new('foo', 'bar') }
it { is_expected.to be_detect('hello from bar') }
it { is_expected.to be_detect('hello from foo') }
it { is_expected.not_to be_detect('hello, world!') }
it_behaves_like 'MessageFilter with argument "foo"'
end

0 comments on commit 31c6476

Please sign in to comment.