2024-06-07 10:06:40 +02:00
|
|
|
describe EmailCheckerController, type: :controller do
|
|
|
|
describe '#show' do
|
|
|
|
render_views
|
|
|
|
before { get :show, format: :json, params: params }
|
|
|
|
let(:body) { JSON.parse(response.body, symbolize_names: true) }
|
|
|
|
|
|
|
|
context 'valid email' do
|
|
|
|
let(:params) { { email: 'martin@orange.fr' } }
|
|
|
|
it do
|
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
expect(body).to eq({ success: true })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'email with typo' do
|
|
|
|
let(:params) { { email: 'martin@orane.fr' } }
|
|
|
|
it do
|
|
|
|
expect(response).to have_http_status(:success)
|
2024-07-01 10:38:43 +02:00
|
|
|
expect(body).to eq({ success: true, suggestions: ['martin@orange.fr'] })
|
2024-06-07 10:06:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'empty' do
|
|
|
|
let(:params) { { email: '' } }
|
|
|
|
it do
|
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
expect(body).to eq({ success: false })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'notanemail' do
|
|
|
|
let(:params) { { email: 'clarkkent' } }
|
|
|
|
it do
|
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
expect(body).to eq({ success: false })
|
|
|
|
end
|
|
|
|
end
|
2024-06-17 13:25:28 +02:00
|
|
|
|
|
|
|
context 'incomplete' do
|
|
|
|
let(:params) { { email: 'bikram.subedi81@' } }
|
|
|
|
it do
|
|
|
|
expect(response).to have_http_status(:success)
|
|
|
|
expect(body).to eq({ success: false })
|
|
|
|
end
|
|
|
|
end
|
2024-06-07 10:06:40 +02:00
|
|
|
end
|
|
|
|
end
|