diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..7438fbe51 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--colour +--format documentation diff --git a/Gemfile b/Gemfile index 0cfa33569..7a86b3aad 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,7 @@ end group :test, :development do gem 'rake', '>= 0.9.0' - gem 'rspec', '~> 1.2.9' + gem 'rspec', '~> 2.10.0' gem 'rcov', '>= 0.9.9', :platform => :mri_18 end diff --git a/Rakefile b/Rakefile index cf1eea187..1565402c4 100644 --- a/Rakefile +++ b/Rakefile @@ -5,9 +5,9 @@ $LOAD_PATH.uniq! require 'rubygems' require 'rake' -gem 'rspec', '~> 1.2.9' +gem 'rspec', '~> 2.10.0' begin - require 'spec/rake/spectask' + require 'rspec/core/rake_task' rescue LoadError STDERR.puts "Please install rspec:" STDERR.puts "sudo gem install rspec" diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index 5779d6236..000000000 --- a/spec/spec.opts +++ /dev/null @@ -1,2 +0,0 @@ ---colour ---format specdoc diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 531fa9598..6f1dd6867 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,3 +3,6 @@ lib_dir = File.expand_path("../lib", spec_dir) $LOAD_PATH.unshift(lib_dir) $LOAD_PATH.uniq! + +RSpec.configure do |config| +end diff --git a/tasks/gem.rake b/tasks/gem.rake index 2f6696069..098333a3e 100644 --- a/tasks/gem.rake +++ b/tasks/gem.rake @@ -39,7 +39,7 @@ namespace :gem do s.add_development_dependency('sinatra', '>= 1.2.0') s.add_development_dependency('rake', '>= 0.9.0') - s.add_development_dependency('rspec', '~> 1.2.9') + s.add_development_dependency('rspec', '~> 2.10.0') s.add_development_dependency('rcov', '>= 0.9.9') s.require_path = 'lib' diff --git a/tasks/spec.rake b/tasks/spec.rake index 0838b646e..85d498633 100644 --- a/tasks/spec.rake +++ b/tasks/spec.rake @@ -1,16 +1,31 @@ -require 'spec/rake/verify_rcov' require 'rake/clean' CLOBBER.include('coverage', 'specdoc') namespace :spec do - Spec::Rake::SpecTask.new(:rcov) do |t| - t.spec_files = FileList['spec/**/*_spec.rb'] - t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc'] + RSpec::Core::RakeTask.new(:all) do |t| + end + + RSpec::Core::RakeTask.new(:fast) do |t| + t.pattern = FileList['spec/**/*_spec.rb'].exclude( + 'spec/**/*_slow_spec.rb' + ) + end + + desc 'Generate HTML Specdocs for all specs.' + RSpec::Core::RakeTask.new(:specdoc) do |t| + specdoc_path = File.expand_path('../../specdoc', __FILE__) + Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path) + + t.rspec_opts = %W( --format html --out #{File.join(specdoc_path, 'index.html')} ) + t.fail_on_error = false + end + + RSpec::Core::RakeTask.new(:rcov) do |t| if RCOV_ENABLED if `which rcov`.strip == "" STDERR.puts( - "Please install rcov and ensure that its binary is in the PATH:" + "Please install rcov and ensure that its binary is in the PATH:" ) STDERR.puts("sudo gem install rcov") exit(1) @@ -19,30 +34,16 @@ namespace :spec do else t.rcov = false end - t.rcov_opts = [ - '--exclude', 'lib\\/google\\/api_client\\/environment.rb', - '--exclude', 'lib\\/compat', - '--exclude', 'spec', - '--exclude', '\\.rvm\\/gems', - '--exclude', '1\\.8\\/gems', - '--exclude', '1\\.9\\/gems', - '--exclude', '\\.rvm', - '--exclude', '\\/Library\\/Ruby', - ] - end - - Spec::Rake::SpecTask.new(:all) do |t| - t.spec_files = FileList['spec/**/*_spec.rb'] - t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc'] - t.rcov = false - end - - Spec::Rake::SpecTask.new(:fast) do |t| - t.spec_files = FileList['spec/**/*_spec.rb'].exclude( - 'spec/**/*_slow_spec.rb' + t.rcov_opts = %w( + --exclude lib/google/api_client/environment.rb, + lib/compat, + spec, + .rvm/gems, + 1.8/gems, + 1.9/gems, + .rvm, + /Library/Ruby ) - t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc'] - t.rcov = false end if RCOV_ENABLED @@ -54,18 +55,6 @@ namespace :spec do task :verify => :rcov end - desc 'Generate HTML Specdocs for all specs' - Spec::Rake::SpecTask.new(:specdoc) do |t| - specdoc_path = File.expand_path( - File.join(File.dirname(__FILE__), '../specdoc/')) - Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path) - - output_file = File.join(specdoc_path, 'index.html') - t.spec_files = FileList['spec/**/*_spec.rb'] - t.spec_opts = ['--format', "\"html:#{output_file}\"", '--diff'] - t.fail_on_error = false - end - namespace :rcov do desc 'Browse the code coverage report.' task :browse => 'spec:rcov' do