From: Yanis Guenane Date: Thu, 15 May 2014 18:40:46 +0000 (-0400) Subject: Implement rspec function it_raises X-Git-Tag: 5.0.0~26 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=9ec5122f6d9c1168f9edb077b629d0722ee6c86c;p=puppet-modules%2Fpuppet-ceilometer.git 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 --- diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb new file mode 100644 index 0000000..d92156a --- /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 e17ce17..53d4dd0 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