google-geo 1.0 → 2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/CHANGELOG +5 -0
  2. data/README +12 -8
  3. data/lib/google/geo.rb +10 -6
  4. data/test/fixtures/invalid_map_key.xml +10 -0
  5. data/test/fixtures/missing_address.xml +10 -0
  6. data/test/fixtures/server_error.xml +10 -0
  7. data/test/fixtures/success.xml +36 -0
  8. data/test/fixtures/success_with_multiple_addresses.xml +62 -0
  9. data/test/fixtures/too_many_queries.xml +10 -0
  10. data/test/fixtures/unavailable_address.xml +10 -0
  11. data/test/fixtures/unknown_address.xml +10 -0
  12. data/test/geo_test.rb +19 -5
  13. data/vendor/mocha-0.4.0/COPYING +3 -0
  14. data/vendor/mocha-0.4.0/MIT-LICENSE +7 -0
  15. data/vendor/mocha-0.4.0/README +35 -0
  16. data/vendor/mocha-0.4.0/RELEASE +98 -0
  17. data/vendor/mocha-0.4.0/Rakefile +126 -0
  18. data/vendor/mocha-0.4.0/examples/misc.rb +36 -0
  19. data/vendor/mocha-0.4.0/examples/mocha.rb +26 -0
  20. data/vendor/mocha-0.4.0/examples/stubba.rb +65 -0
  21. data/vendor/mocha-0.4.0/lib/mocha.rb +19 -0
  22. data/vendor/mocha-0.4.0/lib/mocha/any_instance_method.rb +35 -0
  23. data/vendor/mocha-0.4.0/lib/mocha/auto_verify.rb +113 -0
  24. data/vendor/mocha-0.4.0/lib/mocha/central.rb +35 -0
  25. data/vendor/mocha-0.4.0/lib/mocha/class_method.rb +62 -0
  26. data/vendor/mocha-0.4.0/lib/mocha/expectation.rb +295 -0
  27. data/vendor/mocha-0.4.0/lib/mocha/expectation_error.rb +6 -0
  28. data/vendor/mocha-0.4.0/lib/mocha/infinite_range.rb +27 -0
  29. data/vendor/mocha-0.4.0/lib/mocha/inspect.rb +37 -0
  30. data/vendor/mocha-0.4.0/lib/mocha/instance_method.rb +8 -0
  31. data/vendor/mocha-0.4.0/lib/mocha/metaclass.rb +7 -0
  32. data/vendor/mocha-0.4.0/lib/mocha/mock.rb +20 -0
  33. data/vendor/mocha-0.4.0/lib/mocha/mock_methods.rb +122 -0
  34. data/vendor/mocha-0.4.0/lib/mocha/object.rb +100 -0
  35. data/vendor/mocha-0.4.0/lib/mocha/pretty_parameters.rb +28 -0
  36. data/vendor/mocha-0.4.0/lib/mocha/setup_and_teardown.rb +23 -0
  37. data/vendor/mocha-0.4.0/lib/mocha/standalone.rb +30 -0
  38. data/vendor/mocha-0.4.0/lib/mocha/test_case_adapter.rb +49 -0
  39. data/vendor/mocha-0.4.0/lib/mocha_standalone.rb +2 -0
  40. data/vendor/mocha-0.4.0/lib/stubba.rb +2 -0
  41. data/vendor/mocha-0.4.0/test/active_record_test_case.rb +36 -0
  42. data/vendor/mocha-0.4.0/test/all_tests.rb +75 -0
  43. data/vendor/mocha-0.4.0/test/execution_point.rb +34 -0
  44. data/vendor/mocha-0.4.0/test/method_definer.rb +18 -0
  45. data/vendor/mocha-0.4.0/test/mocha/any_instance_method_test.rb +124 -0
  46. data/vendor/mocha-0.4.0/test/mocha/auto_verify_test.rb +163 -0
  47. data/vendor/mocha-0.4.0/test/mocha/central_test.rb +124 -0
  48. data/vendor/mocha-0.4.0/test/mocha/class_method_test.rb +196 -0
  49. data/vendor/mocha-0.4.0/test/mocha/expectation_test.rb +357 -0
  50. data/vendor/mocha-0.4.0/test/mocha/infinite_range_test.rb +50 -0
  51. data/vendor/mocha-0.4.0/test/mocha/inspect_test.rb +90 -0
  52. data/vendor/mocha-0.4.0/test/mocha/metaclass_test.rb +22 -0
  53. data/vendor/mocha-0.4.0/test/mocha/mock_methods_test.rb +235 -0
  54. data/vendor/mocha-0.4.0/test/mocha/mock_test.rb +84 -0
  55. data/vendor/mocha-0.4.0/test/mocha/object_test.rb +165 -0
  56. data/vendor/mocha-0.4.0/test/mocha/pretty_parameters_test.rb +32 -0
  57. data/vendor/mocha-0.4.0/test/mocha/setup_and_teardown_test.rb +76 -0
  58. data/vendor/mocha-0.4.0/test/mocha_acceptance_test.rb +98 -0
  59. data/vendor/mocha-0.4.0/test/mocha_test_result_integration_test.rb +105 -0
  60. data/vendor/mocha-0.4.0/test/standalone_acceptance_test.rb +110 -0
  61. data/vendor/mocha-0.4.0/test/stubba_acceptance_test.rb +102 -0
  62. data/vendor/mocha-0.4.0/test/stubba_integration_test.rb +89 -0
  63. data/vendor/mocha-0.4.0/test/stubba_test_result_integration_test.rb +85 -0
  64. data/vendor/mocha-0.4.0/test/test_helper.rb +4 -0
  65. metadata +73 -3
