저는 rspec 테스트를 처음 접했고 사용자 위치를 테스트하는 데 문제가 있습니다. 이것은 특정 지역의 스팸을 차단하기 위해 country_code의 행동을 조롱하는 테스트입니다. 수변수를 rspec 테스트에 전달
Failures:
1) GeocodeUserAuthorizer with a user connecting from an authorized country Failure/Error: it { expect(GeocodeUserAuthorizer.new.authorize!(user_country_code: { "CA" })).to eql(true) } ArgumentError: missing keyword: user_country_code # ./app/services/geocode_user_authorizer.rb:2:in
initialize' # ./spec/services/geocode_user_authorizer_spec.rb:16:in
new' # ./spec/services/geocode_user_authorizer_spec.rb:16:inblock (3 levels) in <top (required)>' # ./spec/spec_helper.rb:56:in
block (3 levels) in ' # ./spec/spec_helper.rb:56:in `block (2 levels) in '
: 오류 코드 여기
require 'spec_helper'
describe GeocodeUserAuthorizer do
context 'with a user connecting from an authorized country' do
it { expect(GeocodeUserAuthorizer.new.authorize!(user_country_code: { "CA" })).to eql(true) }
end
end
을 그리고있다 : 여기
class GeocodeUserAuthorizer
def initialize(user_country_code:)
@user_country_code = user_country_code
end
def authorize!
user_continent = ISO3166::Country.new(user_country_code).continent
if user_continent == 'Africa'
return true
else
return false
end
end
end
내 사양 파일의 코드는 다음과 같습니다
내 서비스의 코드 아무도 도와주지?