11
이 간단한 테스트를 RSpec 2.8로 전달하는 데 문제가 있습니다.매개 변수가있는 메소드에서 RSpec 테스트 ArgumentError
(ArgumentError : 잘못된 인수 수 ('x'가 'y'인 경우)) 매개 변수 부재에 대한 간단한 테스트를 작성하고 싶습니다.
내 시험 때문에 같은 보석 모듈 방식을 테스트 :
describe "#ip_lookup" do
it "should raise an ArgumentError error if no parameters passed" do
expect(@geolocater.ip_lookup).to raise_error(ArgumentError)
end
end
내 보석 모듈 코드는 다음과 같습니다
module Geolocater
def ip_lookup(ip_address)
return ip_address
end
end
내 사양이 출력으로 실행됩니다.
Failure/Error: expect(@geolocater.ip_lookup).to raise_error(ArgumentError)
ArgumentError:
wrong number of arguments (0 for 1)
# ./lib/geolocater.rb:4:in `ip_lookup'
# ./spec/geolocater_spec.rb:28:in `block (3 levels) in <top (required)>'
무엇이 여기에 있습니까?
감사합니다! 이것은 훌륭하게 작동했습니다! – thoughtpunch
고마워요! 2013 년에도 여전히 효과가 있습니다. –
2014 년에도 마찬가지입니다.) – macsig