@@ -0,0 +1,110 @@
1
+ require 'test_helper'
2
+ require 'mocha_standalone'
3
+
4
+ class NotATestUnitAssertionFailedError < StandardError
5
+ end
6
+
7
+ class NotATestUnitTestCase
8
+
9
+ include Mocha::Standalone
10
+
11
+ attr_reader :assertion_count
12
+
13
+ def initialize
14
+ @assertion_count = 0
15
+ end
16
+
17
+ def run(test_method)
18
+ mocha_setup
19
+ begin
20
+ prepare
21
+ begin
22
+ send(test_method)
23
+ mocha_verify { @assertion_count += 1 }
24
+ rescue Mocha::ExpectationError => e
25
+ new_error = NotATestUnitAssertionFailedError.new(e.message)
26
+ new_error.set_backtrace(e.backtrace)
27
+ raise new_error
28
+ ensure
29
+ cleanup
30
+ end
31
+ ensure
32
+ mocha_teardown
33
+ end
34
+ end
35
+
36
+ def prepare
37
+ end
38
+
39
+ def cleanup
40
+ end
41
+
42
+ end
43
+
44
+ class SampleTest < NotATestUnitTestCase
45
+
46
+ def mocha_with_fulfilled_expectation
47
+ mockee = mock()
48
+ mockee.expects(:blah)
49
+ mockee.blah
50
+ end
51
+
52
+ def mocha_with_unfulfilled_expectation
53
+ mockee = mock()
54
+ mockee.expects(:blah)
55
+ end
56
+
57
+ def mocha_with_unexpected_invocation
58
+ mockee = mock()
59
+ mockee.blah
60
+ end
61
+
62
+ def stubba_with_fulfilled_expectation
63
+ stubbee = Class.new { define_method(:blah) {} }.new
64
+ stubbee.expects(:blah)
65
+ stubbee.blah
66
+ end
67
+
68
+ def stubba_with_unfulfilled_expectation
69
+ stubbee = Class.new { define_method(:blah) {} }.new
70
+ stubbee.expects(:blah)
71
+ end
72
+
73
+ end
74
+
75
+ require 'test/unit'
76
+
77
+ class StandaloneAcceptanceTest < Test::Unit::TestCase
78
+
79
+ attr_reader :sample_test
80
+
81
+ def setup
82
+ @sample_test = SampleTest.new
83
+ end
84
+
85
+ def test_should_pass_mocha_test
86
+ assert_nothing_raised { sample_test.run(:mocha_with_fulfilled_expectation) }
87
+ assert_equal 1, sample_test.assertion_count
88
+ end
89
+
90
+ def test_should_fail_mocha_test_due_to_unfulfilled_exception
91
+ assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:mocha_with_unfulfilled_expectation) }
92
+ assert_equal 1, sample_test.assertion_count
93
+ end
94
+
95
+ def test_should_fail_mocha_test_due_to_unexpected_invocation
96
+ assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:mocha_with_unexpected_invocation) }
97
+ assert_equal 0, sample_test.assertion_count
98
+ end
99
+
100
+ def test_should_pass_stubba_test
101
+ assert_nothing_raised { sample_test.run(:stubba_with_fulfilled_expectation) }
102
+ assert_equal 1, sample_test.assertion_count
103
+ end
104
+
105
+ def test_should_fail_stubba_test
106
+ assert_raises(NotATestUnitAssertionFailedError) { sample_test.run(:stubba_with_unfulfilled_expectation) }
107
+ assert_equal 1, sample_test.assertion_count
108
+ end
109
+
110
+ end
@@ -0,0 +1,102 @@
1
+ require 'test_helper'
2
+ require 'mocha'
3
+
4
+ class Widget
5
+
6
+ def model
7
+ 'original_model'
8
+ end
9
+
10
+ class << self
11
+
12
+ def find(options)
13
+ []
14
+ end
15
+
16
+ def create(attributes)
17
+ Widget.new
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ module Thingy
25
+
26
+ def self.wotsit
27
+ :hoojamaflip
28
+ end
29
+
30
+ end
31
+
32
+ class StubbaAcceptanceTest < Test::Unit::TestCase
33
+
34
+ def test_should_stub_instance_method
35
+ widget = Widget.new
36
+ widget.expects(:model).returns('different_model')
37
+ assert_equal 'different_model', widget.model
38
+ end
39
+
40
+ def test_should_stub_module_method
41
+ should_stub_module_method
42
+ end
43
+
44
+ def test_should_stub_module_method_again
45
+ should_stub_module_method
46
+ end
47
+
48
+ def test_should_stub_class_method
49
+ should_stub_class_method
50
+ end
51
+
52
+ def test_should_stub_class_method_again
53
+ should_stub_class_method
54
+ end
55
+
56
+ def test_should_stub_instance_method_on_any_instance_of_a_class
57
+ should_stub_instance_method_on_any_instance_of_a_class
58
+ end
59
+
60
+ def test_should_stub_instance_method_on_any_instance_of_a_class_again
61
+ should_stub_instance_method_on_any_instance_of_a_class
62
+ end
63
+
64
+ def test_should_stub_two_different_class_methods
65
+ should_stub_two_different_class_methods
66
+ end
67
+
68
+ def test_should_stub_two_different_class_methods_again
69
+ should_stub_two_different_class_methods
70
+ end
71
+
72
+ private
73
+
74
+ def should_stub_module_method
75
+ Thingy.expects(:wotsit).returns(:dooda)
76
+ assert_equal :dooda, Thingy.wotsit
77
+ end
78
+
79
+ def should_stub_class_method
80
+ widgets = [Widget.new]
81
+ Widget.expects(:find).with(:all).returns(widgets)
82
+ assert_equal widgets, Widget.find(:all)
83
+ end
84
+
85
+ def should_stub_two_different_class_methods
86
+ found_widgets = [Widget.new]
87
+ created_widget = Widget.new
88
+ Widget.expects(:find).with(:all).returns(found_widgets)
89
+ Widget.expects(:create).with(:model => 'wombat').returns(created_widget)
90
+ assert_equal found_widgets, Widget.find(:all)
91
+ assert_equal created_widget, Widget.create(:model => 'wombat')
92
+ end
93
+
94
+ def should_stub_instance_method_on_any_instance_of_a_class
95
+ Widget.any_instance.expects(:model).at_least_once.returns('another_model')
96
+ widget_1 = Widget.new
97
+ widget_2 = Widget.new
98
+ assert_equal 'another_model', widget_1.model
99
+ assert_equal 'another_model', widget_2.model
100
+ end
101
+
102
+ end
@@ -0,0 +1,89 @@
1
+ require 'test_helper'
2
+
3
+ require 'mocha/object'
4
+ require 'mocha/test_case_adapter'
5
+ require 'mocha/standalone'
6
+
7
+ class StubbaIntegrationTest < Test::Unit::TestCase
8
+
9
+ class DontMessWithMe
10
+ def self.my_class_method
11
+ :original_return_value
12
+ end
13
+ def my_instance_method
14
+ :original_return_value
15
+ end
16
+ end
17
+
18
+ def test_should_stub_class_method_within_test
19
+ test = build_test do
20
+ DontMessWithMe.expects(:my_class_method).returns(:new_return_value)
21
+ assert_equal :new_return_value, DontMessWithMe.my_class_method
22
+ end
23
+
24
+ test_result = Test::Unit::TestResult.new
25
+ test.run(test_result) {}
26
+ assert test_result.passed?
27
+ end
28
+
29
+ def test_should_leave_stubbed_class_method_unchanged_after_test
30
+ test = build_test do
31
+ DontMessWithMe.expects(:my_class_method).returns(:new_return_value)
32
+ end
33
+
34
+ test.run(Test::Unit::TestResult.new) {}
35
+ assert_equal :original_return_value, DontMessWithMe.my_class_method
36
+ end
37
+
38
+ def test_should_reset_class_expectations_after_test
39
+ test = build_test do
40
+ DontMessWithMe.expects(:my_class_method)
41
+ end
42
+
43
+ test.run(Test::Unit::TestResult.new) {}
44
+ assert_equal 0, DontMessWithMe.mocha.expectations.size
45
+ end
46
+
47
+ def test_should_stub_instance_method_within_test
48
+ instance = DontMessWithMe.new
49
+ test = build_test do
50
+ instance.expects(:my_instance_method).returns(:new_return_value)
51
+ assert_equal :new_return_value, instance.my_instance_method
52
+ end
53
+ test_result = Test::Unit::TestResult.new
54
+ test.run(test_result) {}
55
+ assert test_result.passed?
56
+ end
57
+
58
+ def test_should_leave_stubbed_instance_method_unchanged_after_test
59
+ instance = DontMessWithMe.new
60
+ test = build_test do
61
+ instance.expects(:my_instance_method).returns(:new_return_value)
62
+ end
63
+
64
+ test.run(Test::Unit::TestResult.new) {}
65
+ assert_equal :original_return_value, instance.my_instance_method
66
+ end
67
+
68
+ def test_should_reset_instance_expectations_after_test
69
+ instance = DontMessWithMe.new
70
+ test = build_test do
71
+ instance.expects(:my_instance_method).returns(:new_return_value)
72
+ end
73
+
74
+ test.run(Test::Unit::TestResult.new) {}
75
+ assert_equal 0, instance.mocha.expectations.size
76
+ end
77
+
78
+ private
79
+
80
+ def build_test(&block)
81
+ test_class = Class.new(Test::Unit::TestCase) do
82
+ include Mocha::Standalone
83
+ include Mocha::TestCaseAdapter
84
+ define_method(:test_me, &block)
85
+ end
86
+ test_class.new(:test_me)
87
+ end
88
+
89
+ end
@@ -0,0 +1,85 @@
1
+ require 'test_helper'
2
+ require 'mocha/object'
3
+ require 'mocha/standalone'
4
+ require 'mocha/test_case_adapter'
5
+ require 'execution_point'
6
+
7
+ class StubbaTestResultIntegrationTest < Test::Unit::TestCase
8
+
9
+ def test_should_include_expectation_verification_in_assertion_count
10
+ test_result = run_test do
11
+ object = Class.new { def message; end }.new
12
+ object.expects(:message)
13
+ object.message
14
+ end
15
+ assert_equal 1, test_result.assertion_count
16
+ end
17
+
18
+ def test_should_include_assertions_in_assertion_count
19
+ test_result = run_test do
20
+ assert true
21
+ end
22
+ assert_equal 1, test_result.assertion_count
23
+ end
24
+
25
+ def test_should_not_include_stubbing_expectation_verification_in_assertion_count
26
+ test_result = run_test do
27
+ object = Class.new { def message; end }.new
28
+ object.stubs(:message)
29
+ object.message
30
+ end
31
+ assert_equal 0, test_result.assertion_count
32
+ end
33
+
34
+ def test_should_include_expectation_verification_failure_in_failure_count
35
+ test_result = run_test do
36
+ object = Class.new { def message; end }.new
37
+ object.expects(:message)
38
+ end
39
+ assert_equal 1, test_result.failure_count
40
+ end
41
+
42
+ def test_should_include_assertion_failure_in_failure_count
43
+ test_result = run_test do
44
+ flunk
45
+ end
46
+ assert_equal 1, test_result.failure_count
47
+ end
48
+
49
+ def test_should_display_backtrace_indicating_line_number_where_expects_was_called
50
+ test_result = Test::Unit::TestResult.new
51
+ faults = []
52
+ test_result.add_listener(Test::Unit::TestResult::FAULT, &lambda { |fault| faults << fault })
53
+ execution_point = nil
54
+ run_test(test_result) do
55
+ object = Class.new { def message; end }.new
56
+ execution_point = ExecutionPoint.current; object.expects(:message)
57
+ end
58
+ assert_equal 1, faults.size
59
+ assert_equal execution_point, ExecutionPoint.new(faults.first.location)
60
+ end
61
+
62
+ def test_should_display_backtrace_indicating_line_number_where_failing_assertion_was_called
63
+ test_result = Test::Unit::TestResult.new
64
+ faults = []
65
+ test_result.add_listener(Test::Unit::TestResult::FAULT, &lambda { |fault| faults << fault })
66
+ execution_point = nil
67
+ run_test(test_result) do
68
+ execution_point = ExecutionPoint.current; flunk
69
+ end
70
+ assert_equal 1, faults.size
71
+ assert_equal execution_point, ExecutionPoint.new(faults.first.location)
72
+ end
73
+
74
+ def run_test(test_result = Test::Unit::TestResult.new, &block)
75
+ test_class = Class.new(Test::Unit::TestCase) do
76
+ include Mocha::Standalone
77
+ include Mocha::TestCaseAdapter
78
+ define_method(:test_me, &block)
79
+ end
80
+ test = test_class.new(:test_me)
81
+ test.run(test_result) {}
82
+ test_result
83
+ end
84
+
85
+ end
@@ -0,0 +1,4 @@
1
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
2
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__)))
3
+
4
+ require 'test/unit'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: google-geo
5
5
  version: !ruby/object:Gem::Version
