open-charities 0.0.1 → 0.0.2

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.
data/README.md CHANGED
@@ -10,7 +10,7 @@ $ gem install open-charities
10
10
  ```
11
11
  or as a dependency in a Gemfile
12
12
  ```ruby
13
- gem "open-charities", "~> 0.1.0", require: 'open_charities'
13
+ gem "open-charities", "~> 0.2.0", require: 'open_charities'
14
14
  ```
15
15
 
16
16
  ## Usage
@@ -25,8 +25,9 @@ module OpenCharities
25
25
  def validate(reg_number)
26
26
  number = reg_number.to_s.strip
27
27
 
28
- # match 7-digit numbers *only*
29
- charities_regex = Regexp.new("\\A\\d{7}\\z")
28
+ # match any 6/7 digit number OR 6/7 digit number followed by a dash and
29
+ # another 1 or 2 numbers
30
+ charities_regex = /\A\d{6,7}\z|\A\d{6,7}\-\d{1,2}\z/
30
31
 
31
32
  msg = "#{number} is not a valid UK charity registration number"
32
33
  raise InvalidRegistration.new(msg) unless number =~ charities_regex
@@ -1,3 +1,3 @@
1
1
  module OpenCharities
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
@@ -6,16 +6,12 @@ describe OpenCharities::Request do
6
6
 
7
7
  describe "#new" do
8
8
  context "throws an exception" do
9
- it "with a number that's too short" do
10
- expect {
11
- subject.new "123456"
12
- }.to raise_exception OpenCharities::InvalidRegistration
13
- end
14
-
15
- it "that's too long" do
16
- expect {
17
- subject.new "12345678"
18
- }.to raise_exception OpenCharities::InvalidRegistration
9
+ %W(12345 12345678 #{"123 ABC"} #{"123?!56"}).each do |n|
10
+ specify do
11
+ expect {
12
+ subject.new n
13
+ }.to raise_exception OpenCharities::InvalidRegistration
14
+ end
19
15
  end
20
16
 
21
17
  it "that's nil" do
@@ -23,20 +19,15 @@ describe OpenCharities::Request do
23
19
  subject.new nil
24
20
  }.to raise_exception OpenCharities::InvalidRegistration
25
21
  end
22
+ end
26
23
 
27
- it "that contains spaces" do
28
- expect {
29
- subject.new "1234 ABC"
30
- }.to raise_exception OpenCharities::InvalidRegistration
31
- end
32
-
33
- it "that contains non alphanumeric chars" do
34
- expect {
35
- subject.new "1234?456"
36
- }.to raise_exception OpenCharities::InvalidRegistration
24
+ context 'is valid' do
25
+ %w(123456 1234567 123456-1 1234567-1 123456-12 1234567-12).each do |n|
26
+ specify do
27
+ expect { subject.new(n) }.to_not raise_exception
28
+ end
37
29
  end
38
30
  end
39
-
40
31
  end
41
32
 
42
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open-charities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-27 00:00:00.000000000 Z
12
+ date: 2013-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec