1
- $: << File . dirname ( __FILE__ ) +"/../lib"
2
-
3
- require 'test/unit'
4
- require 'address_extractor.rb'
5
- require 'test_helper.rb'
1
+ require 'address_extractor'
2
+ require 'test_helper'
6
3
include TestDataHelper
7
4
8
5
class AddressExtractorTest < Test ::Unit ::TestCase
9
- include Helpers
10
-
11
6
def test_first_address_extraction
12
7
each_test_data do |test_data |
13
8
address = AddressExtractor . first_address ( test_data [ :input ] )
14
9
flunk "No address found in:\n #{ test_data [ :input ] } " if address . nil?
15
10
assert_equal_hashes address , test_data [ :expected_output ] . first
16
11
end
17
12
end
18
-
13
+
19
14
def test_find_addresses
20
15
each_test_data do |test_data |
21
16
addresses = AddressExtractor . find_addresses ( test_data [ :input ] )
@@ -25,11 +20,11 @@ def test_find_addresses
25
20
end
26
21
end
27
22
end
28
-
23
+
29
24
def test_replace_first_address
30
25
string = AddressExtractor . replace_first_address ( test_data . first [ :input ] ) do |address_hash , address |
31
26
assert_equal_hashes address_hash , test_data . first [ :expected_output ] . first
32
- assert_match /^\s *123 Foo St., Someplace FL\s */ , address
27
+ assert_match /^\s *123 Foo St., Someplace FL\s */ , address
33
28
"skidoosh"
34
29
end
35
30
assert string =~ /Please send the package to skidoosh/
@@ -70,7 +65,7 @@ def test_no_addresses_found
70
65
71
66
test_input "Let's meet tomorrow at noon at 123 Foo Bar Street, Scooby, NY 12345" ,
72
67
{ :street1 => "123 Foo Bar Street" , :street2 => nil , :city => "Scooby" , :state => "NY" , :zip => "12345" }
73
-
68
+
74
69
test_input "Let's meet tomorrow at noon at 123 Foo Bar Street, Scooby, NY, 12345" ,
75
70
{ :street1 => "123 Foo Bar Street" , :street2 => nil , :city => "Scooby" , :state => "NY" , :zip => "12345" }
76
71
@@ -85,4 +80,4 @@ def test_no_addresses_found
85
80
86
81
test_input "Apple Computer, Inc. 1 Infinite Loop, Cupertino, CA 95014" ,
87
82
{ :street1 => "1 Infinite Loop" , :street2 => nil , :city => "Cupertino" , :state => "CA" , :zip => "95014" }
88
-
83
+
0 commit comments