6
- version: "1.0"
7
- date: 2007-05-24 00:00:00 -07:00
6
+ version: "2.0"
7
+ date: 2007-07-23 00:00:00 -07:00
8
8
  summary: A simple, elegant library for getting geocoding information from Google Maps. Very much inspired by the google-geocode gem, but completely dependency free!
9
9
  require_paths:
10
10
  - lib
@@ -27,10 +27,80 @@ signing_key:
27
27
  cert_chain:
28
28
  post_install_message:
29
29
  authors:
30
- - " \n"
30
+ - |
31
+
32
+
31
33
  files:
32
34
  - lib/google
33
35
  - lib/google/geo.rb
36
+ - test/fixtures
37
+ - test/fixtures/invalid_map_key.xml
38
+ - test/fixtures/missing_address.xml
39
+ - test/fixtures/server_error.xml
40
+ - test/fixtures/success.xml
41
+ - test/fixtures/success_with_multiple_addresses.xml
42
+ - test/fixtures/too_many_queries.xml
43
+ - test/fixtures/unavailable_address.xml
44
+ - test/fixtures/unknown_address.xml
45
+ - test/geo_test.rb
46
+ - vendor/mocha-0.4.0
47
+ - vendor/mocha-0.4.0/COPYING
48
+ - vendor/mocha-0.4.0/examples
49
+ - vendor/mocha-0.4.0/examples/misc.rb
50
+ - vendor/mocha-0.4.0/examples/mocha.rb
51
+ - vendor/mocha-0.4.0/examples/stubba.rb
52
+ - vendor/mocha-0.4.0/lib
53
+ - vendor/mocha-0.4.0/lib/mocha
54
+ - vendor/mocha-0.4.0/lib/mocha/any_instance_method.rb
55
+ - vendor/mocha-0.4.0/lib/mocha/auto_verify.rb
56
+ - vendor/mocha-0.4.0/lib/mocha/central.rb
57
+ - vendor/mocha-0.4.0/lib/mocha/class_method.rb
58
+ - vendor/mocha-0.4.0/lib/mocha/expectation.rb
59
+ - vendor/mocha-0.4.0/lib/mocha/expectation_error.rb
60
+ - vendor/mocha-0.4.0/lib/mocha/infinite_range.rb
61
+ - vendor/mocha-0.4.0/lib/mocha/inspect.rb
62
+ - vendor/mocha-0.4.0/lib/mocha/instance_method.rb
63
+ - vendor/mocha-0.4.0/lib/mocha/metaclass.rb
64
+ - vendor/mocha-0.4.0/lib/mocha/mock.rb
65
+ - vendor/mocha-0.4.0/lib/mocha/mock_methods.rb
66
+ - vendor/mocha-0.4.0/lib/mocha/object.rb
67
+ - vendor/mocha-0.4.0/lib/mocha/pretty_parameters.rb
68
+ - vendor/mocha-0.4.0/lib/mocha/setup_and_teardown.rb
69
+ - vendor/mocha-0.4.0/lib/mocha/standalone.rb
70
+ - vendor/mocha-0.4.0/lib/mocha/test_case_adapter.rb
71
+ - vendor/mocha-0.4.0/lib/mocha.rb
72
+ - vendor/mocha-0.4.0/lib/mocha_standalone.rb
73
+ - vendor/mocha-0.4.0/lib/stubba.rb
74
+ - vendor/mocha-0.4.0/MIT-LICENSE
75
+ - vendor/mocha-0.4.0/Rakefile
76
+ - vendor/mocha-0.4.0/README
77
+ - vendor/mocha-0.4.0/RELEASE
78
+ - vendor/mocha-0.4.0/test
79
+ - vendor/mocha-0.4.0/test/active_record_test_case.rb
80
+ - vendor/mocha-0.4.0/test/all_tests.rb
81
+ - vendor/mocha-0.4.0/test/execution_point.rb
82
+ - vendor/mocha-0.4.0/test/method_definer.rb
83
+ - vendor/mocha-0.4.0/test/mocha
84
+ - vendor/mocha-0.4.0/test/mocha/any_instance_method_test.rb
85
+ - vendor/mocha-0.4.0/test/mocha/auto_verify_test.rb
86
+ - vendor/mocha-0.4.0/test/mocha/central_test.rb
87
+ - vendor/mocha-0.4.0/test/mocha/class_method_test.rb
88
+ - vendor/mocha-0.4.0/test/mocha/expectation_test.rb
89
+ - vendor/mocha-0.4.0/test/mocha/infinite_range_test.rb
90
+ - vendor/mocha-0.4.0/test/mocha/inspect_test.rb
91
+ - vendor/mocha-0.4.0/test/mocha/metaclass_test.rb
92
+ - vendor/mocha-0.4.0/test/mocha/mock_methods_test.rb
93
+ - vendor/mocha-0.4.0/test/mocha/mock_test.rb
94
+ - vendor/mocha-0.4.0/test/mocha/object_test.rb
95
+ - vendor/mocha-0.4.0/test/mocha/pretty_parameters_test.rb
96
+ - vendor/mocha-0.4.0/test/mocha/setup_and_teardown_test.rb
97
+ - vendor/mocha-0.4.0/test/mocha_acceptance_test.rb
98
+ - vendor/mocha-0.4.0/test/mocha_test_result_integration_test.rb
99
+ - vendor/mocha-0.4.0/test/standalone_acceptance_test.rb
100
+ - vendor/mocha-0.4.0/test/stubba_acceptance_test.rb
101
+ - vendor/mocha-0.4.0/test/stubba_integration_test.rb
102
+ - vendor/mocha-0.4.0/test/stubba_test_result_integration_test.rb
103
+ - vendor/mocha-0.4.0/test/test_helper.rb
34
104
  - README
35
105
  - CHANGELOG
36
106
  test_files: