pickle 0.4.11 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,11 +8,11 @@ require 'pickle/adapters/active_record'
8
8
 
9
9
  describe Pickle::Adapter do
10
10
  it ".factories should raise NotImplementedError" do
11
- lambda { Pickle::Adapter.factories }.should raise_error(NotImplementedError)
11
+ expect { Pickle::Adapter.factories }.to raise_error(NotImplementedError)
12
12
  end
13
13
 
14
14
  it "#create should raise NotImplementedError" do
15
- lambda { Pickle::Adapter.new.create }.should raise_error(NotImplementedError)
15
+ expect { Pickle::Adapter.new.create }.to raise_error(NotImplementedError)
16
16
  end
17
17
 
18
18
  describe ".model_classes" do
@@ -23,9 +23,9 @@ describe Pickle::Adapter do
23
23
 
24
24
  describe "adapters: " do
25
25
  before do
26
- @klass1 = Class.new(ActiveRecord::Base).tap { |k| k.stub!(:name).and_return('One') }
27
- @klass2 = Class.new(ActiveRecord::Base).tap { |k| k.stub!(:name).and_return('One::Two') }
28
- @klass3 = Class.new(ActiveRecord::Base).tap { |k| k.stub!(:name).and_return('Three') }
26
+ @klass1 = Class.new(ActiveRecord::Base).tap { |k| allow(k).to receive(:name).and_return('One') }
27
+ @klass2 = Class.new(ActiveRecord::Base).tap { |k| allow(k).to receive(:name).and_return('One::Two') }
28
+ @klass3 = Class.new(ActiveRecord::Base).tap { |k| allow(k).to receive(:name).and_return('Three') }
29
29
  end
30
30
 
31
31
  describe 'ActiveRecord' do
@@ -34,8 +34,8 @@ describe Pickle::Adapter do
34
34
 
35
35
  describe ".model_classes" do
36
36
  it "calls .descendants" do
37
- ::ActiveRecord::Base.should_receive(:descendants).and_return([])
38
- ::ActiveRecord::Base.should_not_receive(:subclasses).and_return([])
37
+ expect(::ActiveRecord::Base).to receive(:descendants).and_return([])
38
+ expect(::ActiveRecord::Base).not_to receive(:subclasses)
39
39
 
40
40
  ActiveRecord::Base::PickleAdapter.model_classes
41
41
  end
@@ -43,14 +43,14 @@ describe Pickle::Adapter do
43
43
 
44
44
  describe 'with class stubs' do
45
45
  before do
46
- Pickle::Adapter::Orm.stub!(:model_classes).and_return([@klass1, @klass2, @klass3])
46
+ allow(Pickle::Adapter::Orm).to receive(:model_classes).and_return([@klass1, @klass2, @klass3])
47
47
  end
48
48
 
49
49
  it ".factories should create one for each active record class" do
50
- Pickle::Adapter::Orm.should_receive(:new).with(@klass1).once
51
- Pickle::Adapter::Orm.should_receive(:new).with(@klass2).once
52
- Pickle::Adapter::Orm.should_receive(:new).with(@klass3).once
53
- Pickle::Adapter::Orm.factories.length.should == 3
50
+ expect(Pickle::Adapter::Orm).to receive(:new).with(@klass1).once
51
+ expect(Pickle::Adapter::Orm).to receive(:new).with(@klass2).once
52
+ expect(Pickle::Adapter::Orm).to receive(:new).with(@klass3).once
53
+ expect(Pickle::Adapter::Orm.factories.length).to eq(3)
54
54
  end
55
55
 
56
56
  describe ".new(Class)" do
@@ -59,11 +59,11 @@ describe Pickle::Adapter do
59
59
  end
60
60
 
61
61
  it "should have underscored (s/_) name of Class as #name" do
62
- @factory.name.should == 'one_two'
62
+ expect(@factory.name).to eq('one_two')
63
63
  end
64
64
 
65
65
  it "#create(attrs) should call Class.create!(attrs)" do
