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

Commit

Permalink
Convert specs to RSpec 3.0.2 syntax with Transpec
Browse files Browse the repository at this point in the history
This conversion is done by Transpec 1.13.1 with the following command:
    transpec

* 73 conversions
    from: obj.should
      to: expect(obj).to

Convert specs to RSpec 3.0.2 syntax with Transpec

This conversion is done by Transpec 2.3.1 with the following command:
    transpec -f

* 6 conversions
    from: obj.stub(:message => value)
      to: allow(obj).to receive_messages(:message => value)

* 5 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 1 conversion
    from: describe 'some controller' { }
      to: describe 'some controller', :type => :controller { }

For more details: https://github.com/yujinakayama/transpec#supported-conversions
  • Loading branch information
petergoldstein authored and calebhearth committed Jun 24, 2014
1 parent e5783ec commit 47ab10f
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 91 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## 1.0.0

* Convert test suite, including Griddler::Testing, to expect syntax for RSpec
3.0 compliance. https://github.com/thoughtbot/griddler/pull/160

*Peter Goldstein*

* Use instances of email processor classes rather than calling class methods.
https://github.com/thoughtbot/griddler/pull/153

Expand Down
8 changes: 4 additions & 4 deletions lib/griddler/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ def fixture_file
Array.wrap(normalized_params).each do |params|
email = Griddler::Email.new(params)

email.to.should eq([{
expect(email.to).to eq([{
token: 'hi',
host: 'example.com',
full: 'Hello World <[email protected]>',
email: '[email protected]',
name: 'Hello World',
}])
email.cc.should eq [{
expect(email.cc).to eq [{
token: 'emily',
host: 'example.com',
email: '[email protected]',
Expand Down Expand Up @@ -81,8 +81,8 @@ def fixture_file
match do |actual|
expected.each do |k, v|
case v
when Regexp then actual[k].should =~ v
else actual[k].should === v
when Regexp then expect(actual[k]).to =~ v
else expect(actual[k]).to === v
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions spec/controllers/griddler/emails_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe Griddler::EmailsController do
describe Griddler::EmailsController, :type => :controller do
before(:each) do
fake_adapter = double(normalize_params: normalized_params)
Griddler.adapter_registry.register(:one_that_works, fake_adapter)
Expand All @@ -11,12 +11,12 @@
it 'is successful' do
post :create, email_params

response.should be_success
expect(response).to be_success
end

it 'creates a new Griddler::Email with the given params' do
email = double
Griddler::Email.should_receive(:new).
expect(Griddler::Email).to receive(:new).
with(hash_including(to: ['[email protected]'])).
and_return(email)

Expand All @@ -25,18 +25,18 @@

it 'calls process on the custom processor class' do
my_handler = double(process: nil)
my_handler.should_receive(:new).and_return(my_handler)
Griddler.configuration.stub(processor_class: my_handler)
expect(my_handler).to receive(:new).and_return(my_handler)
allow(Griddler.configuration).to receive_messages(processor_class: my_handler)

post :create, email_params
end

it 'calls the custom processor method on the processor class' do
Griddler.configuration.stub(processor_method: :perform)
allow(Griddler.configuration).to receive_messages(processor_method: :perform)
fake_processor = double(perform: nil)

EmailProcessor.should_receive(:new).and_return(fake_processor)
fake_processor.should_receive(:perform)
expect(EmailProcessor).to receive(:new).and_return(fake_processor)
expect(fake_processor).to receive(:perform)

post :create, email_params
end
Expand Down
8 changes: 4 additions & 4 deletions spec/griddler/adapter_registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

describe Griddler::AdapterRegistry do
it 'it is exposed by Griddler' do
Griddler.adapter_registry.should be_a Griddler::AdapterRegistry
expect(Griddler.adapter_registry).to be_a Griddler::AdapterRegistry
end

it 'can register adapters' do
adapter_registry = Griddler::AdapterRegistry.new

adapter_registry.register(:foo, adapter)

adapter_registry[:foo].should eq(adapter)
expect(adapter_registry[:foo]).to eq(adapter)
end

it 'can fetch like a hash' do
adapter_registry = Griddler::AdapterRegistry.new

result = adapter_registry.fetch(:non_existent) { 'exists' }

result.should eq 'exists'
expect(result).to eq 'exists'
end

it 'maps :default to :sendgrid' do
adapter_registry = Griddler::AdapterRegistry.new

adapter_registry.register(:sendgrid, adapter)

adapter_registry[:default].should eq(adapter)
expect(adapter_registry[:default]).to eq(adapter)
end

def adapter
Expand Down
22 changes: 11 additions & 11 deletions spec/griddler/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
end

it 'provides defaults' do
Griddler.configuration.processor_class.should eq(EmailProcessor)
Griddler.configuration.reply_delimiter.should eq('Reply ABOVE THIS LINE')
Griddler.configuration.email_service.should eq(:test_adapter)
Griddler.configuration.processor_method.should eq(:process)
expect(Griddler.configuration.processor_class).to eq(EmailProcessor)
expect(Griddler.configuration.reply_delimiter).to eq('Reply ABOVE THIS LINE')
expect(Griddler.configuration.email_service).to eq(:test_adapter)
expect(Griddler.configuration.processor_method).to eq(:process)
end

it 'raises a helpful error if EmailProcessor is undefined' do
Kernel.stub(const_defined?: false)
allow(Kernel).to receive_messages(const_defined?: false)

expect { Griddler.configuration.processor_class }.to raise_error(NameError, %r{https://github\.com/thoughtbot/griddler#defaults})
end
Expand All @@ -32,32 +32,32 @@
config.processor_class = dummy_processor
end

Griddler.configuration.processor_class.should eq dummy_processor
expect(Griddler.configuration.processor_class).to eq dummy_processor
end

it 'stores a processor_method' do
Griddler.configure do |config|
config.processor_method = :perform
end

Griddler.configuration.processor_method.should eq(:perform)
expect(Griddler.configuration.processor_method).to eq(:perform)
end

it 'sets and stores an email_service' do
Griddler.should_receive(:adapter_registry).and_return(double(fetch: :configured_adapter))
expect(Griddler).to receive(:adapter_registry).and_return(double(fetch: :configured_adapter))
Griddler.configure do |config|
config.email_service = :another_adapter
end

Griddler.configuration.email_service.should eq(:configured_adapter)
expect(Griddler.configuration.email_service).to eq(:configured_adapter)
end

it 'accepts a :default symbol and uses sendgrid' do
Griddler.configure do |c|
c.email_service = :default
end

Griddler.configuration.email_service.should eq(:test_adapter)
expect(Griddler.configuration.email_service).to eq(:test_adapter)
end

it 'raises an error when setting a non-existent email service adapter' do
Expand All @@ -67,7 +67,7 @@
end
end

config.should raise_error(Griddler::Errors::EmailServiceAdapterNotFound)
expect(config).to raise_error(Griddler::Errors::EmailServiceAdapterNotFound)
end
end
end
Loading

0 comments on commit 47ab10f

Please sign in to comment.