Module: Bones::Rspec::RspecVersion2

Extended by:
RspecVersion2
Includes:
Helpers
Included in:
RspecVersion2
Defined in:
lib/bones/rspec/rspec_version2.rb

Instance Method Summary collapse

Instance Method Details

#define_tasksObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/bones/rspec/rspec_version2.rb', line 43

def define_tasks
  config = ::Bones.config

  namespace :spec do
    desc 'Run all specs with basic output'
    ::RSpec::Core::RakeTask.new(:run) do |t|
      t.ruby_opts = config.ruby_opts
      t.rspec_opts = config.spec.opts unless config.spec.opts.empty?
      t.pattern = config.spec.files
    end

    if have? :rcov
      desc 'Run all specs with Rcov'
      ::RSpec::Core::RakeTask.new(:rcov) do |t|
        t.ruby_opts = config.ruby_opts
        t.rspec_opts = config.spec.opts unless config.spec.opts.empty?
        t.pattern = config.spec.files

        t.rcov = true
        t.rcov_path = config.rcov.path

        rcov_opts = []
        rcov_opts.concat config.rcov.opts
        rcov_opts << '--output' << config.rcov.dir if config.rcov.dir

        t.rcov_opts = rcov_opts
      end

      task :clobber_rcov do
        rm_r config.rcov.dir rescue nil
      end
    end
  end  # namespace :spec

  desc 'Alias to spec:run'
  task :spec => 'spec:run'

  task :clobber => 'spec:clobber_rcov' if have? :rcov
end

#initialize_rspecObject



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
# File 'lib/bones/rspec/rspec_version2.rb', line 8

def initialize_rspec
  require 'rspec/core/rake_task'

  ::Bones.config {
    desc 'Configuration settings for the RSpec test framework.'
    spec {
      files  'spec/**/*_spec.rb', :desc => <<-__
        Glob pattern used to match spec files to run. This defaults to all
        the ruby fines in the 'spec' directory that end with '_spec.rb' as
        their filename.
      __

      opts [], :desc => <<-__
        An array of command line options that will be passed to the rspec
        command when running your tests. See the RSpec help documentation
        either online or from the command line by running 'spec --help'.

        Options can also be defined in the "spec/spec.opts" file. Please
        leave this opts array empty if you prefer to use the spec.opts file
        instead. However, both can be used in conjunction; watch out for
        options colliions.
      __
    }
  }
  return true

rescue LoadError
  return false
end

#post_loadObject



38
39
40
41
# File 'lib/bones/rspec/rspec_version2.rb', line 38

def post_load
  config = ::Bones.config
  have?(:rspec) { !FileList[config.spec.files].to_a.empty?  }
end