From 697e5f20634ba1408a41453d760d19381a519435 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 15 Sep 2010 16:11:09 +0200 Subject: tests use the mocker --- t/spore-middleware/format-yaml.t | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 't/spore-middleware/format-yaml.t') diff --git a/t/spore-middleware/format-yaml.t b/t/spore-middleware/format-yaml.t index c104cc5..db9629d 100644 --- a/t/spore-middleware/format-yaml.t +++ b/t/spore-middleware/format-yaml.t @@ -6,18 +6,22 @@ use YAML; use Net::HTTP::Spore; +my $content = { keys => [qw/1 2 3/] }; + +my $mock_server = { + '/test_spore/_all_docs' => sub { + my $req = shift; + $req->new_response( 200, [ 'Content-Type' => 'text/x-yaml' ], + Dump($content) ); + }, +}; + ok my $client = Net::HTTP::Spore->new_from_spec( 't/specs/couchdb.json', api_base_url => 'http://localhost:5984' ); -my $content = { keys => [qw/1 2 3/] }; - $client->enable('Format::YAML'); -$client->enable( - 'Test::Response', - body => Dump($content), - headers => [ 'Content-Type' => 'text/x-yaml' ] -); +$client->enable( 'Mock', tests => $mock_server ); my $res = $client->get_all_documents( database => 'test_spore' ); is $res->[0], 200; @@ -28,3 +32,4 @@ my $req = $res->request; is $req->header('Accept'), 'text/x-yaml'; done_testing; + -- cgit v1.2.3