Skip to content

Commit

Permalink
Merge pull request #6 from svoop/fix_rspec_and_location
Browse files Browse the repository at this point in the history
Fix branch/location/country validation (serious bug!)
  • Loading branch information
Frank C. Eckert committed Dec 21, 2015
2 parents e05e5a8 + 3e2ecdc commit d770ad9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- ruby-head
- jruby-19mode
- jruby-head
- rbx-2.1.1
- rbx-2.6
script: rspec
1 change: 1 addition & 0 deletions bic_validation.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Gem::Specification.new do |gem|
gem.add_dependency 'activesupport'
gem.add_dependency 'banking_data'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'rspec-its'
gem.add_development_dependency 'coveralls'
gem.add_development_dependency 'pry'
gem.add_development_dependency 'rubocop'
Expand Down
6 changes: 3 additions & 3 deletions lib/bic_validation/bic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def has_valid_country_code?
country_codes.include? country
end

def has_valid_branch_code?
def has_valid_location_code?
# WTF? http://de.wikipedia.org/wiki/ISO_9362
country[0] =~ /[^01]/ && country[1] =~ /[^O]/
location[0] =~ /[^01]/ && location[1] =~ /[^O]/
end

def known?
Expand All @@ -34,7 +34,7 @@ def valid?
of_valid_length? &&
of_valid_format? &&
has_valid_country_code? &&
has_valid_branch_code?
has_valid_location_code?
end

def invalid?
Expand Down
2 changes: 1 addition & 1 deletion spec/bic_validation/bic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module BicValidation
end

['DEUTDEBB', 'CRESCHZZ10S', 'UBSWCHZH86N', 'OEKOATWWXXX',
'OEKOATWW'].each do |swift|
'OEKOATWW', 'BTRLRO22'].each do |swift|
describe 'validity checks' do
it "validates #{swift}" do
bic = Bic.new(swift)
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'simplecov'
require 'coveralls'
require 'pry'
require 'rspec/its'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
Expand Down

0 comments on commit d770ad9

Please sign in to comment.