66
- @klass2.should_receive(:create!).with({:key => "val"})
66
+ expect(@klass2).to receive(:create!).with({:key => "val"})
67
67
  @factory.create(:key => "val")
68
68
  end
69
69
  end
@@ -72,7 +72,7 @@ describe Pickle::Adapter do
72
72
 
73
73
  describe 'FactoryGirl' do
74
74
  before do
75
- Pickle::Adapter::FactoryGirl.stub!(:model_classes).and_return([@klass1, @klass2, @klass3])
75
+ allow(Pickle::Adapter::FactoryGirl).to receive(:model_classes).and_return([@klass1, @klass2, @klass3])
76
76
 
77
77
  if defined? ::FactoryGirl
78
78
  @orig_factories = ::FactoryGirl.factories.dup
@@ -100,8 +100,8 @@ describe Pickle::Adapter do
100
100
  end
101
101
 
102
102
  it ".factories should create one for each factory" do
103
- Pickle::Adapter::FactoryGirl.should_receive(:new).with(@factory1).once
104
- Pickle::Adapter::FactoryGirl.should_receive(:new).with(@factory2).once
103
+ expect(Pickle::Adapter::FactoryGirl).to receive(:new).with(@factory1).once
104
+ expect(Pickle::Adapter::FactoryGirl).to receive(:new).with(@factory2).once
105
105
  Pickle::Adapter::FactoryGirl.factories
106
106
  end
107
107
 
@@ -111,16 +111,16 @@ describe Pickle::Adapter do
111
111
  end
112
112
 
113
113
  it "should have name of factory_name" do
114
- @factory.name.should == 'one'
114
+ expect(@factory.name).to eq('one')
115
115
  end
116
116
 
117
117
  it "should have klass of build_class" do
118
- @factory.klass.should == @klass1
118
+ expect(@factory.klass).to eq(@klass1)
119
119
  end
120
120
 
121
121
  unless defined? ::FactoryGirl
122
122
  it "#create(attrs) should call Factory(<:key>, attrs)" do
123
- Factory.should_receive(:create).with("one", {:key => "val"})
123
+ expect(Factory).to receive(:create).with("one", {:key => "val"})
124
124
  @factory.create(:key => "val")
125
125
  end
126
126
  end
@@ -129,14 +129,14 @@ describe Pickle::Adapter do
129
129
 
130
130
  describe 'Fabrication' do
131
131
  before do
132
- @schematic1 = [:one, Fabrication::Schematic.new(@klass1)]
133
- @schematic2 = [:two, Fabrication::Schematic.new(@klass2)]
134
- ::Fabrication::Fabricator.stub(:schematics).and_return([@schematic1, @schematic2])
132
+ @schematic1 = [:one, Fabrication::Schematic::Definition.new(@klass1)]
133
+ @schematic2 = [:two, Fabrication::Schematic::Definition.new(@klass2)]
134
+ allow(::Fabrication.manager).to receive(:schematics).and_return(Hash[[@schematic1, @schematic2]])
135
135
  end
136
136
 
137
137
  it '.factories should create one for each fabricator' do
138
- Pickle::Adapter::Fabrication.should_receive(:new).with(@schematic1)
139
- Pickle::Adapter::Fabrication.should_receive(:new).with(@schematic2)
138
+ expect(Pickle::Adapter::Fabrication).to receive(:new).with(@schematic1)
139
+ expect(Pickle::Adapter::Fabrication).to receive(:new).with(@schematic2)
140
140
 
141
141
  Pickle::Adapter::Fabrication.factories
142
142
  end
@@ -147,19 +147,19 @@ describe Pickle::Adapter do
147
147
  end
148
148
 
149
149
  it ".new should have name of schematic name" do
150
- @factory.name.should == 'one'
150
+ expect(@factory.name).to eq('one')
151
151
  end
152
152
 
153
153
  it "should have klass of build_class" do
