Created
July 15, 2009 21:17
-
-
Save zegomesjf/148004 to your computer and use it in GitHub Desktop.
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
require 'validate_entry_state' | |
describe Entry_State do | |
it "should be invalid without a number" do | |
entry_state = Entry_State.new(nil, "PR") | |
entry_state.should_not be_valid | |
end | |
it "should be invalid without a state" do | |
entry_state = Entry_State.new("123456789", nil) | |
entry_state.should_not be_valid | |
end | |
it "should be valid with a state and number valid" do | |
entry_state = Entry_State.new("4140011229", "PR") | |
entry_state.should be_valid | |
end | |
it "should be invalid with a state or number invalid" do | |
entry_state = Entry_State.new("1234546", "PR") | |
entry_state.should_not be_valid | |
end | |
end |
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
#Validar Inscrição Estadual de todos os estados brasileiros usando DLL do Sintegra. | |
require 'Win32API' | |
class Entry_State | |
def initialize(number, state) | |
@number = number | |
@state = state | |
end | |
def valid? | |
if @number and @state | |
obj = Win32API.new("DllInscE32", "ConsisteInscricaoEstadual", ['P', 'P'], 'I') | |
if obj.call(@number, @state) == 0 | |
true | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment