Author: boisvert
Date: Mon Oct 25 04:41:27 2010
New Revision: 1026943

URL: http://svn.apache.org/viewvc?rev=1026943&view=rev
Log:
BUILDR-540 Upgrade to rspec 2.0.0

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/Rakefile
    buildr/trunk/lib/buildr.rb
    buildr/trunk/lib/buildr/core/checks.rb
    buildr/trunk/rakelib/rspec.rake
    buildr/trunk/spec/core/build_spec.rb
    buildr/trunk/spec/core/compile_spec.rb
    buildr/trunk/spec/ide/eclipse_spec.rb
    buildr/trunk/spec/java/emma_spec.rb
    buildr/trunk/spec/java/packaging_spec.rb
    buildr/trunk/spec/java/test_coverage_helper.rb
    buildr/trunk/spec/packaging/archive_spec.rb
    buildr/trunk/spec/spec_helpers.rb

Modified: buildr/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Mon Oct 25 04:41:27 2010
@@ -3,6 +3,7 @@
           (via libnotify/notify-send)
 * Added:  BUILDR-537 Shell tasks should use JAVA_OPTS by default
 * Added:  BUILDR-538 Shell tasks should support passing :java_args
+* Change: BUILDR-540 Upgrade to rspec 2.0.0
 * Fixed:  BUILDR-542 Release task:  SVN tagging fails if parent tag directory
           does not exist yet (Gerolf Seitz)
 * Fixed:  BUILDR-543 POMs are installed and uploaded twice when using artifacts

Modified: buildr/trunk/Rakefile
URL: 
http://svn.apache.org/viewvc/buildr/trunk/Rakefile?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/Rakefile (original)
+++ buildr/trunk/Rakefile Mon Oct 25 04:41:27 2010
@@ -13,6 +13,7 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
+gem 'rspec', '2.0.0'
 
 # We need JAVA_HOME for most things (setup, spec, etc).
 unless ENV['JAVA_HOME']

Modified: buildr/trunk/lib/buildr.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/lib/buildr.rb (original)
+++ buildr/trunk/lib/buildr.rb Mon Oct 25 04:41:27 2010
@@ -32,6 +32,6 @@ class << self ; include Buildr ; end
 class Object #:nodoc:
   Buildr.constants.each do |name|
     const = Buildr.const_get(name)
-    const_set name, const if const.is_a?(Module)
+    const_set name, const if const.is_a?(Module) && name != "RSpec"
   end
 end

Modified: buildr/trunk/lib/buildr/core/checks.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/checks.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/checks.rb (original)
+++ buildr/trunk/lib/buildr/core/checks.rb Mon Oct 25 04:41:27 2010
@@ -15,8 +15,7 @@
 
 
 require 'buildr/core/project'
-autoload :Spec, 'spec'
-
+autoload :RSpec, 'rspec'
 
 module Buildr
   # Methods added to Project to allow checking the build.
@@ -120,7 +119,7 @@ module Buildr
           end
           define_method(:it) { subject }
           define_method(:description) { description }
-          include Spec::Matchers
+          include ::RSpec::Matchers
           include Matchers
         end
 
@@ -148,8 +147,8 @@ module Buildr
             passed
           rescue Exception=>ex
             if verbose
