Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #296 from lulalala/fix-spec
Browse files Browse the repository at this point in the history
Spec to test Rails 5.1 and convert to request spec
  • Loading branch information
wingrunr21 authored Apr 23, 2018
2 parents 56daba8 + eebdbcd commit 543033a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
- "RAILS_BRANCH=4-1-stable"
- "RAILS_BRANCH=4-2-stable"
- "RAILS_BRANCH=5-0-stable"
- "RAILS_BRANCH=5-1-stable"
- "RAILS_BRANCH=master"
branches:
only:
Expand Down
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
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 543033a

Please sign in to comment.