Switch testing to MiniTest::Spec

Official testing has been revised slightly to use MiniTest but in spec
form BUT using asserts not expectations.
This commit is contained in:
Paul Thornthwaite 2014-04-03 09:24:18 +01:00
parent fef4d12e20
commit 05f1e5bacd
3 changed files with 35 additions and 31 deletions

View File

@ -51,7 +51,7 @@ task :default => :test
task :travis => ['test', 'test:travis', 'coveralls_push_workaround']
Rake::TestTask.new do |t|
t.pattern = File.join("**", "test", "**", "*_test.rb")
t.pattern = File.join("**", "spec", "**", "*_spec.rb")
end
namespace :test do

View File

@ -0,0 +1,34 @@
require "minitest/autorun"
require "fog"
# @note This is going to be part of fog-xml eventually
describe Fog::XML::Connection do
before do
@connection = Fog::XML::Connection.new("http://localhost")
end
after do
Excon.stubs.clear
end
it "responds to #request" do
assert_respond_to @connection, :request
end
describe "when request is passed a parser" do
it "returns the body after parsing" do
@parser = Fog::ToHashDocument.new
Excon.stub({}, { :status => 200, :body => "<xml></xml>" })
response = @connection.request(:parser => @parser, :mock => true)
assert_equal({ :xml => "" }, response.body)
end
end
describe "when request excludes a parser" do
it "returns the response body without change" do
Excon.stub({}, { :status => 200, :body => "<xml></xml>" })
response = @connection.request(:mock => true)
assert_equal("<xml></xml>", response.body)
end
end
end

View File

@ -1,30 +0,0 @@
require "minitest/autorun"
require "fog"
# Note this is going to be part of fog-xml eventually
class Fog::XML::ConnectionTest < Minitest::Test
def setup
@connection = Fog::XML::Connection.new("http://localhost")
end
def teardown
Excon.stubs.clear
end
def test_respond_to_request
assert_respond_to @connection, :request
end
def test_request_with_parser
@parser = Fog::ToHashDocument.new
Excon.stub({}, { :status => 200, :body => "<xml></xml>" })
response = @connection.request(:parser => @parser, :mock => true)
assert_equal({ :xml => "" }, response.body)
end
def test_request_without_parser
Excon.stub({}, { :status => 200, :body => "<xml></xml>" })
response = @connection.request(:mock => true)
assert_equal("<xml></xml>", response.body)
end
end