From bbb13ec1cfab4eaaa5a2db76863a3a8da95f9a77 Mon Sep 17 00:00:00 2001 From: Paul Gallagher Date: Sun, 30 Oct 2011 00:55:05 +0800 Subject: [PATCH] switch to rspec --- .gitignore | 2 +- .rvmrc | 2 ++ Gemfile | 12 ++++++------ Gemfile.lock | 33 +++++++++++++++++++++++++++++++++ Rakefile | 37 ++++++++++++++++--------------------- VERSION | 1 - lib/rgovdata.rb | 1 + lib/rgovdata/version.rb | 9 +++++++++ spec/spec_helper.rb | 24 ++++++++++++++++++++++++ test/helper.rb | 18 ------------------ test/test_rgovdata.rb | 7 ------- 11 files changed, 92 insertions(+), 54 deletions(-) create mode 100644 .rvmrc create mode 100644 Gemfile.lock delete mode 100644 VERSION create mode 100644 lib/rgovdata/version.rb create mode 100644 spec/spec_helper.rb delete mode 100644 test/helper.rb delete mode 100644 test/test_rgovdata.rb diff --git a/.gitignore b/.gitignore index eb8e985..9246680 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,7 @@ pkg #*.swp # For redcar: -#.redcar +.redcar # For rubinius: #*.rbc diff --git a/.rvmrc b/.rvmrc new file mode 100644 index 0000000..52f7300 --- /dev/null +++ b/.rvmrc @@ -0,0 +1,2 @@ +rvm use 1.9.2-p136@rgovdata --create + diff --git a/Gemfile b/Gemfile index f79b668..87e6769 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,13 @@ source "http://rubygems.org" -# Add dependencies required to use your gem here. -# Example: -# gem "activesupport", ">= 2.3.5" +gem "rake", '~> 0.9.2.2' -# Add dependencies to develop your gem here. -# Include everything needed to run rake, tests, features, etc. group :development do - gem "shoulda", ">= 0" gem "bundler", "~> 1.0.0" gem "jeweler", "~> 1.6.4" gem "rcov", ">= 0" + gem 'rdoc', '~> 3.11' +end + +group :development, :test do + gem 'rspec', '~> 2.7.0', :require => 'spec' end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..28df370 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,33 @@ +GEM + remote: http://rubygems.org/ + specs: + diff-lcs (1.1.3) + git (1.2.5) + jeweler (1.6.4) + bundler (~> 1.0) + git (>= 1.2.5) + rake + json (1.6.1) + rake (0.9.2.2) + rcov (0.9.11) + rdoc (3.11) + json (~> 1.4) + rspec (2.7.0) + rspec-core (~> 2.7.0) + rspec-expectations (~> 2.7.0) + rspec-mocks (~> 2.7.0) + rspec-core (2.7.1) + rspec-expectations (2.7.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.7.0) + +PLATFORMS + ruby + +DEPENDENCIES + bundler (~> 1.0.0) + jeweler (~> 1.6.4) + rake (~> 0.9.2.2) + rcov + rdoc (~> 3.11) + rspec (~> 2.7.0) diff --git a/Rakefile b/Rakefile index d053b69..b0431e1 100644 --- a/Rakefile +++ b/Rakefile @@ -10,11 +10,17 @@ rescue Bundler::BundlerError => e exit e.status_code end require 'rake' +require 'rspec' +require 'rspec/core/rake_task' + +$LOAD_PATH.unshift('lib') +require 'rgovdata/version' require 'jeweler' Jeweler::Tasks.new do |gem| # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options gem.name = "rgovdata" + gem.version = Rgovdata::Version::STRING gem.homepage = "http://github.com/tardate/rgovdata" gem.license = "MIT" gem.summary = %Q{TODO: one-line summary of your gem} @@ -25,29 +31,18 @@ Jeweler::Tasks.new do |gem| end Jeweler::RubygemsDotOrgTasks.new -require 'rake/testtask' -Rake::TestTask.new(:test) do |test| - test.libs << 'lib' << 'test' - test.pattern = 'test/**/test_*.rb' - test.verbose = true -end - -require 'rcov/rcovtask' -Rcov::RcovTask.new do |test| - test.libs << 'test' - test.pattern = 'test/**/test_*.rb' - test.verbose = true - test.rcov_opts << '--exclude "gems/*"' +RSpec::Core::RakeTask.new do |t| + t.rspec_opts = ["-c", "-f progress"] + t.pattern = 'spec/**/*_spec.rb' end -task :default => :test - -require 'rake/rdoctask' -Rake::RDocTask.new do |rdoc| - version = File.exist?('VERSION') ? File.read('VERSION') : "" +task :default => :spec +require 'rdoc/task' +RDoc::Task.new do |rdoc| + rdoc.main = "README.rdoc" rdoc.rdoc_dir = 'rdoc' - rdoc.title = "rgovdata #{version}" - rdoc.rdoc_files.include('README*') - rdoc.rdoc_files.include('lib/**/*.rb') + rdoc.title = "rgovdata #{Rgovdata::Version::STRING}" + rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb") end + diff --git a/VERSION b/VERSION deleted file mode 100644 index 6c6aa7c..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.1.0 \ No newline at end of file diff --git a/lib/rgovdata.rb b/lib/rgovdata.rb index e69de29..d56972e 100644 --- a/lib/rgovdata.rb +++ b/lib/rgovdata.rb @@ -0,0 +1 @@ +require 'rgovdata/version' \ No newline at end of file diff --git a/lib/rgovdata/version.rb b/lib/rgovdata/version.rb new file mode 100644 index 0000000..99eb810 --- /dev/null +++ b/lib/rgovdata/version.rb @@ -0,0 +1,9 @@ +class Rgovdata + module Version + MAJOR = 0 + MINOR = 1 + PATCH = 0 + + STRING = [MAJOR, MINOR, PATCH].compact.join('.') + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..a0605ce --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,24 @@ + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +RSpec.configure do |config| + # == Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + config.mock_with :rspec + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + # config.use_transactional_fixtures = true + +end diff --git a/test/helper.rb b/test/helper.rb deleted file mode 100644 index db65ab6..0000000 --- a/test/helper.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rubygems' -require 'bundler' -begin - Bundler.setup(:default, :development) -rescue Bundler::BundlerError => e - $stderr.puts e.message - $stderr.puts "Run `bundle install` to install missing gems" - exit e.status_code -end -require 'test/unit' -require 'shoulda' - -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -$LOAD_PATH.unshift(File.dirname(__FILE__)) -require 'rgovdata' - -class Test::Unit::TestCase -end diff --git a/test/test_rgovdata.rb b/test/test_rgovdata.rb deleted file mode 100644 index 5ed11ef..0000000 --- a/test/test_rgovdata.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'helper' - -class TestRgovdata < Test::Unit::TestCase - should "probably rename this file and start testing for real" do - flunk "hey buddy, you should probably rename this file and start testing for real" - end -end