forked from threedaymonk/uk_postcode
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests to run against sample lists of postcodes. If you have the PostZ…
…on file, you can generate a list and put it in test/samples/postzon.list to test against it.
- Loading branch information
1 parent
16182e3
commit 95f0b6e
Showing
4 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test/samples/postzon.list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Special postcodes listed in http://en.wikipedia.org/wiki/UK_postcode | ||
|
||
SW1A 0AA | ||
SW1A 1AA | ||
SW1A 2AA | ||
BS98 1TL | ||
BX1 1LT | ||
BX5 5AT | ||
CF99 1NA | ||
DH99 1NS | ||
E16 1XL | ||
E98 1NW | ||
E98 1SN | ||
E98 1ST | ||
E98 1TT | ||
EC4Y 0HQ | ||
EH99 1SP | ||
EN8 9SL | ||
G58 1SB | ||
GIR 0AA | ||
L30 4GB | ||
LS98 1FD | ||
M2 5BE | ||
N81 1ER | ||
S2 4SU | ||
S6 1SW | ||
SE1 8UJ | ||
SE9 2UG | ||
SN38 1NW | ||
SW1A 0PW | ||
SW1A 2HQ | ||
SW1W 0DT | ||
TS1 3BA | ||
W1A 1AA | ||
W1F 9DJ | ||
GIR 0AA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
$:.unshift File.join(File.dirname(__FILE__), "..", "lib") | ||
require "test/unit" | ||
require "shoulda" | ||
require "uk_postcode" | ||
|
||
class UKPostcodeTest < Test::Unit::TestCase | ||
|
||
Dir[File.join(File.dirname(__FILE__), "samples", "*.list")].each do |path| | ||
context "in sample file #{File.basename(path, ".list")}" do | ||
setup do | ||
@file = open(path) | ||
end | ||
|
||
teardown do | ||
@file.close | ||
end | ||
|
||
should "be valid for each line in sample file" do | ||
@file.each_line do |line| | ||
next if line =~ /^#|^$/ | ||
sample = line.chomp.sub(/\s+/, "") | ||
postcode = UKPostcode.new(sample) | ||
assert postcode.valid?, "'#{sample}' should be valid" | ||
end | ||
end | ||
end | ||
end | ||
end |