brynary / rspec forked from dchelimsky/rspec

Behaviour Driven Development framework for Ruby

This URL has Read+Write access

rspec / Rakefile
100644 146 lines (121 sloc) 4.17 kb
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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# -*- ruby -*-
gem 'hoe', '>=2.0.0'
require 'hoe'
 
$:.unshift 'lib'
 
require 'spec/version'
require 'spec/rake/spectask'
require 'spec/ruby'
require 'cucumber/rake/task'
 
Hoe.spec 'rspec' do
  self.version = Spec::VERSION::STRING
  self.summary = Spec::VERSION::SUMMARY
  self.description = "Behaviour Driven Development for Ruby."
  self.rubyforge_name = 'rspec'
  self.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
  self.extra_dev_deps << ["cucumber",">=0.3"] << ["bmabey-fakefs",">=0.1.1"] << ["syntax",">=1.0"] << ["diff-lcs",">=1.1.2"]
  self.extra_dev_deps << ["heckle",">=1.4.3"] unless Spec::Ruby.version >= "1.9"
  self.remote_rdoc_dir = "rspec/#{Spec::VERSION::STRING}"
  self.rspec_options = ['--options', 'spec/spec.opts']
  self.history_file = 'History.rdoc'
  self.readme_file = 'README.rdoc'
  self.post_install_message = <<-POST_INSTALL_MESSAGE
#{'*'*50}
 
Thank you for installing rspec-#{Spec::VERSION::STRING}
 
Please be sure to read History.rdoc and Upgrade.rdoc
for useful information about this release.
 
#{'*'*50}
POST_INSTALL_MESSAGE
end
 
['audit','test','test_deps','default','post_blog'].each do |task|
  Rake.application.instance_variable_get('@tasks').delete(task)
end
 
task :post_blog do
  # no-op
end
 
# Some of the tasks are in separate files since they are also part of the website documentation
load 'resources/rake/examples.rake'
load 'resources/rake/examples_with_rcov.rake'
load 'resources/rake/failing_examples_with_html.rake'
load 'resources/rake/verify_rcov.rake'
 
task :cleanup_rcov_files do
  rm_rf 'coverage.data'
end
 
 
if RUBY_VERSION =~ /^1.8/
  task :default => [:cleanup_rcov_files, :features, :verify_rcov]
else
  task :default => [:spec, :features]
end
 
namespace :spec do
 
  desc "Run all specs with rcov"
  Spec::Rake::SpecTask.new(:rcov) do |t|
    t.spec_files = FileList['spec/**/*_spec.rb']
    t.spec_opts = ['--options', 'spec/spec.opts']
    t.rcov = true
    t.rcov_dir = 'coverage'
    t.rcov_opts = ['--exclude', "features,kernel,load-diff-lcs\.rb,instance_exec\.rb,lib/spec.rb,lib/spec/runner.rb,^spec/*,bin/spec,examples,/gems,/Library/Ruby,\.autotest,#{ENV['GEM_HOME']}"]
    t.rcov_opts << '--sort coverage --text-summary --aggregate coverage.data'
  end
  
  desc "Run files listed in spec/spec_files.txt"
  Spec::Rake::SpecTask.new(:focus) do |t|
    if File.exists?('spec/spec_files.txt')
      t.spec_files = File.readlines('spec/spec_files.txt').collect{|f| f.chomp}
    end
  end
end
 
desc "Run Cucumber features"
if RUBY_VERSION =~ /^1.8/
  Cucumber::Rake::Task.new :features do |t|
    t.rcov = true
    t.rcov_opts = ['--exclude', "features,kernel,load-diff-lcs\.rb,instance_exec\.rb,lib/spec.rb,lib/spec/runner.rb,^spec/*,bin/spec,examples,/gems,/Library/Ruby,\.autotest,#{ENV['GEM_HOME']}"]
    t.rcov_opts << '--no-html --aggregate coverage.data'
    t.cucumber_opts = %w{--format progress}
  end
else
  task :features do
    sh 'cucumber --profile no_heckle'
  end
end
 
desc "Run failing examples (see failure output)"
Spec::Rake::SpecTask.new('failing_examples') do |t|
  t.spec_files = FileList['failing_examples/**/*_spec.rb']
  t.spec_opts = ['--options', 'spec/spec.opts']
end
 
def egrep(pattern)
  Dir['**/*.rb'].each do |fn|
    count = 0
    open(fn) do |f|
      while line = f.gets
        count += 1
        if line =~ pattern
          puts "#{fn}:#{count}:#{line}"
        end
      end
    end
  end
end
 
desc "Look for TODO and FIXME tags in the code"
task :todo do
  egrep /(FIXME|TODO|TBD)/
end
 
desc "verify_committed, verify_rcov, post_news, release"
task :complete_release => [:verify_committed, :verify_rcov, :post_news, :release]
 
desc "Verifies that there is no uncommitted code"
task :verify_committed do
  IO.popen('git status') do |io|
    io.each_line do |line|
      raise "\n!!! Do a git commit first !!!\n\n" if line =~ /^#\s*modified:/
    end
  end
end
 
namespace :update do
  desc "update the manifest"
  task :manifest do
    system %q[touch Manifest.txt; rake check_manifest | grep -v "(in " | patch]
  end
end
 
task :clobber => :clobber_tmp
 
task :clobber_tmp do
  cmd = %q[rm -r tmp]
  puts cmd
  system cmd if test ?d, 'tmp'
end