From 4709ebc7ede865134eb27d787703ac88d15d9c73 Mon Sep 17 00:00:00 2001 From: Matt Zumwalt Date: Thu, 19 May 2011 12:45:56 -0500 Subject: [PATCH] HYDRA-455: removing unused spec tasks, cleaning up execution of rake tasks, updating README, addressing bug reported by molly in comments on HYDRA-455 --- README.textile | 34 +++++++++++++++++++++----------- Rakefile | 1 - lib/tasks/active_fedora.rake | 2 +- lib/tasks/active_fedora_dev.rake | 23 ++++++++++++++++++++- lib/tasks/rspec.rake | 29 --------------------------- 5 files changed, 46 insertions(+), 43 deletions(-) delete mode 100644 lib/tasks/rspec.rake diff --git a/README.textile b/README.textile index 46936de38..67024c53b 100644 --- a/README.textile +++ b/README.textile @@ -18,7 +18,7 @@ h2. Getting Started The "ActiveFedora Console Tour":https://github.com/mediashelf/active_fedora/blob/master/CONSOLE_GETTING_STARTED.textile gives you a brief tour through ActiveFedora's features on the command line. -h2. Testing +h2. Installation In order to run the RSpec tests, you need to have a copy of the ActiveFedora source code, and then run bundle install in the source directory. @@ -28,7 +28,19 @@ cd /wherever/active_fedora/is bundle install -You also need to have a copy of hydra-jetty running. To do this, download a working copy of "hydra-jetty":https://github.com/projecthydra/hydra-jetty, cd into its root and run +h2. Testing with Hudson Rake Task + +The hudson rake task will spin up jetty, import the fixtures, and run the tests for you. + +
+  rake hudson
+
+ +h2. Testing Manually + +If you want to run the tests manually, follow these instructions. + +You need to have a copy of hydra-jetty running. To do this, download a working copy of "hydra-jetty":https://github.com/projecthydra/hydra-jetty, cd into its root and run
 java -jar start.jar
@@ -37,22 +49,22 @@ java -jar start.jar
 Then open a new terminal, go to your ActiveFedora source directory, and import fedora's demo objects.
 
 
-cd /wherever/active_fedora/is
-export FEDORA_HOME=/path/to/hydra/jetty/fedora/default
-$FEDORA_HOME/client/bin/fedora-ingest-demos.sh localhost 8983 fedoraAdmin fedoraAdmin http
+  rake active_fedora:load_fixtures RAILS_ENV=test
 
- -You must ingest one fixture using the import_fixture rake task provided by the hydra project. + +This does the equivalent of:
-rake fedora:import_fixture pid=hydrangea_fixture_mods_article1
+cd /wherever/active_fedora/is
+export FEDORA_HOME=/path/to/hydra/jetty/fedora/default
+$FEDORA_HOME/client/bin/fedora-ingest-demos.sh localhost 8983 fedoraAdmin fedoraAdmin http
+rake af:import_fixture pid=hydrangea:fixture_mods_article1 RAILS_ENV=test
 
-Now you're ready to run +Now you're ready to run the tests. In the directory where active_fedora is installed, run
-cd /wherever/active_fedora/is
-rake spec
+  rake spec
 
h2. Acknowledgements diff --git a/Rakefile b/Rakefile index 8c99952a8..1ff40dfe7 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,5 @@ require 'rake/clean' require 'rubygems' -load 'lib/tasks/rspec.rake' $: << 'lib' diff --git a/lib/tasks/active_fedora.rake b/lib/tasks/active_fedora.rake index ff92fd132..4d7e1a361 100644 --- a/lib/tasks/active_fedora.rake +++ b/lib/tasks/active_fedora.rake @@ -101,7 +101,7 @@ namespace :af do file = File.new(filename, "r") result = foxml = Fedora::Repository.instance.ingest(file.read) if result - puts "The fixture has been ingested as #{result}" + puts "The fixture has been ingested as #{result.body}" if !pid.nil? solrizer = Solrizer::Fedora::Solrizer.new solrizer.solrize(pid) diff --git a/lib/tasks/active_fedora_dev.rake b/lib/tasks/active_fedora_dev.rake index ff5c5af02..c0726cca9 100644 --- a/lib/tasks/active_fedora_dev.rake +++ b/lib/tasks/active_fedora_dev.rake @@ -1,5 +1,26 @@ +begin + require 'spec' +rescue LoadError + require 'rubygems' + require 'spec' +end +begin + require 'spec/rake/spectask' +rescue LoadError + puts <<-EOS +To use rspec for testing you must install rspec gem: + gem install rspec +EOS + exit(0) +end + $: << 'lib' +desc "Run active-fedora rspec tests" +task :spec do + Rake::Task["active_fedora:rspec"].invoke +end + desc "Hudson build" task :hudson do require 'jettywrapper' @@ -29,7 +50,6 @@ task :hudson do end end - namespace :active_fedora do require 'lib/active-fedora' @@ -115,6 +135,7 @@ desc 'Set up ActiveFedora environment. !! Only for use while working within a w task :environment do puts "Initializing ActiveFedora Rake environment. This should only be called when working within a workign copy of the active-fedora code." require 'spec/samples/models/hydrangea_article' + require 'active_fedora/samples' # $:.unshift(File.dirname(__FILE__) + '/../lib') # Dir[File.join(File.dirname(__FILE__)+'/../lib/')+'**/*.rb'].each{|x| require x} end diff --git a/lib/tasks/rspec.rake b/lib/tasks/rspec.rake deleted file mode 100644 index 25270e91e..000000000 --- a/lib/tasks/rspec.rake +++ /dev/null @@ -1,29 +0,0 @@ -begin - require 'spec' -rescue LoadError - require 'rubygems' - require 'spec' -end -begin - require 'spec/rake/spectask' -rescue LoadError - puts <<-EOS -To use rspec for testing you must install rspec gem: - gem install rspec -EOS - exit(0) -end - -desc "Run the specs under spec/models" -Spec::Rake::SpecTask.new do |t| - t.spec_opts = ['--options', "spec/spec.opts"] - t.spec_files = FileList['spec/**/*_spec.rb'] -end - -namespace :spec do - desc "run the unit specs" - Spec::Rake::SpecTask.new(:units) do |t| - t.spec_opts = ['--options', "spec/spec.opts"] - t.spec_files = FileList['spec/unit/**/*_spec.rb'] - end -end