Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 47ab10f

Browse files
petergoldsteincalebhearth
authored andcommitted
Convert specs to RSpec 3.0.2 syntax with Transpec
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
1 parent e5783ec commit 47ab10f

7 files changed

Lines changed: 96 additions & 91 deletions

File tree

‎NEWS.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## 1.0.0
22

3+
* Convert test suite, including Griddler::Testing, to expect syntax for RSpec
4+
3.0 compliance. https://github.com/thoughtbot/griddler/pull/160
5+
6+
*Peter Goldstein*
7+
38
* Use instances of email processor classes rather than calling class methods.
49
https://github.com/thoughtbot/griddler/pull/153
510

‎lib/griddler/testing.rb‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def fixture_file
4444
Array.wrap(normalized_params).each do |params|
4545
email = Griddler::Email.new(params)
4646

47-
email.to.should eq([{
47+
expect(email.to).to eq([{
4848
token: 'hi',
4949
host: 'example.com',
5050
full: 'Hello World <hi@example.com>',
5151
email: 'hi@example.com',
5252
name: 'Hello World',
5353
}])
54-
email.cc.should eq [{
54+
expect(email.cc).to eq [{
5555
token: 'emily',
5656
host: 'example.com',
5757
email: 'emily@example.com',
@@ -81,8 +81,8 @@ def fixture_file
8181
match do |actual|
8282
expected.each do |k, v|
8383
case v
84-
when Regexp then actual[k].should =~ v
85-
else actual[k].should === v
84+
when Regexp then expect(actual[k]).to =~ v
85+
else expect(actual[k]).to === v
8686
end
8787
end
8888
end

‎spec/controllers/griddler/emails_controller_spec.rb‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
22

3-
describe Griddler::EmailsController do
3+
describe Griddler::EmailsController, :type => :controller do
44
before(:each) do
55
fake_adapter = double(normalize_params: normalized_params)
66
Griddler.adapter_registry.register(:one_that_works, fake_adapter)
@@ -11,12 +11,12 @@
1111
it 'is successful' do
1212
post :create, email_params
1313

14-
response.should be_success
14+
expect(response).to be_success
1515
end
1616

1717
it 'creates a new Griddler::Email with the given params' do
1818
email = double
19-
Griddler::Email.should_receive(:new).
19+
expect(Griddler::Email).to receive(:new).
2020
with(hash_including(to: ['tb@example.com'])).
2121
and_return(email)
2222

@@ -25,18 +25,18 @@
2525

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

3131
post :create, email_params
3232
end
3333

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

38-
EmailProcessor.should_receive(:new).and_return(fake_processor)
39-
fake_processor.should_receive(:perform)
38+
expect(EmailProcessor).to receive(:new).and_return(fake_processor)
39+
expect(fake_processor).to receive(:perform)
4040

4141
post :create, email_params
4242
end

‎spec/griddler/adapter_registry_spec.rb‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22

33
describe Griddler::AdapterRegistry do
44
it 'it is exposed by Griddler' do
5-
Griddler.adapter_registry.should be_a Griddler::AdapterRegistry
5+
expect(Griddler.adapter_registry).to be_a Griddler::AdapterRegistry
66
end
77

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

1111
adapter_registry.register(:foo, adapter)
1212

13-
adapter_registry[:foo].should eq(adapter)
13+
expect(adapter_registry[:foo]).to eq(adapter)
1414
end
1515

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

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

21-
result.should eq 'exists'
21+
expect(result).to eq 'exists'
2222
end
2323

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

2727
adapter_registry.register(:sendgrid, adapter)
2828

29-
adapter_registry[:default].should eq(adapter)
29+
expect(adapter_registry[:default]).to eq(adapter)
3030
end
3131

3232
def adapter

‎spec/griddler/configuration_spec.rb‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
end
88

99
it 'provides defaults' do
10-
Griddler.configuration.processor_class.should eq(EmailProcessor)
11-
Griddler.configuration.reply_delimiter.should eq('Reply ABOVE THIS LINE')
12-
Griddler.configuration.email_service.should eq(:test_adapter)
13-
Griddler.configuration.processor_method.should eq(:process)
10+
expect(Griddler.configuration.processor_class).to eq(EmailProcessor)
11+
expect(Griddler.configuration.reply_delimiter).to eq('Reply ABOVE THIS LINE')
12+
expect(Griddler.configuration.email_service).to eq(:test_adapter)
13+
expect(Griddler.configuration.processor_method).to eq(:process)
1414
end
1515

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

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

35-
Griddler.configuration.processor_class.should eq dummy_processor
35+
expect(Griddler.configuration.processor_class).to eq dummy_processor
3636
end
3737

3838
it 'stores a processor_method' do
3939
Griddler.configure do |config|
4040
config.processor_method = :perform
4141
end
4242

43-
Griddler.configuration.processor_method.should eq(:perform)
43+
expect(Griddler.configuration.processor_method).to eq(:perform)
4444
end
4545

4646
it 'sets and stores an email_service' do
47-
Griddler.should_receive(:adapter_registry).and_return(double(fetch: :configured_adapter))
47+
expect(Griddler).to receive(:adapter_registry).and_return(double(fetch: :configured_adapter))
4848
Griddler.configure do |config|
4949
config.email_service = :another_adapter
5050
end
5151

52-
Griddler.configuration.email_service.should eq(:configured_adapter)
52+
expect(Griddler.configuration.email_service).to eq(:configured_adapter)
5353
end
5454

5555
it 'accepts a :default symbol and uses sendgrid' do
5656
Griddler.configure do |c|
5757
c.email_service = :default
5858
end
5959

60-
Griddler.configuration.email_service.should eq(:test_adapter)
60+
expect(Griddler.configuration.email_service).to eq(:test_adapter)
6161
end
6262

6363
it 'raises an error when setting a non-existent email service adapter' do
@@ -67,7 +67,7 @@
6767
end
6868
end
6969

70-
config.should raise_error(Griddler::Errors::EmailServiceAdapterNotFound)
70+
expect(config).to raise_error(Griddler::Errors::EmailServiceAdapterNotFound)
7171
end
7272
end
7373
end

0 commit comments

Comments
 (0)