diff --git a/.autotest b/.autotest deleted file mode 100644 index ac96595c..00000000 --- a/.autotest +++ /dev/null @@ -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 diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..53607ea5 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--colour diff --git a/Rakefile b/Rakefile index 5104f25c..88d3cad4 100644 --- a/Rakefile +++ b/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 diff --git a/autotest/discover.rb b/autotest/discover.rb new file mode 100644 index 00000000..cd6892cc --- /dev/null +++ b/autotest/discover.rb @@ -0,0 +1 @@ +Autotest.add_discovery { "rspec2" } diff --git a/discover.rb b/discover.rb new file mode 100644 index 00000000..cd6892cc --- /dev/null +++ b/discover.rb @@ -0,0 +1 @@ +Autotest.add_discovery { "rspec2" } diff --git a/spec/basic_spec_helper.rb b/spec/basic_spec_helper.rb deleted file mode 100644 index e29b9876..00000000 --- a/spec/basic_spec_helper.rb +++ /dev/null @@ -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 diff --git a/spec/integration/http_basic_auth_spec.rb b/spec/integration/http_basic_auth_spec.rb deleted file mode 100644 index 390cf26f..00000000 --- a/spec/integration/http_basic_auth_spec.rb +++ /dev/null @@ -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 diff --git a/spec/integration/server.rb b/spec/integration/server.rb deleted file mode 100644 index c790d94d..00000000 --- a/spec/integration/server.rb +++ /dev/null @@ -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| "#{link[:name]}" }.join("
") -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 diff --git a/spec/savon/core_ext/datetime_spec.rb b/spec/savon/core_ext/datetime_spec.rb index 43667a90..f8c3d830 100644 --- a/spec/savon/core_ext/datetime_spec.rb +++ b/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 diff --git a/spec/savon/core_ext/hash_spec.rb b/spec/savon/core_ext/hash_spec.rb index 3fd1339b..cba6d645 100644 --- a/spec/savon/core_ext/hash_spec.rb +++ b/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 = "2012-03-22T16:22:33Z" + result = "2012-03-22T16:22:33+00:00" 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 }, "2012-03-22T16:22:33Z" + hash, result = { :before => singleton }, "2012-03-22T16:22:33+00:00" 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 diff --git a/spec/savon/core_ext/object_spec.rb b/spec/savon/core_ext/object_spec.rb index b15283c6..6a3d7e42 100644 --- a/spec/savon/core_ext/object_spec.rb +++ b/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 diff --git a/spec/savon/soap_spec.rb b/spec/savon/soap_spec.rb index e7dc84ee..0aeaf85c 100644 --- a/spec/savon/soap_spec.rb +++ b/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 diff --git a/spec/savon/wsse_spec.rb b/spec/savon/wsse_spec.rb index ef11fe36..306e6527 100644 --- a/spec/savon/wsse_spec.rb +++ b/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 diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index 391705bf..00000000 --- a/spec/spec.opts +++ /dev/null @@ -1,4 +0,0 @@ ---colour ---format progress ---loadby mtime ---reverse diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 13a9973b..997f23f0 100644 --- a/spec/spec_helper.rb +++ b/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" diff --git a/spec/endpoint_helper.rb b/spec/support/endpoint_helper.rb similarity index 100% rename from spec/endpoint_helper.rb rename to spec/support/endpoint_helper.rb diff --git a/spec/http_stubs.rb b/spec/support/http_stubs.rb similarity index 100% rename from spec/http_stubs.rb rename to spec/support/http_stubs.rb