I want to replace the array of ips with a method (like known_ips
or just ips
) but I don't know how.
I'll use this known_ips
somewhere else.
describe WelcomeController, type: :controller do
[
{
ip: '73.53.61.23',
location_name: 'Seattle, Washington, US'
}, {
ip: '8.26.157.16',
location_name: 'San Francisco, California, US'
}, {
ip: '174.112.13.21',
location_name: 'Mississauga, Ontario, CA'
}
].each do |params|
it 'geolocalizes the visitor based on the ip' do
allow_any_instance_of(ActionDispatch::Request).to receive(:remote_ip).and_return params[:ip]
get :index
expect(controller.current_location.name).to eq params[:location_name]
end
end
end
allow_any_instance_of(ActionDispatch::Request).to_receive
withexpect(controller.request).to_receive
\$\endgroup\$