154
- @factory.klass.should == @klass1
154
+ expect(@factory.klass).to eq(@klass1)
155
155
  end
156
156
  end
157
157
 
158
158
  describe ".create" do
159
159
  it "returns the fabricated instance" do
160
160
  @factory = Pickle::Adapter::Fabrication.new(@schematic1)
161
- ::Fabrication::Fabricator.should_receive(:generate).
162
- with(@factory.name.to_sym, {:save => true}, {:attribute => 'value'})
161
+ expect(Fabricate).to receive(:create).
162
+ with(@factory.name.to_sym, {:attribute => 'value'})
163
163
  @factory.create({:attribute => 'value'})
164
164
  end
165
165
  end
@@ -167,7 +167,7 @@ describe Pickle::Adapter do
167
167
 
168
168
  describe 'Machinist' do
169
169
  before do
170
- Pickle::Adapter::Machinist.stub!(:model_classes).and_return([@klass1, @klass2, @klass3])
170
+ allow(Pickle::Adapter::Machinist).to receive(:model_classes).and_return([@klass1, @klass2, @klass3])
171
171
 
172
172
  @klass1.blueprint {}
173
173
  @klass3.blueprint {}
@@ -175,9 +175,9 @@ describe Pickle::Adapter do
175
175
  end
176
176
 
177
177
  it ".factories should create one for each master blueprint, and special case" do
178
- Pickle::Adapter::Machinist.should_receive(:new).with(@klass1, :master).once
179
- Pickle::Adapter::Machinist.should_receive(:new).with(@klass3, :master).once
180
- Pickle::Adapter::Machinist.should_receive(:new).with(@klass3, :special).once
178
+ expect(Pickle::Adapter::Machinist).to receive(:new).with(@klass1, :master).once
179
+ expect(Pickle::Adapter::Machinist).to receive(:new).with(@klass3, :master).once
180
+ expect(Pickle::Adapter::Machinist).to receive(:new).with(@klass3, :special).once
181
181
  Pickle::Adapter::Machinist.factories
182
182
  end
183
183
 
@@ -187,11 +187,11 @@ describe Pickle::Adapter do
187
187
  end
188
188
 
189
189
  it "should have underscored (s/_) name of Class as #name" do
190
- @factory.name.should == 'one'
190
+ expect(@factory.name).to eq('one')
191
191
  end
192
192
 
193
- it "#create(attrs) should call Class.make(:master, attrs)" do
194
- @klass1.should_receive(:make).with(:master, {:key => "val"})
193
+ it "#create(attrs) should call Class.make!(:master, attrs)" do
194
+ expect(@klass1).to receive(:make!).with(:master, {:key => "val"})
195
195
  @factory.create(:key => "val")
196
196
  end
197
197
  end
@@ -202,11 +202,11 @@ describe Pickle::Adapter do
202
202
  end
203
203
 
204
204
  it "should have 'special_<Class name>' as #name" do
205
- @factory.name.should == 'special_three'
205
+ expect(@factory.name).to eq('special_three')
206
206
  end
207
207
 
208
- it "#create(attrs) should call Class.make(:special, attrs)" do
209
- @klass3.should_receive(:make).with(:special, {:key => "val"})
208
+ it "#create(attrs) should call Class.make!(:special, attrs)" do
209
+ expect(@klass3).to receive(:make!).with(:special, {:key => "val"})
210
210
  @factory.create(:key => "val")
211
211
  end
212
212
  end
@@ -6,11 +6,11 @@ describe Pickle::Config do
6
6
  end
7
7
 
8
8
  it "#adapters should default to :machinist, :factory_girl, :orm" do
9
- @config.adapters.should == [:machinist, :factory_girl, :fabrication, :orm]
9
+ expect(@config.adapters).to eq([:machinist, :factory_girl, :fabrication, :orm])
10
10
  end
11
11
 
12
12
  it "#adapter_classes should default to Adapter::Machinist, Adapter::FactoryGirl, Adapter::Orm" do
