File: example.rb

package info (click to toggle)
ruby-ammeter 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 312 kB
  • sloc: ruby: 703; makefile: 4
file content (28 lines) | stat: -rw-r--r-- 1,008 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
require 'rspec/core'
require 'ammeter/rspec/generator/example/generator_example_group'
require 'ammeter/rspec/generator/example/generator_example_helpers'

RSpec::configure do |c|
  def c.escaped_path(*parts)
    Regexp.compile(parts.join('[\\\/]') + '[\\\/]')
  end

  generator_path_regex = c.escaped_path(%w[spec generators])
  if RSpec::Core::Version::STRING >= '3'
    c.include Ammeter::RSpec::Rails::GeneratorExampleHelpers,
      :type          => :generator
    c.include Ammeter::RSpec::Rails::GeneratorExampleGroup,
      :type          => :generator
    c.include Ammeter::RSpec::Rails::GeneratorExampleGroup,
      :file_path     => lambda { |file_path, metadata|
        metadata[:type].nil? && generator_path_regex =~ file_path
      }

  else #rspec2
    c.include Ammeter::RSpec::Rails::GeneratorExampleHelpers, :type => :generator
    c.include Ammeter::RSpec::Rails::GeneratorExampleGroup, :type => :generator, :example_group => {
      :file_path => generator_path_regex
    }
  end

end