This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from lulalala/fix-spec
Spec to test Rails 5.1 and convert to request spec
- Loading branch information
Showing
2 changed files
with
10 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
require 'spec_helper' | ||
|
||
describe Griddler::EmailsController, :type => :controller do | ||
RSpec.describe 'Receiving Email', type: :request do | ||
before(:each) do | ||
fake_adapter = double(normalize_params: normalized_params) | ||
Griddler.adapter_registry.register(:one_that_works, fake_adapter) | ||
Griddler.configuration.email_service = :one_that_works | ||
end | ||
|
||
describe 'POST create', type: :controller do | ||
let(:path) { '/email_processor' } | ||
|
||
describe 'POST create' do | ||
it 'is successful' do | ||
post :create, email_params | ||
post path, params: email_params | ||
|
||
expect(response).to be_success | ||
expect(response).to be_successful | ||
end | ||
|
||
it 'creates a new Griddler::Email with the given params' do | ||
|
@@ -20,15 +22,15 @@ | |
with(hash_including(to: ['[email protected]'])). | ||
and_return(email) | ||
|
||
post :create, { to: '[email protected]' } | ||
post path, params: { to: '[email protected]' } | ||
end | ||
|
||
it 'calls process on the custom processor class' do | ||
my_handler = double(process: nil) | ||
expect(my_handler).to receive(:new).and_return(my_handler) | ||
allow(Griddler.configuration).to receive_messages(processor_class: my_handler) | ||
|
||
post :create, email_params | ||
post path, params: email_params | ||
end | ||
|
||
it 'calls the custom processor method on the processor class' do | ||
|
@@ -38,7 +40,7 @@ | |
expect(EmailProcessor).to receive(:new).and_return(fake_processor) | ||
expect(fake_processor).to receive(:perform) | ||
|
||
post :create, email_params | ||
post path, params: email_params | ||
end | ||
end | ||
|
||
|