13
- @config.adapter_classes.should == [Pickle::Adapter::Machinist, Pickle::Adapter::FactoryGirl, Pickle::Adapter::Fabrication, Pickle::Adapter::Orm]
13
+ expect(@config.adapter_classes).to eq([Pickle::Adapter::Machinist, Pickle::Adapter::FactoryGirl, Pickle::Adapter::Fabrication, Pickle::Adapter::Orm])
14
14
  end
15
15
 
16
16
  describe "setting adapters to [:machinist, SomeAdapter]" do
@@ -21,60 +21,60 @@ describe Pickle::Config do
21
21
  end
22
22
 
23
23
  it "#adapter_classes should be Adapter::Machinist, SomeAdapter" do
24
- @config.adapter_classes.should == [Pickle::Adapter::Machinist, SomeAdapter]
24
+ expect(@config.adapter_classes).to eq([Pickle::Adapter::Machinist, SomeAdapter])
25
25
  end
26
26
  end
27
27
 
28
28
  describe "#factories" do
29
29
  it "should call adaptor.factories for each adaptor" do
30
- Pickle::Adapter::Machinist.should_receive(:factories).and_return([])
31
- Pickle::Adapter::FactoryGirl.should_receive(:factories).and_return([])
32
- Pickle::Adapter::Fabrication.should_receive(:factories).and_return([])
33
- Pickle::Adapter::Orm.should_receive(:factories).and_return([])
30
+ expect(Pickle::Adapter::Machinist).to receive(:factories).and_return([])
31
+ expect(Pickle::Adapter::FactoryGirl).to receive(:factories).and_return([])
32
+ expect(Pickle::Adapter::Fabrication).to receive(:factories).and_return([])
33
+ expect(Pickle::Adapter::Orm).to receive(:factories).and_return([])
34
34
  @config.factories
35
35
  end
36
36
 
37
37
  it "should aggregate factories into a hash using factory name as key" do
38
- Pickle::Adapter::Machinist.should_receive(:factories).and_return([@machinist = mock('machinist', :name => 'machinist')])
39
- Pickle::Adapter::FactoryGirl.should_receive(:factories).and_return([@factory_girl = mock('factory_girl', :name => 'factory_girl')])
40
- Pickle::Adapter::Fabrication.should_receive(:factories).and_return([@fabrication = mock('fabrication', :name => 'fabrication')])
41
- Pickle::Adapter::Orm.should_receive(:factories).and_return([@orm = mock('orm', :name => 'orm')])
42
- @config.factories.should == {'machinist' => @machinist, 'factory_girl' => @factory_girl, 'fabrication' => @fabrication, 'orm' => @orm}
38
+ expect(Pickle::Adapter::Machinist).to receive(:factories).and_return([@machinist = double('machinist', :name => 'machinist')])
39
+ expect(Pickle::Adapter::FactoryGirl).to receive(:factories).and_return([@factory_girl = double('factory_girl', :name => 'factory_girl')])
40
+ expect(Pickle::Adapter::Fabrication).to receive(:factories).and_return([@fabrication = double('fabrication', :name => 'fabrication')])
41
+ expect(Pickle::Adapter::Orm).to receive(:factories).and_return([@orm = double('orm', :name => 'orm')])
42
+ expect(@config.factories).to eq({'machinist' => @machinist, 'factory_girl' => @factory_girl, 'fabrication' => @fabrication, 'orm' => @orm})
43
43
  end
44
44
 
45
45
  it "should give preference to adaptors first in the list" do
