Permalink
Browse files

fixed and refactored specs to use rspec2 and follow conventions. also…

… moved integration specs into their own repository.
  • Loading branch information...
1 parent 5972d94 commit f6f7e0c1bdb32b194a0c8b97d4ee375f3195bb3f @rubiii rubiii committed Sep 1, 2010
View
5 .autotest
@@ -1,5 +0,0 @@
-Autotest.add_hook(:initialize) do |at|
- at.clear_mappings
- at.add_mapping(%r%^spec/savon/.*_spec.rb$%) { |filename, _| filename }
- at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| ["spec/#{m[1]}_spec.rb"] }
-end
View
1 .rspec
@@ -0,0 +1 @@
+--colour
View
53 Rakefile
@@ -1,50 +1,13 @@
-require "rake"
-require "spec/rake/spectask"
-require "spec/rake/verify_rcov"
-
-task :default => :spec
-
-Spec::Rake::SpecTask.new do |spec|
- spec.spec_files = FileList["spec/{savon}/**/*_spec.rb"]
- spec.spec_opts << "--color"
- spec.libs += ["lib", "spec"]
- spec.rcov = true
-end
-
-RCov::VerifyTask.new(:spec_verify => :spec) do |verify|
- verify.threshold = 100.0
- verify.index_html = "rcov/index.html"
-end
-
-desc "Run integration specs using WEBrick"
-task :spec_integration do
- pid = fork { exec "ruby spec/integration/server.rb" }
- sleep 10 # wait until the server is actually ready
- begin
- task(:run_integration_spec).invoke
- ensure
- Process.kill "TERM", pid
- Process.wait pid
- end
-end
-
-desc "" # make this task invisible
-Spec::Rake::SpecTask.new(:run_integration_spec) do |spec|
- spec.spec_files = FileList["spec/{integration}/**/*_spec.rb"]
- spec.spec_opts << "--color"
- spec.libs += ["lib", "spec"]
-end
-
begin
- require "hanna/rdoctask"
+ require "rspec/core/rake_task"
- Rake::RDocTask.new do |rdoc|
- rdoc.title = "Savon - Heavy metal Ruby SOAP client library"
- rdoc.rdoc_dir = "doc"
- rdoc.rdoc_files.include("**/*.rdoc").include("lib/**/*.rb")
- rdoc.options << "--line-numbers"
- rdoc.options << "--webcvs=http://github.com/rubiii/savon/tree/master/"
+ RSpec::Core::RakeTask.new do |t|
+ t.spec_opts = %w(-fd -c)
end
rescue LoadError
- puts "'gem install hanna' for documentation"
+ task :spec do
+ abort "Run 'gem install rspec --pre' to be able to run specs"
+ end
end
+
+task :default => :spec
View
1 autotest/discover.rb
@@ -0,0 +1 @@
+Autotest.add_discovery { "rspec2" }
View
1 discover.rb
@@ -0,0 +1 @@
+Autotest.add_discovery { "rspec2" }
View
11 spec/basic_spec_helper.rb
@@ -1,11 +0,0 @@
-require "rake"
-require "spec"
-require "mocha"
-require "fakeweb"
-
-Spec::Runner.configure do |config|
- config.mock_with :mocha
-end
-
-require "savon"
-Savon::Request.log = false
View
16 spec/integration/http_basic_auth_spec.rb
@@ -1,16 +0,0 @@
-require "basic_spec_helper"
-
-describe Savon do
- before { @client = Savon::Client.new :soap_endpoint => "http://localhost:8080/http-basic-auth" }
-
- it "should be able to handle HTTP basic authentication" do
- @client.request.basic_auth "user", "password"
- response = @client.do_something
- response.to_hash[:authenticate_response][:return][:success].should == true
- end
-
- it "should raise a Savon::HTTPError in case authentication failed" do
- lambda { @client.do_something }.should raise_error(Savon::HTTPError)
- end
-
-end
View
51 spec/integration/server.rb
@@ -1,51 +0,0 @@
-require "webrick"
-
-include WEBrick
-
-# Run WEBrick. Yields the server to a given block.
-def run_webrick(config = {})
- config.update :Port => 8080
- server = HTTPServer.new config
- yield server if block_given?
- ["INT", "TERM"].each { |signal| trap(signal) { server.shutdown } }
- server.start
-end
-
-# Returns the SOAP response fixture for a given +file+.
-def respond_with(file)
- response_path = File.dirname(__FILE__) + "/../fixtures/response/xml"
- File.read "#{response_path}/#{file}.xml"
-end
-
-# Returns HTML links for a given Hash of link URI's and names.
-def link_to(links)
- links.map { |link| "<a href='#{link[:uri]}'>#{link[:name]}</a>" }.join("<br>")
-end
-
-run_webrick do |server|
- user, password, realm = "user", "password", "realm"
-
- htdigest = HTTPAuth::Htdigest.new "/tmp/webrick-htdigest"
- htdigest.set_passwd realm, user, password
- authenticator = HTTPAuth::DigestAuth.new :UserDB => htdigest, :Realm => realm
-
- # Homepage including links to subpages.
- server.mount_proc("/") do |request, response|
- response.body = link_to [
- { :uri => "http-basic-auth", :name => "HTTP basic auth" },
- { :uri => "http-digest-auth", :name => "HTTP digest auth" }
- ]
- end
-
- # HTTP basic authentication.
- server.mount_proc("/http-basic-auth") do |request, response|
- HTTPAuth.basic_auth(request, response, realm) { |u, p| u == user && p == password }
- response.body = respond_with :authentication
- end
-
- # HTTP digest authentication.
- server.mount_proc("/http-digest-auth") do |request, response|
- authenticator.authenticate request, response
- response.body = "HTTP digest authentication successfull"
- end
-end
View
2 spec/savon/core_ext/datetime_spec.rb
@@ -3,7 +3,7 @@
describe DateTime do
before do
@datetime = DateTime.new 2012, 03, 22, 16, 22, 33
- @datetime_string = "2012-03-22T16:22:33Z"
+ @datetime_string = "2012-03-22T16:22:33+00:00"
end
describe "to_soap_value" do
View
6 spec/savon/core_ext/hash_spec.rb
@@ -56,7 +56,7 @@
it "should convert DateTime objects to xs:dateTime compliant Strings" do
hash = { :before => DateTime.new(2012, 03, 22, 16, 22, 33) }
- result = "<before>2012-03-22T16:22:33Z</before>"
+ result = "<before>2012-03-22T16:22:33+00:00</before>"
hash.to_soap_xml.should == result
end
@@ -67,7 +67,7 @@ def singleton.to_datetime
DateTime.new(2012, 03, 22, 16, 22, 33)
end
- hash, result = { :before => singleton }, "<before>2012-03-22T16:22:33Z</before>"
+ hash, result = { :before => singleton }, "<before>2012-03-22T16:22:33+00:00</before>"
hash.to_soap_xml.should == result
end
@@ -166,7 +166,7 @@ def singleton.to_datetime
end
it "should convert Hash values matching the xs:dateTime format into DateTime Objects" do
- soap_response = { "response" => { "at" => "2012-03-22T16:22:33" } }
+ soap_response = { "response" => { "at" => "2012-03-22T16:22:33+00:00" } }
result = { :response => { :at => DateTime.new(2012, 03, 22, 16, 22, 33) } }
soap_response.map_soap_response.should == result
View
2 spec/savon/core_ext/object_spec.rb
@@ -23,7 +23,7 @@ def singleton.to_datetime
DateTime.new(2012, 03, 22, 16, 22, 33)
end
- singleton.to_soap_value.should == "2012-03-22T16:22:33Z"
+ singleton.to_soap_value.should == "2012-03-22T16:22:33+00:00"
end
it "calls to_s unless the Object responds to to_datetime" do
View
2 spec/savon/soap_spec.rb
@@ -31,7 +31,7 @@
Savon::SOAP::DateTimeFormat.should_not be_empty
DateTime.new(2012, 03, 22, 16, 22, 33).strftime(Savon::SOAP::DateTimeFormat).
- should == "2012-03-22T16:22:33Z"
+ should == "2012-03-22T16:22:33+00:00"
end
it "should contain a Regexp matching the xs:dateTime format" do
View
19 spec/savon/wsse_spec.rb
@@ -77,7 +77,8 @@
@wsse.password = @password
header = @wsse.header
- header.should include_security_namespaces
+ header.should include(Savon::WSSE::WSENamespace)
+ header.should include(Savon::WSSE::WSUNamespace)
header.should include(@username)
header.should include(@password)
header.should include(Savon::WSSE::PasswordTextURI)
@@ -88,7 +89,8 @@
Savon::WSSE.password = @password
header = @wsse.header
- header.should include_security_namespaces
+ header.should include(Savon::WSSE::WSENamespace)
+ header.should include(Savon::WSSE::WSUNamespace)
header.should include(@username)
header.should include(@password)
header.should include(Savon::WSSE::PasswordTextURI)
@@ -102,7 +104,8 @@
@wsse.digest = true
header = @wsse.header
- header.should include_security_namespaces
+ header.should include(Savon::WSSE::WSENamespace)
+ header.should include(Savon::WSSE::WSUNamespace)
header.should include(@username)
header.should_not include(@password)
header.should include(Savon::WSSE::PasswordDigestURI)
@@ -114,19 +117,13 @@
Savon::WSSE.digest = true
header = @wsse.header
- header.should include_security_namespaces
+ header.should include(Savon::WSSE::WSENamespace)
+ header.should include(Savon::WSSE::WSUNamespace)
header.should include(@username)
header.should_not include(@password)
header.should include(Savon::WSSE::PasswordDigestURI)
end
end
-
- def include_security_namespaces
- simple_matcher("include security namespaces") do |given|
- given.should include(Savon::WSSE::WSENamespace)
- given.should include(Savon::WSSE::WSUNamespace)
- end
- end
end
end
View
4 spec/spec.opts
@@ -1,4 +0,0 @@
---colour
---format progress
---loadby mtime
---reverse
View
20 spec/spec_helper.rb
@@ -1,5 +1,17 @@
-require "basic_spec_helper"
+require "rspec"
+require "mocha"
+require "fakeweb"
-FileList["spec/fixtures/**/*.rb"].each { |fixture| require fixture }
-require "endpoint_helper"
-require "http_stubs"
+RSpec.configure do |config|
+ config.mock_with :mocha
+end
+
+require "savon"
+Savon::Request.log = false
+
+# Requires fixtures.
+Dir["spec/fixtures/**/*.rb"].each {|file| require file }
+
+# Requires supporting files.
+require "support/endpoint_helper"
+require "support/http_stubs"
View
0 spec/endpoint_helper.rb → spec/support/endpoint_helper.rb
File renamed without changes.
View
0 spec/http_stubs.rb → spec/support/http_stubs.rb
File renamed without changes.

0 comments on commit f6f7e0c

Please sign in to comment.