-              error ex.backtrace.select { |line| line =~ 
/#{Buildr.application.buildfile}/ }.join("\n")
               error ex
+              error ex.backtrace.select { |line| line =~ 
/#{Buildr.application.buildfile}/ }.join("\n")
             end
             false
           end

Modified: buildr/trunk/rakelib/rspec.rake
URL: 
http://svn.apache.org/viewvc/buildr/trunk/rakelib/rspec.rake?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/rakelib/rspec.rake (original)
+++ buildr/trunk/rakelib/rspec.rake Mon Oct 25 04:41:27 2010
@@ -13,9 +13,8 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
-
 begin
-  require 'spec/rake/spectask'
+  require 'rspec/core/rake_task'
   directory '_reports'
 
   def default_spec_opts
@@ -23,33 +22,44 @@ begin
     default << '--colour' if $stdout.isatty
     default
   end
-  
+
+  # RSpec doesn't support file exclusion, so hack our own.
+  class RSpec::Core::RakeTask
+    attr_accessor :rspec_files
+  private
+    def files_to_run
+      @rspec_files
+    end
+  end
+
   desc "Run all specs"
-  Spec::Rake::SpecTask.new :spec=>['_reports', :compile] do |task|
+  RSpec::Core::RakeTask.new :spec=>['_reports', :compile] do |task|
     ENV['USE_FSC'] = 'no'
-    task.spec_files = FileList['spec/**/*_spec.rb']
-    task.spec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
-    task.spec_opts = default_spec_opts
-    task.spec_opts << '--format specdoc'
+    task.rspec_files = FileList['spec/**/*_spec.rb']
+    task.rspec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
+    task.rspec_opts = default_spec_opts
+    task.rspec_opts << '--format documentation'
   end
   file('_reports/specs.html') { task(:spec).invoke }
 
   desc 'Run all failed examples from previous run'
-  Spec::Rake::SpecTask.new :failed do |task|
+  RSpec::Core::RakeTask.new :failed do |task|
     ENV['USE_FSC'] = 'no'
-    task.spec_files = FileList['spec/**/*_spec.rb']
-    task.spec_opts = default_spec_opts
-    task.spec_opts << '--format specdoc' << '--example failed'
+    task.rspec_files = FileList['spec/**/*_spec.rb']
+    task.rspec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
+    task.rspec_opts = default_spec_opts
+    task.rspec_opts << '--format documentation' << '--example failed'
   end
 
   desc 'Run RSpec and generate Spec and coverage reports (slow)'
-  Spec::Rake::SpecTask.new :coverage=>['_reports', :compile] do |task|
+  RSpec::Core::RakeTask.new :coverage=>['_reports', :compile] do |task|
     ENV['USE_FSC'] = 'no'
-    task.spec_files = FileList['spec/**/*_spec.rb']
-    task.spec_opts = default_spec_opts
-    task.spec_opts << '--format progress'
+    task.rspec_files = FileList['spec/**/*_spec.rb']
+    task.rspec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
+    task.rspec_opts = default_spec_opts
+    task.rspec_opts << '--format progress'
     task.rcov = true
-    task.rcov_dir = '_reports/coverage'
+    task.rcov_path = '_reports/coverage'
     task.rcov_opts = %w{--exclude / --include-file ^lib --text-summary}
   end
   file('_reports/coverage') { task(:coverage).invoke }
@@ -61,10 +71,10 @@ begin
     ci_rep_path = Gem.loaded_specs['ci_reporter'].full_gem_path
     ENV["SPEC_OPTS"] = [ENV["SPEC_OPTS"], default_spec_opts, "--require", 
"\"#{ci_rep_path}/lib/ci/reporter/rake/rspec_loader.rb\"", "--format", 
"CI::Reporter::RSpec"].join(" ")
   end
-  
+
   desc 'Run all specs with CI reporter'
-  task :ci=>[:load_ci_reporter, :spec] 
-  
+  task :ci=>[:load_ci_reporter, :spec]
+
   # Useful for testing with JRuby when using Ruby and vice versa.
   namespace :spec do
     desc "Run all specs specifically with Ruby"
@@ -85,7 +95,7 @@ begin
     rm_rf '_reports'
   end
 
-rescue LoadError
+rescue LoadError => e
   puts "Buildr uses RSpec. You can install it by running rake setup"
   task(:setup) { install_gem 'rcov', :version=>'~>0.8' }
   task(:setup) { install_gem 'win32console' if RUBY_PLATFORM[/win32/] } # 
Colors for RSpec, only on Windows platform.

Modified: buildr/trunk/spec/core/build_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/core/build_spec.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/spec/core/build_spec.rb (original)
+++ buildr/trunk/spec/core/build_spec.rb Mon Oct 25 04:41:27 2010
@@ -16,7 +16,7 @@
 
 require File.expand_path(File.join(File.dirname(__FILE__), '..', 
'spec_helpers'))
 
-describe 'local task', :shared=>true do
+shared_examples_for 'local task' do
   it "should execute task for project in current directory" do
     define 'foobar'
     lambda { @task.invoke }.should run_task("foobar:#[email protected]}")
@@ -369,7 +369,7 @@ describe Release do
 end
 
 
-describe 'a release process', :shared=>true do
+shared_examples_for 'a release process' do
 
   describe '#make' do
     before do
@@ -406,7 +406,7 @@ describe 'a release process', :shared=>t
       @release.make
       file('buildfile').should contain('VERSION_NUMBER = "1.0.002-SNAPSHOT"')
     end
-    
+
     it 'should commit the updated buildfile' do
       @release.stub!(:tag_release)
       @release.make
@@ -419,7 +419,7 @@ describe 'a release process', :shared=>t
       @release.make
       file('buildfile').should contain('VERSION_NUMBER = "1.0.0-rc1"')
     end
-    
+
     it 'should only commit the updated buildfile if the version changed' do
       write 'buildfile', "VERSION_NUMBER = '1.0.0-rc1'"
       @release.should_not_receive(:update_version_to_next)
@@ -465,7 +465,7 @@ describe 'a release process', :shared=>t
       Release.next_version = lambda {|version| "#{version}++"}
       @release.send(:resolve_next_version, "1.0.0").should == 
'ze_version_from_env_lowercase'
     end
-    after { 
+    after {
       Release.next_version = nil
       ENV['NEXT_VERSION'] = nil
       ENV['next_version'] = nil
@@ -509,7 +509,7 @@ describe 'a release process', :shared=>t
       Release.next_version = lambda {|version| "#{version}++"}
       @release.send(:resolve_next_version, "1.0.0").should == 
'ze_version_from_env_lowercase'
     end
-    after { 
+    after {
       Release.next_version = nil
       ENV['NEXT_VERSION'] = nil
       ENV['next_version'] = nil
@@ -553,7 +553,7 @@ describe 'a release process', :shared=>t
       Release.next_version = lambda {|version| "#{version}++"}
       @release.send(:resolve_next_version, "1.0.0").should == 
'ze_version_from_env_lowercase'
     end
-    after { 
+    after {
       Release.next_version = nil
       ENV['NEXT_VERSION'] = nil
       ENV['next_version'] = nil

Modified: buildr/trunk/spec/core/compile_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/core/compile_spec.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/spec/core/compile_spec.rb (original)
+++ buildr/trunk/spec/core/compile_spec.rb Mon Oct 25 04:41:27 2010
@@ -106,9 +106,9 @@ describe Buildr::CompileTask do
     write "src/main/java/com/example/Hello.java", ""
     old_compiler = nil
     new_compiler = nil
-    define('foo') { 
+    define('foo') {
       old_compiler = compile.compiler
-      compile.using(:scalac) 
+      compile.using(:scalac)
       new_compiler = compile.compiler
     }
     old_compiler.should == :javac
@@ -416,7 +416,7 @@ describe Buildr::CompileTask, '#invoke' 
 end
 
 
-describe 'accessor task', :shared=>true do
+shared_examples_for 'accessor task' do
   it 'should return a task' do
     define('foo').send(@task_name).should be_kind_of(Rake::Task)
   end

Modified: buildr/trunk/spec/ide/eclipse_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/ide/eclipse_spec.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/spec/ide/eclipse_spec.rb (original)
+++ buildr/trunk/spec/ide/eclipse_spec.rb Mon Oct 25 04:41:27 2010
@@ -382,7 +382,7 @@ MANIFEST
         write 'src/test/java/Test.java'
       end
 
-      describe 'source', :shared=>true do
+      shared_examples_for 'source' do
         it 'should ignore CVS and SVN files' do
           define('foo')
           classpath_sources('excluding').each do |excluding_attribute|

Modified: buildr/trunk/spec/java/emma_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/java/emma_spec.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/spec/java/emma_spec.rb (original)
+++ buildr/trunk/spec/java/emma_spec.rb Mon Oct 25 04:41:27 2010
@@ -20,6 +20,8 @@ artifacts(Buildr::Emma::dependencies).ma
 
 
 describe Buildr::Emma do
+  include TestCoverageHelper
+
   before do
     # Reloading the extension because the sandbox removes all its actions
     Buildr.module_eval { remove_const :Emma }

Modified: buildr/trunk/spec/java/packaging_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/java/packaging_spec.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/spec/java/packaging_spec.rb (original)
+++ buildr/trunk/spec/java/packaging_spec.rb Mon Oct 25 04:41:27 2010
@@ -346,7 +346,7 @@ describe Project, '#meta_inf' do
 end
 
 
-describe 'package with meta_inf', :shared=>true do
+shared_examples_for 'package with meta_inf' do
 
   def package_with_meta_inf(meta_inf = nil)
     packaging = @packaging

Modified: buildr/trunk/spec/java/test_coverage_helper.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/java/test_coverage_helper.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/spec/java/test_coverage_helper.rb (original)
+++ buildr/trunk/spec/java/test_coverage_helper.rb Mon Oct 25 04:41:27 2010
@@ -53,7 +53,7 @@ module TestCoverageHelper
   end
 end
 
-describe 'test coverage tool', :shared=>true do
+shared_examples_for 'test coverage tool' do
   include TestCoverageHelper
 
   def toolname

Modified: buildr/trunk/spec/packaging/archive_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/archive_spec.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/archive_spec.rb (original)
+++ buildr/trunk/spec/packaging/archive_spec.rb Mon Oct 25 04:41:27 2010
@@ -17,15 +17,7 @@
 require File.expand_path(File.join(File.dirname(__FILE__), '..', 
'spec_helpers'))
 
 
-describe 'ArchiveTask', :shared=>true do
-  before do
-    @dir = File.expand_path('test')
-    @files = %w{Test1.txt Text2.html}.map { |file| File.expand_path(file, 
@dir) }.
-      each { |file| write file, content_for(file) }
-    @empty_dirs = %w{EmptyDir1 EmptyDir2}.map { |file| File.expand_path(file, 
@dir) }.
-      each { |file| mkdir file }
-  end
-
+module ArchiveTaskHelpers
   # Not too smart, we just create some content based on file name to make sure 
you read what you write.
   def content_for(file)
     "Content for #{File.basename(file)}"
@@ -48,6 +40,24 @@ describe 'ArchiveTask', :shared=>true do
     end
   end
 
+  def init_dir
+    unless @dir
+      @dir = File.expand_path('test')
+      @files = %w{Test1.txt Text2.html}.map { |file| File.expand_path(file, 
@dir) }.
+        each { |file| write file, content_for(file) }
+      @empty_dirs = %w{EmptyDir1 EmptyDir2}.map { |file| 
File.expand_path(file, @dir) }.
+        each { |file| mkdir file }
+    end
+  end
+end
+
+shared_examples_for 'ArchiveTask' do
+  include ArchiveTaskHelpers
+
+  before(:each) do
+    init_dir
+  end
+
   it 'should point to archive file' do
     archive(@archive).name.should eql(@archive)
   end
@@ -359,10 +369,13 @@ describe 'ArchiveTask', :shared=>true do
   end
 end
 
-
 describe TarTask do
   it_should_behave_like 'ArchiveTask'
-  before { @archive = File.expand_path('test.tar') }
+
+  before(:each) do
+    @archive = File.expand_path('test.tar')
+  end
+
   define_method(:archive) { |file| tar(file) }
 
   def inspect_archive
@@ -378,7 +391,11 @@ end
 
 describe TarTask, ' gzipped' do
   it_should_behave_like 'ArchiveTask'
-  before { @archive = File.expand_path('test.tgz') }
+
+  before(:each) do
+    @archive = File.expand_path('test.tgz')
+  end
+
   define_method(:archive) { |file| tar(file) }
 
   def inspect_archive
@@ -393,13 +410,19 @@ describe TarTask, ' gzipped' do
   end
 end
 
+describe "ZipTask" do
+  include ArchiveTaskHelpers
 
-describe ZipTask do
   it_should_behave_like 'ArchiveTask'
-  before { @archive = File.expand_path('test.zip') }
+
+  before(:each) do
+    init_dir
+    @archive = File.expand_path('test.zip')
+  end
+
   define_method(:archive) { |file| zip(file) }
 
-  after do
+  after(:each) do
     checkZip(@archive)
   end
 
@@ -473,9 +496,8 @@ describe ZipTask do
 
 end
 
-
 describe Unzip do
-  before do
+  before(:each) do
     @zip = File.expand_path('test.zip')
     @dir = File.expand_path('test')
     @files = %w{Test1.txt Text2.html}.map { |file| File.join(@dir, file) }.

Modified: buildr/trunk/spec/spec_helpers.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/spec_helpers.rb?rev=1026943&r1=1026942&r2=1026943&view=diff
==============================================================================
--- buildr/trunk/spec/spec_helpers.rb (original)
+++ buildr/trunk/spec/spec_helpers.rb Mon Oct 25 04:41:27 2010
@@ -24,7 +24,7 @@ unless defined?(SpecHelpers)
   spec = Gem::Specification.load(File.expand_path('../buildr.gemspec', 
File.dirname(__FILE__)))
   # Dependency.version_requirements deprecated in rubygems 1.3.6
   spec.dependencies.select {|dep| dep.type == :runtime }.each { |dep| gem 
dep.name, (dep.respond_to?(:requirement) ? dep.requirement.to_s : 
dep.version_requirements.to_s) }
-  
+
   # Make sure to load from these paths first, we don't want to load any
   # code from Gem library.
   $LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__)),
@@ -48,7 +48,7 @@ unless defined?(SpecHelpers)
       end
     end
   end
-  
+
   # Give a chance for plugins to do a few things before requiring the sandbox.
   include SandboxHook if defined?(SandboxHook)
 
@@ -287,9 +287,9 @@ unless defined?(SpecHelpers)
 
     # Value covered by range. For example:
     #   (1..5).should cover(3)
-    def cover(value)
-      simple_matcher :cover do |given|
-        value >= given.min && value <= given.max
+    RSpec::Matchers.define :cover do |actual|
+      match do |range|
+        actual >= range.min && actual <= range.max
       end
     end
 
@@ -357,9 +357,10 @@ unless defined?(SpecHelpers)
   end
 
 
-  Spec::Runner.configure do |config|
+  RSpec.configure do |config|
     # Make all Buildr methods accessible from test cases, and add various 
helper methods.
-    config.include Buildr, SpecHelpers
+    config.include Buildr
+    config.include SpecHelpers
 
     # Sanbdox Buildr for each test.
     config.include Sandbox


Reply via email to