Skip to content

Commit

Permalink
code deduplication
Browse files Browse the repository at this point in the history
move the rspec2 catcher to support.rb
  • Loading branch information
Martin Alfke committed Sep 25, 2014
1 parent dd8273d commit fe0b344
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 24 deletions.
6 changes: 0 additions & 6 deletions lib/rspec-puppet/matchers/compile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ def failure_message_when_negated
"expected that the catalogue would not compile but it does"
end

if RSpec::Version::STRING < '3'
# RSpec 2 compatibility:
alias_method :failure_message_for_should, :failure_message
alias_method :failure_message_for_should_not, :failure_message_when_negated
end

private
def missing_dependencies?
retval = false
Expand Down
6 changes: 0 additions & 6 deletions lib/rspec-puppet/matchers/count_generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ def failure_message_when_negated
"expected that the catalogue would not " + description + " but it does"
end

if RSpec::Version::STRING < '3'
# RSpec 2 compatibility:
alias_method :failure_message_for_should, :failure_message
alias_method :failure_message_for_should_not, :failure_message_when_negated
end

private

def referenced_type(type)
Expand Down
6 changes: 0 additions & 6 deletions lib/rspec-puppet/matchers/create_generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ def failure_message_when_negated
"expected that the catalogue would not contain #{@referenced_type}[#{@title}]#{errors}"
end

if RSpec::Version::STRING < '3'
# RSpec 2 compatibility:
alias_method :failure_message_for_should, :failure_message
alias_method :failure_message_for_should_not, :failure_message_when_negated
end

def description
values = []
value_str_prefix = "with"
Expand Down
6 changes: 0 additions & 6 deletions lib/rspec-puppet/matchers/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ def failure_message_when_negated
failure_message_generic(:should_not, @func_obj)
end

if RSpec::Version::STRING < '3'
# RSpec 2 compatibility:
alias_method :failure_message_for_should, :failure_message
alias_method :failure_message_for_should_not, :failure_message_when_negated
end

def description
"run #{func_name}(#{func_params}) and #{@desc}"
end
Expand Down
8 changes: 8 additions & 0 deletions lib/rspec-puppet/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,13 @@ def build_node(name, opts = {})
opts.merge!({:environment => node_environment})
Puppet::Node.new(name, opts)
end

def rspec_compatibility
if RSpec::Version::STRING < '3'
# RSpec 2 compatibility:
alias_method :failure_message_for_should, :failure_message
alias_method :failure_message_for_should_not, :failure_message_when_negated
end
end
end
end

0 comments on commit fe0b344

Please sign in to comment.