File: spec_helper_unit.rb

package info (click to toggle)
ruby-rspec-puppet 2.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,416 kB
  • sloc: ruby: 6,661; makefile: 6
file content (49 lines) | stat: -rw-r--r-- 819 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
if ENV['COVERAGE']
  require 'coveralls'
  require 'simplecov'

  if ENV['COVERAGE'] == 'yes'
    SimpleCov.formatter = Coveralls::SimpleCov::Formatter
  end

  SimpleCov.start do
    add_filter %r{^/spec/}
    add_filter %r{^/vendor/}
  end
end

require 'rspec-puppet'

module Helpers
  def rspec2?
    RSpec::Version::STRING < '3'
  end
  module_function :rspec2?

  def test_double(type, *args)
    if rspec2?
      double(type.to_s, *args)
    else
      instance_double(type, *args)
    end
  end
end

RSpec.configure do |c|
  c.include Helpers
  c.extend Helpers

  if Helpers.rspec2?
    RSpec::Matchers.define :be_truthy do
      match do |actual|
        !!actual == true
      end
    end

    RSpec::Matchers.define :be_falsey do
      match do |actual|
        !!actual == false
      end
    end
  end
end