File: Simple.t

package info (click to toggle)
libweather-com-perl 0.5.0-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 340 kB
  • ctags: 148
  • sloc: perl: 3,509; makefile: 44
file content (48 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#####################################################################
#
#  Test suite for 'Weather::Com::Simple'
#
#  Functional tests with 'Test::MockObject'. These could only be run
#  if Test::MockObject is installed.
#
#  Before `make install' is performed this script should be runnable
#  with `make test'. After `make install' it should work as
#  `perl t/Simple.t'
#
#####################################################################
#
# initialization
#
no warnings;
use Data::Dumper;
use Test::More tests => 2;
require 't/TestData.pm';

BEGIN {
	use_ok('Weather::Com::Simple');
}

#####################################################################
#
# Test functionality if Test::MockObject is installed.
#
SKIP: {
	eval { require Test::MockObject; };
	skip( "Test::MockObject not installed", 1 ) if ($@);

	my %weatherargs = (
						'place'    => 'New York/Central Park, NY',
						'debug'    => 0,
						'language' => 'en',
	);

	my $wc = Weather::Com::Simple->new(%weatherargs);

	# define mock object
	my $mock = Test::MockObject->new();
	$mock->fake_module(
		'Weather::Com::Cached' => ( '_cache_time' => sub { return 1110000000 } ) );

	is_deeply( $wc->get_weather, $simpleWeather,
			   'Checking simple weather format.' );
}