From 9ec5122f6d9c1168f9edb077b629d0722ee6c86c Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Thu, 15 May 2014 14:40:46 -0400 Subject: [PATCH] Implement rspec function it_raises On some puppet modules, a it_raises helper is provided. This commit implements it for puppet-ceilometer. Change-Id: Ie1c83e09952fed1f114fc07d9944f89e94c413f1 --- spec/shared_examples.rb | 5 +++++ spec/spec_helper.rb | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 spec/shared_examples.rb diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb new file mode 100644 index 000000000..d92156a36 --- /dev/null +++ b/spec/shared_examples.rb @@ -0,0 +1,5 @@ +shared_examples_for "a Puppet::Error" do |description| + it "with message matching #{description.inspect}" do + expect { should have_class_count(1) }.to raise_error(Puppet::Error, description) + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e17ce17d6..53d4dd02d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,7 @@ require 'puppetlabs_spec_helper/module_spec_helper' +require 'shared_examples' RSpec.configure do |c| c.alias_it_should_behave_like_to :it_configures, 'configures' + c.alias_it_should_behave_like_to :it_raises, 'raises' end