46
- Pickle::Adapter::Machinist.should_receive(:factories).and_return([@machinist_one = mock('one', :name => 'one')])
47
- Pickle::Adapter::FactoryGirl.should_receive(:factories).and_return([@factory_girl_one = mock('one', :name => 'one'), @factory_girl_two = mock('two', :name => 'two')])
48
- Pickle::Adapter::Fabrication.should_receive(:factories).and_return([@fabrication_one = mock('one', :name => 'one'), @fabrication_three = mock('three', :name => 'three')])
49
- Pickle::Adapter::Orm.should_receive(:factories).and_return([@orm_two = mock('two', :name => 'two'), @orm_four = mock('four', :name => 'four')])
50
- @config.factories.should == {'one' => @machinist_one, 'two' => @factory_girl_two, 'three' => @fabrication_three, 'four' => @orm_four}
46
+ expect(Pickle::Adapter::Machinist).to receive(:factories).and_return([@machinist_one = double('one', :name => 'one')])
47
+ expect(Pickle::Adapter::FactoryGirl).to receive(:factories).and_return([@factory_girl_one = double('one', :name => 'one'), @factory_girl_two = double('two', :name => 'two')])
48
+ expect(Pickle::Adapter::Fabrication).to receive(:factories).and_return([@fabrication_one = double('one', :name => 'one'), @fabrication_three = double('three', :name => 'three')])
49
+ expect(Pickle::Adapter::Orm).to receive(:factories).and_return([@orm_two = double('two', :name => 'two'), @orm_four = double('four', :name => 'four')])
50
+ expect(@config.factories).to eq({'one' => @machinist_one, 'two' => @factory_girl_two, 'three' => @fabrication_three, 'four' => @orm_four})
51
51
  end
52
52
  end
53
53
 
54
54
  it "#mappings should default to []" do
55
- @config.mappings.should == []
55
+ expect(@config.mappings).to eq([])
56
56
  end
57
57
 
58
58
  describe '#predicates' do
59
59
  it "should be list of all non object ? public instance methods + columns methods of Adapter.model_classes" do
