Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to rspec3 #204

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ rvm:
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.2
notifications:
email:
- [email protected]
Expand All @@ -13,7 +14,9 @@ env:
- PUPPET_VERSION=3.1.1
- PUPPET_VERSION=3.2.4
- PUPPET_VERSION=3.3.2
- PUPPET_VERSION=3.4.1
- PUPPET_VERSION=3.4.3
- PUPPET_VERSION=3.5.1
- PUPPET_VERSION=3.6.1
matrix:
exclude:
- rvm: 1.9.2
Expand All @@ -28,3 +31,17 @@ matrix:
env: PUPPET_VERSION=3.0.2
- rvm: 2.0.0
env: PUPPET_VERSION=3.1.1
- rvm: 2.1.2
env: PUPPET_VERSION=2.6.18
- rvm: 2.1.2
env: PUPPET_VERSION=2.7.23
- rvm: 2.1.2
env: PUPPET_VERSION=3.0.2
- rvm: 2.1.2
env: PUPPET_VERSION=3.1.1
- rvm: 2.1.2
env: PUPPET_VERSION=3.2.4
- rvm: 2.1.2
env: PUPPET_VERSION=3.3.2
- rvm: 2.1.2
env: PUPPET_VERSION=3.4.3
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
rspecversion = ENV.key?('RSPEC_VERSION') ? "= #{ENV['RSPEC_VERSION']}" : ['>= 2.9 ', '< 3.0.0']
rspecversion = ENV.key?('RSPEC_VERSION') ? "= #{ENV['RSPEC_VERSION']}" : ['>= 3.0']

gem 'rake'
gem 'rspec', rspecversion
Expand Down
8 changes: 4 additions & 4 deletions lib/rspec-puppet/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ def c.escaped_path(*parts)
Regexp.compile(parts.join('[\\\/]'))
end

