Skip to content

Instantly share code, notes, and snippets.

@zegomesjf
Created July 15, 2009 21:17
Show Gist options
  • Save zegomesjf/148004 to your computer and use it in GitHub Desktop.
Save zegomesjf/148004 to your computer and use it in GitHub Desktop.
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
#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