60
- class1 = mock('Class1',
60
+ class1 = double('Class1',
61
61
  :public_instance_methods => ['nope', 'foo?', 'bar?'],
62
62
  :column_names => ['one', 'two'],
63
63
  :const_get => ::ActiveRecord::Base::PickleAdapter
64
64
  )
65
- class2 = mock('Class2',
65
+ class2 = double('Class2',
66
66
  :public_instance_methods => ['not', 'foo?', 'faz?'],
67
67
  :column_names => ['two', 'three'],
68
68
  :const_get => ::ActiveRecord::Base::PickleAdapter
69
69
  )
70
- Pickle::Adapter.stub!(:model_classes).and_return([class1, class2])
70
+ allow(Pickle::Adapter).to receive(:model_classes).and_return([class1, class2])
71
71
 
72
- @config.predicates.to_set.should == ['foo?', 'faz?', 'bar?', 'one', 'two', 'three'].to_set
72
+ expect(@config.predicates.to_set).to eq(['foo?', 'faz?', 'bar?', 'one', 'two', 'three'].to_set)
73
73
  end
74
74
 
75
75
  it "should be overridable" do
76
76
  @config.predicates = %w(lame?)
77
- @config.predicates.should == %w(lame?)
77
+ expect(@config.predicates).to eq(%w(lame?))
78
78
  end
79
79
  end
80
80
 
@@ -85,9 +85,9 @@ describe Pickle::Config do
85
85
 
86
86
  it "should create Mapping('foo', 'faz') mapping" do
87
87
  @config.mappings.first.tap do |mapping|
88
- mapping.should be_kind_of Pickle::Config::Mapping
89
- mapping.search.should == 'foo'
90
- mapping.replacement.should == 'faz'
88
+ expect(mapping).to be_kind_of Pickle::Config::Mapping
89
+ expect(mapping.search).to eq('foo')
90
+ expect(mapping.replacement).to eq('faz')
91
91
  end
92
92
  end
93
93
  end
@@ -98,13 +98,13 @@ describe Pickle::Config do
98
98
  end
99
99
 
100
100
  it "should create 2 mappings" do
101
- @config.mappings.first.should == Pickle::Config::Mapping.new('foo', 'faz')
102
- @config.mappings.last.should == Pickle::Config::Mapping.new('bar', 'faz')
101
+ expect(@config.mappings.first).to eq(Pickle::Config::Mapping.new('foo', 'faz'))
102
+ expect(@config.mappings.last).to eq(Pickle::Config::Mapping.new('bar', 'faz'))
103
103
  end
104
104
  end
105
105
 
106
106
  it "#configure(&block) should execiute on self" do
107
- @config.should_receive(:foo).with(:bar)
107
+ expect(@config).to receive(:foo).with(:bar)
108
108
  @config.configure do |c|
109
109
  c.foo :bar
110
110
  end
@@ -8,44 +8,44 @@ describe Pickle::Email::Parser do
8
8
 
9
9
  describe "#match_email" do
10
10
  it "should match 'the email'" do
11
- 'the email'.should match(/^#{match_email}$/)
11
+ expect('the email').to match(/^#{match_email}$/)
12
12
  end
13
13
 
14
14
  it "should match 'the first email'" do
15
- 'the first email'.should match(/^#{match_email}$/)
15
+ expect('the first email').to match(/^#{match_email}$/)
16
16
  end
17
17
 
18
18
  it "should match 'the last email'" do
19
- 'the last email'.should match(/^#{match_email}$/)
19
+ expect('the last email').to match(/^#{match_email}$/)
20
20
  end
21
21
 
22
22
  it "should match 'the 3rd email'" do
23
- 'the 3rd email'.should match(/^#{match_email}$/)
23
+ expect('the 3rd email').to match(/^#{match_email}$/)
24
24
  end
25
25
 
26
26
  it "should match 'an email'" do
27
- 'an email'.should match(/^#{match_email}$/)
27
+ expect('an email').to match(/^#{match_email}$/)
28
28
  end
29
29
  end
30
30
 
31
31
  it "#capture_email should just capture match_email" do
32
- capture_email.should == "(#{match_email})"
32
+ expect(capture_email).to eq("(#{match_email})")
33
33
  end
34
34
 
35
35
  describe "#capture_index_in_email" do
36
36
  it "should extract the '2nd' from 'the 2nd email'" do
37
37
  match = 'the 2nd email'.match(/^#{capture_index_in_email}$/)
38
- match[1].should == '2nd'
38
+ expect(match[1]).to eq('2nd')
39
39
  end
40
40
 
41
41
  it "should extract nil from 'the email'" do
42
42
  match = 'the email'.match(/^#{capture_index_in_email}$/)
43
- match[1].should == nil
43
+ expect(match[1]).to eq(nil)
44
44
  end
45
45
 
46
46
  it "should extract the 'last' from 'the last email'" do
47
47
  match = 'the last email'.match(/^#{capture_index_in_email}$/)
48
- match[1].should == 'last'
48
+ expect(match[1]).to eq('last')
49
49
  end
50
50
  end
51
51
  end
@@ -10,17 +10,17 @@ describe Pickle::Email do
10
10
  include Pickle::Email::Parser
11
11
 
12
12
  before do
13
- @email1 = mock("Email 1")
14
- @email2 = mock("Email 2")
15
- ActionMailer::Base.stub!(:deliveries).and_return([@email1, @email2])
13
+ @email1 = double("Email 1")
14
+ @email2 = double("Email 2")
15
+ allow(ActionMailer::Base).to receive(:deliveries).and_return([@email1, @email2])
16
16
  if defined?(ActiveRecord::Base)
17
- ActiveRecord::Base::PickleAdapter.stub!(:model_classes).and_return([])
17
+ allow(ActiveRecord::Base::PickleAdapter).to receive(:model_classes).and_return([])
18
18
  end
19
19
  end
20
20
 
21
21
  describe "#emails" do
22
22
  it "should return ordered deliveries" do
23
- emails.should == [@email1, @email2]
23
+ expect(emails).to eq([@email1, @email2])
24
24
  end
25
25
 
26
26
  describe "(after)" do
@@ -29,38 +29,38 @@ describe Pickle::Email do
29
29
  end
30
30
 
31
31
  it "#email('the email') should return the last delivery" do
32
- email('the email').should == @email2
32
+ expect(email('the email')).to eq(@email2)
33
33
  end
34
34
 
35
35
  it "#email('the 1st email') should return the first delivery" do
36
- email('the 1st email').should == @email1
36
+ expect(email('the 1st email')).to eq(@email1)
37
37
  end
38
38
 
39
39
  it "#email('the first email') should return the first delivery" do
40
- email('the first email').should == @email1
40
+ expect(email('the first email')).to eq(@email1)
41
41
  end
42
42
 
43
43
  it "#email('the 2nd email') should return the second delivery" do
44
- email('the 2nd email').should == @email2
44
+ expect(email('the 2nd email')).to eq(@email2)
45
45
  end
46
46
 
47
47
  it "#email('the last email') should return the second delivery" do
48
- email('the last email').should == @email2
48
+ expect(email('the last email')).to eq(@email2)
49
49
  end
50
50
 
51
51
  it "#email2('the 3rd email') should be nil" do
52
- email('the 3rd email').should == nil
52
+ expect(email('the 3rd email')).to eq(nil)
53
53
  end
54
54
  end
55
55
 
56
56
  describe "when email1 is to fred & joe, and email2 is to joe" do
57
57
  before do
58
- @email1.stub!(:to).and_return(['fred@gmail.com', 'joe@gmail.com'])
59
- @email2.stub!(:to).and_return('joe@gmail.com')
58
+ allow(@email1).to receive(:to).and_return(['fred@gmail.com', 'joe@gmail.com'])
59
+ allow(@email2).to receive(:to).and_return('joe@gmail.com')
60
60
  end
61
61
 
62
62
  it "#emails('to: \"fred@gmail.com\"') should just return email1" do
63
- emails('to: "fred@gmail.com"').should == [@email1]
63
+ expect(emails('to: "fred@gmail.com"')).to eq([@email1])
64
64
  end
65
65
 
66
66
  describe "after #emails('to: \"fred@gmail.com\"')" do
@@ -69,35 +69,35 @@ describe Pickle::Email do
69
69
  end
70
70
 
71
71
  it "#email('first') should be #email('last')" do
72
- email('first email').should == email('last email')
73
- email('first email').should == @email1
72
+ expect(email('first email')).to eq(email('last email'))
73
+ expect(email('first email')).to eq(@email1)
74
74
  end
75
75
 
76
76
  it "#email('the email', 'to: \"blah\") should be nil" do
77
- email('the email', 'to: "blah"').should == nil
77
+ expect(email('the email', 'to: "blah"')).to eq(nil)
78
78
  end
79
79
 
80
80
  it "#email('the email', 'to: \"fred@gmail.com\") should be email1" do
81
- email('the email', 'to: "fred@gmail.com"').should == @email1
81
+ expect(email('the email', 'to: "fred@gmail.com"')).to eq(@email1)
82
82
  end
83
83
  end
84
84
 
85
85
  it "#emails('to: \"joe@gmail.com\"') should return both emails" do
86
- emails('to: "joe@gmail.com"').should == [@email1, @email2]
86
+ expect(emails('to: "joe@gmail.com"')).to eq([@email1, @email2])
87
87
  end
88
88
 
89
89
  describe "and emails have subjects 'email1', 'email2'" do
90
90
  before do
91
- @email1.stub!(:subject).and_return('email1')
92
- @email2.stub!(:subject).and_return('email2')
91
+ allow(@email1).to receive(:subject).and_return('email1')
92
+ allow(@email2).to receive(:subject).and_return('email2')
93
93
  end
94
94
 
95
95
  it "#emails('to: \"joe@gmail.com\", subject: \"email1\"') should return email1" do
96
- emails('to: "joe@gmail.com", subject: "email1"').should == [@email1]
96
+ expect(emails('to: "joe@gmail.com", subject: "email1"')).to eq([@email1])
97
97
  end
98
98
 
99
99
  it "#emails('to: \"fred@gmail.com\", subject: \"email2\"') should return empty array" do
100
- emails('to: "fred@gmail.com", subject: "email2"').should == []
100
+ expect(emails('to: "fred@gmail.com", subject: "email2"')).to eq([])
101
101
  end
102
102
  end
103
103
  end
@@ -105,14 +105,14 @@ describe Pickle::Email do
105
105
 
106
106
  describe "#save_and_open_emails" do
107
107
  before do
108
- stub!(:open_in_browser)
109
- stub!(:emails).and_return(["Contents of Email 1"])
108
+ allow(self).to receive(:open_in_browser)
109
+ allow(self).to receive(:emails).and_return(["Contents of Email 1"])
110
110
  @now = "2008-01-01".to_time
111
- Time.stub!(:now).and_return(@now)
111
+ allow(Time).to receive(:now).and_return(@now)
112
112
  end
113
113
 
114
114
  it "should call #emails to get emails" do
115
- should_receive(:emails).and_return([])
115
+ expect(self).to receive(:emails).and_return([])
116
116
  save_and_open_emails
117
117
  end
118
118
 
@@ -120,47 +120,47 @@ describe Pickle::Email do
120
120
  before { @emails = [] }
121
121
 
122
122
  it "should not call #emails" do
123
- should_not_receive(:emails)
123
+ expect(self).not_to receive(:emails)
124
124
  save_and_open_emails
125
125
  end
126
126
  end
127
127
 
128
128
  it "should create a file in Rails/tmp with the emails in it" do
129
129
  save_and_open_emails
130
- File.read("pickle-email-#{@now.to_i}.html").should == "<h1>Email 1</h1><pre>Contents of Email 1</pre><hr />"
130
+ expect(File.read("pickle-email-#{@now.to_i}.html")).to eq("<h1>Email 1</h1><pre>Contents of Email 1</pre><hr />")
131
131
  end
132
132
 
133
133
  it "should call open_in_browser on created tmp file" do
134
- should_receive(:open_in_browser).with("pickle-email-#{@now.to_i}.html")
134
+ expect(self).to receive(:open_in_browser).with("pickle-email-#{@now.to_i}.html")
135
135
  save_and_open_emails
136
136
  end
137
137
  end
138
138
 
139
139
  describe "following links in emails" do
140
140
  before do
141
- stub!(:open_in_browser)
142
- @email1.stub!(:body).and_return('some text <a href="http://example.com/page">example page</a> more text')
141
+ allow(self).to receive(:open_in_browser)
142
+ allow(@email1).to receive(:body).and_return('some text <a href="http://example.com/page">example page</a> more text')
143
143
  end
144
144
 
145
145
  it "should find a link for http://example.com/page" do
146
- should_receive(:visit).with('http://example.com/page')
146
+ expect(self).to receive(:visit).with('http://example.com/page')
147
147
  visit_in_email(@email1, 'http://example.com/page')
148
148
  end
149
149
 
150
150
  it "should find a link for \"example page\"" do
151
- should_receive(:visit).with('http://example.com/page')
151
+ expect(self).to receive(:visit).with('http://example.com/page')
152
152
  visit_in_email(@email1, 'example page')
153
153
  end
154
154
 
155
155
  it "should follow the first link in an email" do
156
- should_receive(:visit).with('http://example.com/page')
156
+ expect(self).to receive(:visit).with('http://example.com/page')
157
157
  click_first_link_in_email(@email1)
158
158
  end
159
159
 
160
160
  it "should not raise an error when the email body is not a string, but needs to_s [#26]" do
161
- stub!(:visit)
162
- @email1.stub!(:body).and_return(:a_string_body)
163
- lambda { click_first_link_in_email(@email1) }.should_not raise_error
161
+ allow(self).to receive(:visit)
162
+ allow(@email1).to receive(:body).and_return(:a_string_body)
163
+ expect { click_first_link_in_email(@email1) }.not_to raise_error
164
164
  end
165
165
  end
166
166
  end