c.include RSpec::Puppet::DefineExampleGroup, :type => :define, :example_group => {
c.include RSpec::Puppet::DefineExampleGroup, { :type => :define,
:file_path => c.escaped_path(%w[spec defines])
}

c.include RSpec::Puppet::ClassExampleGroup, :type => :class, :example_group => {
c.include RSpec::Puppet::ClassExampleGroup, { :type => :class,
:file_path => c.escaped_path(%w[spec classes])
}

c.include RSpec::Puppet::FunctionExampleGroup, :type => :puppet_function, :example_group => {
c.include RSpec::Puppet::FunctionExampleGroup, { :type => :puppet_function,
:file_path => c.escaped_path(%w[spec functions])
}

c.include RSpec::Puppet::HostExampleGroup, :type => :host, :example_group => {
c.include RSpec::Puppet::HostExampleGroup, { :type => :host,
:file_path => c.escaped_path(%w[spec hosts])
}
end
4 changes: 2 additions & 2 deletions lib/rspec-puppet/matchers/compile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def description
end
end

def failure_message_for_should
def failure_message
unless @cycles.empty?
"dependency cycles found: #{@cycles.join('; ')}"
else
Expand All @@ -63,7 +63,7 @@ def failure_message_for_should
end
end

def failure_message_for_should_not
def failure_message_when_negated
"expected that the catalogue would not compile but it does"
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rspec-puppet/matchers/count_generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def description
desc.join(" ")
end

def failure_message_for_should
def failure_message
"expected that the catalogue would " + description + " but it contains #{@actual_number}"
end

def failure_message_for_should_not
def failure_message_when_negated
"expected that the catalogue would not " + description + " but it does"
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rspec-puppet/matchers/create_generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def matches?(catalogue)
end
end

def failure_message_for_should
def failure_message
"expected that the catalogue would contain #{@referenced_type}[#{@title}]#{errors}"
end

def failure_message_for_should_not
def failure_message_when_negated
"expected that the catalogue would not contain #{@referenced_type}[#{@title}]#{errors}"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rspec-puppet/matchers/include_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module ManifestMatchers
"include Class[#{expected_class}]"
end

failure_message_for_should do |actual|
failure_message do |actual|
"expected that the catalogue would include Class[#{expected_class}]"
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rspec-puppet/matchers/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ def and_raise_error(error_or_message, message=nil)
self
end

def failure_message_for_should
def failure_message
failure_message_generic(:should, @func_obj)
end

def failure_message_for_should_not
def failure_message_when_negated
failure_message_generic(:should_not, @func_obj)
end

Expand Down
8 changes: 4 additions & 4 deletions spec/classes/array_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end

it {
should contain_structured_data__def('thing').with(
is_expected.to contain_structured_data__def('thing').with(
{ 'data' => ['foo', 'bar', 'baz', 'quux'] }
)
}
Expand All @@ -19,7 +19,7 @@
end

it {
should contain_structured_data__def('thing').with(
is_expected.to contain_structured_data__def('thing').with(
{ 'data' => ['first', 1, 'second', 2] }
)
}
Expand All @@ -42,7 +42,7 @@
# we're still handling numeric values correctly.
describe 'on Puppet 2.6', :if => Puppet.version =~ /^2\.6/ do
it {
should contain_structured_data__def('thing').with(
is_expected.to contain_structured_data__def('thing').with(
{ 'data' => [
'first',
'second',
Expand All @@ -58,7 +58,7 @@

describe 'on Puppet 2.7 and later', :unless => Puppet.version =~ /^2\.6/ do
it {
should contain_structured_data__def('thing').with(
is_expected.to contain_structured_data__def('thing').with(
{ 'data' => [
'first',
'second',
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/boolean_regexp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
let(:params) { { :bool => false } }
let(:message_re) { /bool is false/ }

it { should create_notify("bool testing").with_message(message_re) }
it { is_expected.to create_notify("bool testing").with_message(message_re) }

# `should_not with_messsage` == `should without_message`
it { should_not create_notify("bool testing").with_message(/true/) }
it { should create_notify("bool testing").without_message(/true/) }
it { is_expected.not_to create_notify("bool testing").with_message(/true/) }
it { is_expected.to create_notify("bool testing").without_message(/true/) }
end
2 changes: 1 addition & 1 deletion spec/classes/boolean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:title) { 'bool.testing' }
let(:params) { { :bool => false } }

it { should create_notify("bool testing")\
it { is_expected.to create_notify("bool testing")\
.with_message("This will print when \$bool is false.") }
end
end
2 changes: 1 addition & 1 deletion spec/classes/cycle_bad_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'spec_helper'

describe 'cycle::bad' do
it { should_not compile }
it { is_expected.not_to compile }
end
2 changes: 1 addition & 1 deletion spec/classes/cycle_good_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'spec_helper'

describe 'cycle::good' do
it { should compile }
it { is_expected.to compile }
end
2 changes: 1 addition & 1 deletion spec/classes/escape_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
describe 'escape' do
let(:params) { { :content => '$MSG foo' } }

it { should contain_file('/tmp/escape').with_content(/\$MSG foo/) }
it { is_expected.to contain_file('/tmp/escape').with_content(/\$MSG foo/) }
end
8 changes: 4 additions & 4 deletions spec/classes/hash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end

it {
should contain_structured_data__def('thing').with(
is_expected.to contain_structured_data__def('thing').with(
{'data' => {'foo' => 'bar', 'baz' => 'quux'}}
)
}
Expand All @@ -19,7 +19,7 @@
end

it {
should contain_structured_data__def('thing').with(
is_expected.to contain_structured_data__def('thing').with(
{ 'data' => {1 => 'uno', 2 => 'dos'}}
)
}
Expand All @@ -31,7 +31,7 @@
end

it {
should contain_structured_data__def('thing').with(
is_expected.to contain_structured_data__def('thing').with(
{ 'data' => {'first' => 1, 'second' => 2}}
)
}
Expand All @@ -51,7 +51,7 @@
end

it {
should contain_structured_data__def('thing').with(
is_expected.to contain_structured_data__def('thing').with(
{ 'data' => {
'first' => 1,
'second' => 2,
Expand Down
20 changes: 10 additions & 10 deletions spec/classes/relationship__before_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
require 'spec_helper'

describe 'relationships::before' do
it { should contain_notify('foo').that_comes_before('Notify[bar]') }
it { should contain_notify('foo').that_comes_before('Notify[baz]') }
it { should contain_notify('bar').that_comes_before('Notify[baz]') }
it { is_expected.to contain_notify('foo').that_comes_before('Notify[bar]') }
it { is_expected.to contain_notify('foo').that_comes_before('Notify[baz]') }
it { is_expected.to contain_notify('bar').that_comes_before('Notify[baz]') }

it { should contain_notify('bar').that_requires('Notify[foo]') }
it { should contain_notify('baz').that_requires('Notify[foo]') }
it { should contain_notify('baz').that_requires('Notify[bar]') }
it { is_expected.to contain_notify('bar').that_requires('Notify[foo]') }
it { is_expected.to contain_notify('baz').that_requires('Notify[foo]') }
it { is_expected.to contain_notify('baz').that_requires('Notify[bar]') }

it { should contain_notify('foo').that_comes_before(['Notify[bar]','Notify[baz]']) }
it { should contain_notify('bar').that_comes_before(['Notify[baz]']) }
it { is_expected.to contain_notify('foo').that_comes_before(['Notify[bar]','Notify[baz]']) }
it { is_expected.to contain_notify('bar').that_comes_before(['Notify[baz]']) }

it { should contain_notify('bar').that_requires(['Notify[foo]']) }
it { should contain_notify('baz').that_requires(['Notify[foo]','Notify[bar]']) }
it { is_expected.to contain_notify('bar').that_requires(['Notify[foo]']) }
it { is_expected.to contain_notify('baz').that_requires(['Notify[foo]','Notify[bar]']) }
end
20 changes: 10 additions & 10 deletions spec/classes/relationship__notify_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
require 'spec_helper'

describe 'relationships::notify' do
it { should contain_notify('foo').that_notifies('Notify[bar]') }
it { should contain_notify('baz').that_notifies('Notify[bar]') }
it { should contain_notify('baz').that_notifies('Notify[gronk]') }
it { is_expected.to contain_notify('foo').that_notifies('Notify[bar]') }
it { is_expected.to contain_notify('baz').that_notifies('Notify[bar]') }
it { is_expected.to contain_notify('baz').that_notifies('Notify[gronk]') }

it { should contain_notify('gronk').that_subscribes_to('Notify[baz]') }
it { should contain_notify('bar').that_subscribes_to('Notify[baz]') }
it { should contain_notify('bar').that_subscribes_to('Notify[foo]') }
it { is_expected.to contain_notify('gronk').that_subscribes_to('Notify[baz]') }
it { is_expected.to contain_notify('bar').that_subscribes_to('Notify[baz]') }
it { is_expected.to contain_notify('bar').that_subscribes_to('Notify[foo]') }

it { should contain_notify('foo').that_notifies(['Notify[bar]']) }
it { should contain_notify('baz').that_notifies(['Notify[bar]','Notify[gronk]']) }
it { is_expected.to contain_notify('foo').that_notifies(['Notify[bar]']) }
it { is_expected.to contain_notify('baz').that_notifies(['Notify[bar]','Notify[gronk]']) }

it { should contain_notify('gronk').that_subscribes_to(['Notify[baz]']) }
it { should contain_notify('bar').that_subscribes_to(['Notify[baz]','Notify[foo]']) }
it { is_expected.to contain_notify('gronk').that_subscribes_to(['Notify[baz]']) }
it { is_expected.to contain_notify('bar').that_subscribes_to(['Notify[baz]','Notify[foo]']) }
end
Loading