Skip to content
Browse files

adapted specs to rspec 2.x

  • Loading branch information...
1 parent 51ef982 commit 5a4596b8677fe45c0d53f9dcde1bc8473b8dec8a @jmettraux jmettraux committed Nov 24, 2010
View
1 .rspec
@@ -0,0 +1 @@
+--colour --format documentation
View
26 Rakefile
@@ -1,3 +1,4 @@
+
require 'rubygems'
require 'rake'
@@ -18,38 +19,21 @@ begin
gemspec.add_dependency 'ruote', ">= #{RuoteAMQP::VERSION}"
# ruote depends on rufus-json
- gemspec.add_development_dependency 'rspec', '>= 2.0.0'
+ gemspec.add_development_dependency 'rspec', '>= 2.1.0'
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler not available. Install it with 'gem install jeweler'"
end
-require 'spec/rake/spectask'
-Spec::Rake::SpecTask.new(:spec) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.spec_files = FileList['spec/**/*_spec.rb']
-end
-
-Spec::Rake::SpecTask.new(:rcov) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.pattern = 'spec/**/*_spec.rb'
- spec.rcov = true
+#task :spec => :check_dependencies do
+task :spec do
+ sh 'rspec spec/'
end
-task :spec #=> :check_dependencies
task :default => :spec
-#begin
-# require 'yard'
-# YARD::Rake::YardocTask.new
-#rescue LoadError
-# task :yardoc do
-# abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
-# end
-#end
-
require 'rake/clean'
CLEAN.include('pkg', 'tmp', 'html', 'rdoc')
View
5 lib/spec/ruote.rb
@@ -1,5 +0,0 @@
-require File.dirname(__FILE__) + '/ruote_example_group.rb'
-require File.dirname(__FILE__) + '/ruote_matchers.rb'
-require File.dirname(__FILE__) + '/ruote_helpers.rb'
-
-Spec::Example::ExampleGroupFactory.register(:ruote, Spec::RuoteSpec::Example::RuoteExampleGroup)
View
8 lib/spec/ruote_example_group.rb
@@ -1,8 +0,0 @@
-module Spec
- module RuoteSpec
- module Example
- class RuoteExampleGroup < Spec::Example::ExampleGroup
- end
- end
- end
-end
View
2 spec/launchitem_listener_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/spec_helper'
+require File.join(File.dirname(__FILE__), 'spec_helper')
#
# NOTE : RuoteAMQP::LaunchitemListener has been depreacted in favour of
View
2 spec/participant_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/spec_helper'
+require File.join(File.dirname(__FILE__), 'spec_helper')
describe RuoteAMQP::ParticipantProxy, :type => :ruote do
View
5 spec/receiver_spec.rb
@@ -1,8 +1,5 @@
-require File.dirname(__FILE__) + '/spec_helper'
-
-# rspec clobbering global space... :(
-undef :context if defined?(:context)
+require File.join(File.dirname(__FILE__), 'spec_helper')
describe RuoteAMQP::Receiver do
View
8 spec/ruote_amqp_spec.rb
@@ -1,12 +1,18 @@
-require File.dirname(__FILE__) + '/spec_helper'
+
+require File.join(File.dirname(__FILE__), 'spec_helper')
+
describe RuoteAMQP do
+
it "should use persistent messages by default" do
+
RuoteAMQP.use_persistent_messages?.should be_true
end
it "should allow switching to transient messages" do
+
RuoteAMQP.use_persistent_messages = false
RuoteAMQP.use_persistent_messages?.should be_false
end
end
+
View
1 spec/spec.opts
@@ -1 +0,0 @@
---colour
View
22 spec/spec_helper.rb
@@ -1,9 +1,9 @@
+
require 'rubygems'
-gem 'rspec'
-require 'spec'
+require 'rspec'
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-$:.unshift('../ruote/lib')
+$:.unshift(File.join(File.dirname(__FILE__), '../lib'))
+$:.unshift(File.join(File.dirname(__FILE__), '../../ruote/lib'))
gem 'amqp', '=0.6.7'
@@ -16,7 +16,10 @@
require 'ruote/log/test_logger'
require 'ruote-amqp'
-require 'spec/ruote'
+
+Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |path|
+ require(path)
+}
# AMQP magic worked here
@@ -27,20 +30,17 @@
#AMQP.logging = true
-Spec::Runner.configure do |config|
+RSpec.configure do |config|
- config.include( RuoteSpecHelpers )
+ config.include(RuoteSpecHelpers)
config.before(:each) do
@tracer = Tracer.new
@engine = Ruote::Engine.new(
Ruote::Worker.new(
Ruote::HashStorage.new(
- 's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ]
- )
- )
- )
+ 's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ])))
@engine.add_service( 'tracer', @tracer )
end
View
0 lib/spec/ruote_helpers.rb → spec/support/ruote_helpers.rb
File renamed without changes.
View
16 lib/spec/ruote_matchers.rb → spec/support/ruote_matchers.rb
@@ -1,5 +1,5 @@
-Spec::Matchers.define :have_errors do |*args|
+RSpec::Matchers.define :have_errors do |*args|
match do |engine|
@@ -13,30 +13,38 @@
end
failure_message_for_should do |engine|
+
"Expected engine to have errors, but didn't"
end
+
failure_message_for_should_not do |engine|
+
"Expected the engine to not have errors, but it did.\n" +
@ps.errors.map { |e| " * error: #{e.message}\n\"#{e.trace}\"" }.join("\n")
end
+
description do
- #
end
end
-Spec::Matchers.define :have_remaining_expressions do
+RSpec::Matchers.define :have_remaining_expressions do
match do |engine|
(engine.storage.get_many('expressions').size != 0)
end
failure_message_for_should do |engine|
+
"Expected engine to have processes remaining, but it didn't"
end
+
failure_message_for_should_not do |engine|
- "Expected engine to have no processes remaining, but it did.#{engine.storage.get_many('expressions').inspect}"
+
+ "Expected engine to have no processes remaining, but it did." +
+ "#{engine.storage.get_many('expressions').inspect}"
end
+
description do
end
end
View
10 spec/workitem_listener_spec.rb
@@ -1,16 +1,18 @@
-require File.dirname(__FILE__) + '/spec_helper'
+require File.join(File.dirname(__FILE__), 'spec_helper')
#
# NOTE : RuoteAMQP::WorkitemListener has been depreacted in favour of
# RuoteAMQP::Receiver
#
-# rspec clobbering global space... :(
-#undef :context if defined?(:context)
describe RuoteAMQP::WorkitemListener do
+ after(:each) do
+ purge_engine
+ end
+
it "should handle replies" do
pdef = Ruote.process_definition :name => 'test' do
@@ -55,8 +57,6 @@
@engine.should_not have_remaining_expressions
@tracer.to_s.should == "foo\nbar"
-
- purge_engine
end
end

0 comments on commit 5a4596b

Please sign in to comment.
Something went wrong with that request. Please try again.