HornsAndHooves-flat_map 0.2.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,7 +75,7 @@ module FlatMap
75
75
 
76
76
  context 'defining mountings' do
77
77
  it "should use Factory for defining mappings" do
78
- Mapper::Factory.should_receive(:new).
78
+ expect(Mapper::Factory).to receive(:new).
79
79
  with(:foo, :mapper_class_name => 'FooMapper').
80
80
  and_call_original
81
81
 
@@ -85,75 +85,75 @@ module FlatMap
85
85
  end
86
86
 
87
87
  describe 'properties' do
88
- it{ mapper.hosted?.should be false }
89
- it{ mounting.hosted?.should be true }
90
- it{ mounting.host.should == mapper }
88
+ it{ expect(mapper.hosted? ).to be false }
89
+ it{ expect(mounting.hosted?).to be true }
90
+ it{ expect(mounting.host ).to eq mapper }
91
91
  end
92
92
 
93
93
  it 'should be able to access mapping by name' do
94
- mapper.mounting(:spec_mount).should be_a(FlatMap::Mapper)
95
- mapper.mounting(:undefined_mount).should be_nil
94
+ expect(mapper.mounting(:spec_mount )).to be_a(FlatMap::Mapper)
95
+ expect(mapper.mounting(:undefined_mount)).to be_nil
96
96
  end
97
97
 
98
98
  describe "#read" do
99
99
  it 'should add mounted mappers to a result' do
100
- mapper.read.should == {
100
+ expect(mapper.read).to eq({
101
101
  :host_attr => 'attr',
102
102
  :attr_a => 'a',
103
103
  :mapped_attr_b => 'b'
104
- }
104
+ })
105
105
  end
106
106
 
107
107
  it 'should define dynamic writer methods' do
108
- mapper.respond_to?(:attr_a).should be true
109
- mapper.method(:attr_a).should_not be nil
108
+ expect(mapper.respond_to?(:attr_a)).to be true
109
+ expect(mapper.method(:attr_a )).not_to be nil
110
110
 
111
- mapper.respond_to?(:mapped_attr_b).should be true
112
- mapper.method(:mapped_attr_b).should_not be nil
111
+ expect(mapper.respond_to?(:mapped_attr_b)).to be true
112
+ expect(mapper.method(:mapped_attr_b )).not_to be nil
113
113
  end
114
114
  end
115
115
 
116
116
  describe "#write" do
117
117
  it 'should define dynamic writer methods' do
118
- mapper.respond_to?(:attr_a=).should be true
119
- mapper.method(:attr_a=).should_not be nil
118
+ expect(mapper.respond_to?(:attr_a=)).to be true
119
+ expect(mapper.method(:attr_a= )).not_to be nil
120
120
 
121
- mapper.respond_to?(:mapped_attr_b=).should be true
122
- mapper.method(:mapped_attr_b=).should_not be nil
121
+ expect(mapper.respond_to?(:mapped_attr_b=)).to be true
122
+ expect(mapper.method(:mapped_attr_b= )).not_to be nil
123
123
  end
124
124
 
125
125
  it 'should pass values to mounted mappers' do
126
126
  target = MountingSpec.mount_target
127
127
  mapper.write :attr_a => 'A', :mapped_attr_b => 'B'
128
- target.attr_a.should == 'A'
129
- target.attr_b.should == 'B'
128
+ expect(target.attr_a).to eq 'A'
129
+ expect(target.attr_b).to eq 'B'
130
130
  end
131
131
  end
132
132
 
133
133
  it 'should delegate missing methods to mounted mappers' do
134
- expect{ mapper.a_method.should == 'a value' }.not_to raise_error
134
+ expect{ expect(mapper.a_method).to eq 'a value' }.not_to raise_error
135
135
  end
136
136
 
137
137
  specify '#before_save_mountings' do
138
- mapper.before_save_mountings.should == [mapper.mounting(:spec_mount_before)]
138
+ expect(mapper.before_save_mountings).to eq [mapper.mounting(:spec_mount_before)]
139
139
  end
140
140
 
141
141
  specify '#after_save_mountings' do
142
- mapper.after_save_mountings.should == [mapper.mounting(:spec_mount)]
142
+ expect(mapper.after_save_mountings).to eq [mapper.mounting(:spec_mount)]
143
143
  end
144
144
 
145
145
  context 'with suffix' do
146
146
  let(:mapper){ MountingSuffixSpec::SpecMapper.new(OpenStruct.new) }
147
147
  let(:mounting){ mapper.mounting(:mount_foo) }
148
148
 
149
- it{ mapper.should_not be_suffixed }
150
- it{ mounting.should be_suffixed }
149
+ it{ expect(mapper ).not_to be_suffixed }
150
+ it{ expect(mounting).to be_suffixed }
151
151
 
152
152
  it 'should cascade to nested mappings' do
153
153
  mapper.attr_mount_foo = 'foo'
154
154
  mapper.attr_nested_foo = 'bar'
155
155
 
156
- mapper.read.should include({
156
+ expect(mapper.read).to include({
157
157
  :attr_mount_foo => 'foo',
158
158
  :attr_nested_foo => 'bar' })
159
159
  end
@@ -29,21 +29,24 @@ module FlatMap
29
29
  describe Mapper::Persistence do
30
30
  describe '#target_class' do
31
31
  it 'should detect target_class from mapper class name' do
32
- PersistenceSpec::TargetClassMapper.target_class.should == PersistenceSpec::TargetClass
32
+ expect(PersistenceSpec::TargetClassMapper.target_class.ancestors).
33
+ to include PersistenceSpec::TargetClass
33
34
  end
34
35
 
35
36
  it 'should detect target_class from nearest ancestor when inherited' do
36
- PersistenceSpec::InheritedClassMapper.target_class.should == PersistenceSpec::TargetClass
37
+ expect(PersistenceSpec::InheritedClassMapper.target_class.ancestors).
38
+ to include PersistenceSpec::TargetClass
37
39
  end
38
40
 
39
41
  it 'should use explicit class name if specified' do
40
- PersistenceSpec::ExplicitNameMapper.target_class.should == PersistenceSpec::OtherTargetClass
42
+ expect(PersistenceSpec::ExplicitNameMapper.target_class.ancestors).
43
+ to include PersistenceSpec::OtherTargetClass
41
44
  end
42
45
  end
43
46
 
44
47
  describe '.build' do
45
48
  it 'should use target class to build a new object for mapper' do
46
- PersistenceSpec::TargetClassMapper.should_receive(:new).with(kind_of(PersistenceSpec::TargetClass), :used_trait)
49
+ expect(PersistenceSpec::TargetClassMapper).to receive(:new).with(kind_of(PersistenceSpec::TargetClass), :used_trait)
47
50
  PersistenceSpec::TargetClassMapper.build(:used_trait)
48
51
  end
49
52
  end
@@ -52,8 +55,8 @@ module FlatMap
52
55
  let(:target){ PersistenceSpec::TargetClass.new('a', 'b') }
53
56
 
54
57
  it 'should delegate to target class to find object for mapper' do
55
- PersistenceSpec::TargetClass.should_receive(:find).with(1).and_return(target)
56
- PersistenceSpec::TargetClassMapper.should_receive(:new).with(target, :used_trait)
58
+ expect(PersistenceSpec::TargetClass).to receive(:find).with(1).and_return(target)
59
+ expect(PersistenceSpec::TargetClassMapper).to receive(:new).with(target, :used_trait)
57
60
  PersistenceSpec::TargetClassMapper.find(1, :used_trait)
58
61
  end
59
62
  end
@@ -63,35 +66,35 @@ module FlatMap
63
66
  let(:mapper){ PersistenceSpec::TargetClassMapper.new(target){} }
64
67
 
65
68
  specify '#model_name' do
66
- mapper.model_name.should == 'mapper'
69
+ expect(mapper.model_name).to respond_to :human
67
70
  end
68
71
 
69
72
  specify '#to_key should delegate to target' do
70
- target.should_receive(:to_key).and_return(1)
71
- mapper.to_key.should == 1
73
+ expect(target).to receive(:to_key).and_return(1)
74
+ expect(mapper.to_key).to eq 1
72
75
  end
73
76
 
74
77
  specify '#persisted? when target does not respond to :persised?' do
75
- mapper.should_not be_persisted
78
+ expect(mapper).not_to be_persisted
76
79
  end
77
80
 
78
81
  specify '#persisted? when target responds to :persisted?' do
79
- target.stub(:persisted?).and_return(true)
80
- mapper.should be_persisted
82
+ expect(target).to receive(:persisted?).and_return(true)
83
+ expect(mapper).to be_persisted
81
84
  end
82
85
 
83
86
  specify '#id when target does not respond to :id' do
84
- mapper.id.should be_nil
87
+ expect(mapper.id).to be_nil
85
88
  end
86
89
 
87
90
  specify '#id when target responds to :id' do
88
- target.stub(:id).and_return(1)
89
- mapper.id.should == 1
91
+ expect(target).to receive(:id).and_return(1)
92
+ expect(mapper.id).to eq 1
90
93
  end
91
94
 
92
95
  describe '#write with multiparams' do
93
96
  let(:params) {{
94
- 'attr_a' => 'A',
97
+ 'attr_a' => 'A',
95
98
  'dob(0i)' => '1999',
96
99
  'dob(1i)' => '01',
97
100
  'dob(2i)' => '02'
@@ -99,23 +102,23 @@ module FlatMap
99
102
 
100
103
  it 'should assign values properly' do
101
104
  mapper.write(params)
102
- target.attr_a.should == 'A'
103
- target.attr_b.should == Date.new(1999, 1, 2)
105
+ expect(target.attr_a).to eq 'A'
106
+ expect(target.attr_b).to eq Date.new(1999, 1, 2)
104
107
  end
105
108
  end
106
109
 
107
110
  describe '#save_target' do
108
111
  it 'should return true for owned mappers' do
109
- mapper.extension.save_target.should be true
112
+ expect(mapper.extension.save_target).to eq true
110
113
  end
111
114
 
112
115
  it 'should return true if target does not respond to #save' do
113
- mapper.save_target.should be true
116
+ expect(mapper.save_target).to eq true
114
117
  end
115
118
 
116
119
  it 'should save with no validation if target responds to #save' do
117
- target.should_receive(:save).with(:validate => false).and_return(true)
118
- mapper.save_target.should be true
120
+ expect(target).to receive(:save).with(:validate => false).and_return(true)
121
+ expect(mapper.save_target).to eq true
119
122
  end
120
123
  end
121
124
 
@@ -123,28 +126,28 @@ module FlatMap
123
126
  let(:params){{ :attr_a => 'A' }}
124
127
 
125
128
  it 'should write params first' do
126
- mapper.should_receive(:write).with(params)
127
- ActiveRecord::Base.should_receive(:transaction).and_yield
129
+ expect(mapper).to receive(:write).with(params)
130
+ expect(ActiveRecord::Base).to receive(:transaction).and_yield
128
131
  mapper.apply(params)
129
132
  end
130
133
 
131
134
  it 'should not save if not valid' do
132
- mapper.stub(:valid?).and_return(false)
133
- mapper.should_not_receive(:save)
135
+ expect(mapper).to receive(:valid?).and_return(false)
136
+ expect(mapper).not_to receive(:save)
134
137
  mapper.apply(params)
135
138
  end
136
139
 
137
140
  it 'should save if valid' do
138
- mapper.stub(:valid?).and_return(true)
139
- ActiveRecord::Base.should_receive(:transaction).and_yield
140
- mapper.should_receive(:save)
141
+ expect(mapper).to receive(:valid?).and_return(true)
142
+ expect(ActiveRecord::Base).to receive(:transaction).and_yield
143
+ expect(mapper).to receive(:save)
141
144
  mapper.apply(params)
142
145
  end
143
146
  end
144
147
 
145
148
  specify '#shallow_save saves target in a save callbacks' do
146
- mapper.should_receive(:run_callbacks).with(:save).and_yield
147
- mapper.should_receive(:save_target)
149
+ expect(mapper).to receive(:run_callbacks).with(:save).and_yield
150
+ expect(mapper).to receive(:save_target)
148
151
  mapper.shallow_save
149
152
  end
150
153
  end
@@ -28,22 +28,22 @@ module FlatMap
28
28
  before{ mapper.trait(:with_trait).skip! }
29
29
 
30
30
  it 'should completely ignore skipped mounting' do
31
- mapper.should be_valid
32
- mapper.save.should be true
33
- mapper.attr_a.should be_nil
34
- mapper.attr_b.should be_nil
31
+ expect(mapper ).to be_valid
32
+ expect(mapper.save ).to be true
33
+ expect(mapper.attr_a).to be_nil
34
+ expect(mapper.attr_b).to be_nil
35
35
  end
36
36
 
37
37
  it '#use! should enable skipped mounting' do
38
38
  mapper.trait(:with_trait).use!
39
39
 
40
- mapper.should_not be_valid
41
- mapper.attr_a.should == 'a'
42
- mapper.errors[:attr_a].should be_present
40
+ expect(mapper).not_to be_valid
41
+ expect(mapper.attr_a).to eq 'a'
42
+ expect(mapper.errors[:attr_a]).to be_present
43
43
 
44
44
  mapper.attr_a = 5
45
45
  mapper.save
46
- mapper.attr_b.should == 'b'
46
+ expect(mapper.attr_b).to eq 'b'
47
47
  end
48
48
  end
49
49
 
@@ -51,39 +51,40 @@ module FlatMap
51
51
  let(:target){ OpenStruct.new }
52
52
  let(:mapper){ SkippingSpec::SpecMapper.new(target, :with_trait) }
53
53
 
54
- before{ target.stub(:is_a?).with(ActiveRecord::Base).and_return(true) }
54
+ before{ expect(target).
55
+ to receive(:is_a?).at_least(1).times.with(ActiveRecord::Base).and_return(true) }
55
56
 
56
57
  context 'for new record' do
57
58
  before do
58
- target.stub(:new_record?).and_return(true)
59
+ expect(target).to receive(:new_record?).at_least(1).times.and_return(true)
59
60
  mapper.trait(:with_trait).skip!
60
61
  end
61
62
 
62
63
  specify '#skip! should set ivar @destroyed to true' do
63
- target.instance_variable_get('@destroyed').should be true
64
+ expect(target.instance_variable_get('@destroyed')).to be true
64
65
  end
65
66
 
66
67
  specify '#use! should set ivar @destroyed to true' do
67
68
  mapper.trait(:with_trait).use!
68
- target.instance_variable_get('@destroyed').should be false
69
+ expect(target.instance_variable_get('@destroyed')).to be false
69
70
  end
70
71
  end
71
72
 
72
73
  context 'for persisted record' do
73
74
  before do
74
- target.stub(:new_record?).and_return(false)
75
+ expect(target).to receive(:new_record?).at_least(1).times.and_return(false)
75
76
  end
76
77
 
77
78
  specify '#skip! should reload persisted record' do
78
- target.should_receive(:reload)
79
+ expect(target).to receive(:reload)
79
80
  mapper.trait(:with_trait).skip!
80
81
  end
81
82
 
82
83
  specify '#use! should use all nested mountings' do
83
84
  mapper.trait(:with_trait).skip!
84
85
  mock = double('mounting')
85
- mock.should_receive(:use!)
86
- mapper.trait(:with_trait).stub(:all_nested_mountings).and_return([mock])
86
+ expect(mock).to receive(:use!)
87
+ expect(mapper.trait(:with_trait)).to receive(:all_nested_mountings).and_return([mock])
87
88
  mapper.trait(:with_trait).use!
88
89
  end
89
90
  end
@@ -29,24 +29,23 @@ module FlatMap
29
29
  describe 'Working with Target' do
30
30
  describe '#target_class' do
31
31
  it 'should detect target_class from mapper class name' do
32
- ModelMethodsSpec::TargetClassMapper.target_class.should == ModelMethodsSpec::TargetClass
32
+ expect(ModelMethodsSpec::TargetClassMapper.target_class).to eq ModelMethodsSpec::TargetClass
33
33
  end
34
34
 
35
35
  it 'should detect target_class from nearest ancestor when inherited' do
36
- ModelMethodsSpec::InheritedClassMapper.target_class.
37
- should == ModelMethodsSpec::TargetClass
36
+ expect(ModelMethodsSpec::InheritedClassMapper.target_class.ancestors).
37
+ to include ModelMethodsSpec::TargetClass
38
38
  end
39
39
 
40
40
  it 'should use explicit class name if specified' do
41
- ModelMethodsSpec::ExplicitNameMapper.target_class.
42
- should == ModelMethodsSpec::OtherTargetClass
41
+ expect(ModelMethodsSpec::ExplicitNameMapper.target_class.ancestors).
42
+ to include ModelMethodsSpec::OtherTargetClass
43
43
  end
44
44
  end
45
45
 
46
46
  describe '.build' do
47
47
  it 'should use target class to build a new object for mapper' do
48
- ModelMethodsSpec::TargetClassMapper.
49
- should_receive(:new).
48
+ expect(ModelMethodsSpec::TargetClassMapper).to receive(:new).
50
49
  with(kind_of(ModelMethodsSpec::TargetClass), :used_trait)
51
50
  ModelMethodsSpec::TargetClassMapper.build(:used_trait)
52
51
  end
@@ -56,8 +55,8 @@ module FlatMap
56
55
  let(:target){ ModelMethodsSpec::TargetClass.new('a', 'b') }
57
56
 
58
57
  it 'should delegate to target class to find object for mapper' do
59
- ModelMethodsSpec::TargetClass.should_receive(:find).with(1).and_return(target)
60
- ModelMethodsSpec::TargetClassMapper.should_receive(:new).with(target, :used_trait)
58
+ expect(ModelMethodsSpec::TargetClass).to receive(:find).with(1).and_return(target)
59
+ expect(ModelMethodsSpec::TargetClassMapper).to receive(:new).with(target, :used_trait)
61
60
  ModelMethodsSpec::TargetClassMapper.find(1, :used_trait)
62
61
  end
63
62
  end
@@ -67,30 +66,30 @@ module FlatMap
67
66
  let(:mapper){ ModelMethodsSpec::TargetClassMapper.new(target){} }
68
67
 
69
68
  specify '#model_name' do
70
- mapper.model_name.should == 'mapper'
69
+ expect(mapper.model_name).to respond_to :human
71
70
  end
72
71
 
73
72
  specify '#to_key should delegate to target' do
74
- target.should_receive(:to_key).and_return(1)
75
- mapper.to_key.should == 1
73
+ expect(target).to receive(:to_key).and_return(1)
74
+ expect(mapper.to_key).to eq 1
76
75
  end
77
76
 
78
77
  specify '#persisted? when target does not respond to :persised?' do
79
- mapper.should_not be_persisted
78
+ expect(mapper).not_to be_persisted
80
79
  end
81
80
 
82
81
  specify '#persisted? when target responds to :persisted?' do
83
- target.stub(:persisted?).and_return(true)
84
- mapper.should be_persisted
82
+ expect(target).to receive(:persisted?).and_return(true)
83
+ expect(mapper).to be_persisted
85
84
  end
86
85
 
87
86
  specify '#id when target does not respond to :id' do
88
- mapper.id.should be_nil
87
+ expect(mapper.id).to be_nil
89
88
  end
90
89
 
91
90
  specify '#id when target responds to :id' do
92
- target.stub(:id).and_return(1)
93
- mapper.id.should == 1
91
+ expect(target).to receive(:id).and_return(1)
92
+ expect(mapper.id).to eq 1
94
93
  end
95
94
 
96
95
  describe '#write with multiparams' do
@@ -103,23 +102,23 @@ module FlatMap
103
102
 
104
103
  it 'should assign values properly' do
105
104
  mapper.write(params)
106
- target.attr_a.should == 'A'
107
- target.attr_b.should == Date.new(1999, 1, 2)
105
+ expect(target.attr_a).to eq 'A'
106
+ expect(target.attr_b).to eq Date.new(1999, 1, 2)
108
107
  end
109
108
  end
110
109
 
111
110
  describe '#save_target' do
112
111
  it 'should return true for owned mappers' do
113
- mapper.extension.save_target.should be true
112
+ expect(mapper.extension.save_target).to be true
114
113
  end
115
114
 
116
115
  it 'should return true if target does not respond to #save' do
117
- mapper.save_target.should be true
116
+ expect(mapper.save_target).to be true
118
117
  end
119
118
 
120
119
  it 'should save with no validation if target responds to #save' do
121
- target.should_receive(:save).with(:validate => false).and_return(true)
122
- mapper.save_target.should be true
120
+ expect(target).to receive(:save).with(:validate => false).and_return(true)
121
+ expect(mapper.save_target).to be true
123
122
  end
124
123
  end
125
124
 
@@ -127,28 +126,28 @@ module FlatMap
127
126
  let(:params){{ :attr_a => 'A' }}
128
127
 
129
128
  it 'should write params first' do
130
- mapper.should_receive(:write).with(params)
131
- ActiveRecord::Base.should_receive(:transaction).and_yield
129
+ expect(mapper).to receive(:write).with(params)
130
+ expect(ActiveRecord::Base).to receive(:transaction).and_yield
132
131
  mapper.apply(params)
133
132
  end
134
133
 
135
134
  it 'should not save if not valid' do
136
- mapper.stub(:valid?).and_return(false)
137
- mapper.should_not_receive(:save)
135
+ expect(mapper).to receive(:valid?).and_return(false)
136
+ expect(mapper).not_to receive(:save)
138
137
  mapper.apply(params)
139
138
  end
140
139
 
141
140
  it 'should save if valid' do
142
- mapper.stub(:valid?).and_return(true)
143
- ActiveRecord::Base.should_receive(:transaction).and_yield
144
- mapper.should_receive(:save)
141
+ expect(mapper).to receive(:valid?).and_return(true)
142
+ expect(ActiveRecord::Base).to receive(:transaction).and_yield
143
+ expect(mapper).to receive(:save)
145
144
  mapper.apply(params)
146
145
  end
147
146
  end
148
147
 
149
148
  specify '#shallow_save saves target in a save callbacks' do
150
- mapper.should_receive(:run_callbacks).with(:save).and_yield
151
- mapper.should_receive(:save_target)
149
+ expect(mapper).to receive(:run_callbacks).with(:save).and_yield
150
+ expect(mapper).to receive(:save_target)
152
151
  mapper.shallow_save
153
152
  end
154
153
  end
@@ -51,14 +51,14 @@ module FlatMap
51
51
  describe 'Traits' do
52
52
  describe 'trait definition' do
53
53
  it "should add a traited mapper factory to a class" do
54
- TraitsSpec::EmptyMapper.should_receive(:mount).
54
+ expect(TraitsSpec::EmptyMapper).to receive(:mount).
55
55
  with(kind_of(Class), :trait_name => :a_trait).
56
56
  and_call_original
57
57
  expect{ TraitsSpec::EmptyMapper.trait(:a_trait) }.
58
58
  to change{ TraitsSpec::EmptyMapper.mountings.length }.by(1)
59
59
  trait_mapper_class =
60
60
  TraitsSpec::EmptyMapper.mountings.first.instance_variable_get('@identifier')
61
- trait_mapper_class.name.should == 'FlatMap::TraitsSpec::EmptyMapperATraitTrait'
61
+ expect(trait_mapper_class.name).to eq 'FlatMap::TraitsSpec::EmptyMapperATraitTrait'
62
62
  end
63
63
  end
64
64
 
@@ -79,25 +79,25 @@ module FlatMap
79
79
  end
80
80
 
81
81
  it 'should be able to access trait by name' do
82
- mapper.trait(:trait_one).should be_a(Mapper)
83
- mapper.trait(:undefined).should be_nil
82
+ expect(mapper.trait(:trait_one)).to be_a(Mapper)
83
+ expect(mapper.trait(:undefined)).to be_nil
84
84
  end
85
85
 
86
86
  it 'should not contain unused trait' do
87
- mapper.trait(:trait_two).should be_nil
87
+ expect(mapper.trait(:trait_two)).to be_nil
88
88
  end
89
89
 
90
90
  it 'should have mountings of a trait' do
91
- mapper.mounting(:spec_mount).should be_present
91
+ expect(mapper.mounting(:spec_mount)).to be_present
92
92
  end
93
93
 
94
94
  it '#read should read values with respect to trait' do
95
- mapper.read.should == {
95
+ expect(mapper.read).to eq({
96
96
  :attr_a => 'a',
97
97
  :attr_b => 'b',
98
98
  :attr_c => 'c',
99
99
  :attr_d => 'd'
100
- }
100
+ })
101
101
  end
102
102
 
103
103
  it '#write should properly distribute values' do
@@ -106,33 +106,33 @@ module FlatMap
106
106
  :attr_b => 'B',
107
107
  :attr_c => 'C',
108
108
  :attr_d => 'D'
109
- target.attr_a.should == 'A'
110
- target.attr_b.should == 'B'
111
- mount_target.attr_c.should == 'C'
112
- mount_target.attr_d.should == 'D'
109
+ expect(target.attr_a ).to eq 'A'
110
+ expect(target.attr_b ).to eq 'B'
111
+ expect(mount_target.attr_c).to eq 'C'
112
+ expect(mount_target.attr_d).to eq 'D'
113
113
  end
114
114
 
115
115
  specify 'mapper should be avle to call methods of enabled traits' do
116
116
  mapper = TraitsSpec::HostMapper.new(target, :trait_one)
117
- mapper.method_one.should == 'one'
117
+ expect(mapper.method_one).to eq 'one'
118
118
  expect{ mapper.method_two }.to raise_error(NoMethodError)
119
119
  end
120
120
 
121
121
  specify 'traits should be able to call methods of each other' do
122
122
  mapper = TraitsSpec::HostMapper.new(target, :trait_one, :trait_two)
123
- mapper.trait(:trait_two).method_two.should == 'one'
123
+ expect(mapper.trait(:trait_two).method_two).to eq 'one'
124
124
  end
125
125
 
126
126
  describe 'trait nesting' do
127
127
  let(:mapper){ TraitsSpec::HostMapper.new(target, :trait_one_nested) }
128
128
 
129
129
  it 'should still be able to have top-level trait definitions' do
130
- mapper.mounting(:spec_mount).should be_present
131
- mapper.method_one.should == 'one'
130
+ expect(mapper.mounting(:spec_mount)).to be_present
131
+ expect(mapper.method_one).to eq 'one'
132
132
  end
133
133
 
134
134
  it 'should have new definitions' do
135
- mapper.method_one_nested.should == 'nested_one'
135
+ expect(mapper.method_one_nested).to eq 'nested_one'
136
136
  end
137
137
  end
138
138
 
@@ -150,21 +150,21 @@ module FlatMap
150
150
  end
151
151
 
152
152
  it 'should behave like a normal trait' do
153
- mapper.trait(:extension).should be_present
154
- mapper.read.should include :attr_b => 'b'
153
+ expect(mapper.trait(:extension)).to be_present
154
+ expect(mapper.read).to include :attr_b => 'b'
155
155
  end
156
156
 
157
157
  it 'should be accessible' do
158
- mapper.extension.should be_present
158
+ expect(mapper.extension).to be_present
159
159
  end
160
160
 
161
161
  it 'should be_extension' do
162
- mapper.extension.should be_extension
162
+ expect(mapper.extension).to be_extension
163
163
  end
164
164
 
165
165
  it "should be able to handle save exception of traits" do
166
166
  expect{ mapper.apply(:writing_error => 'foo') }.not_to raise_error
167
- mapper.errors[:writing_error].should include 'cannot be foo'
167
+ expect(mapper.errors[:writing_error]).to include 'cannot be foo'
168
168
  end
169
169
  end
170
170
  end
@@ -52,21 +52,21 @@ module FlatMap
52
52
  end
53
53
 
54
54
  it 'should not be valid' do
55
- mapper.should_not be_valid
55
+ expect(mapper).not_to be_valid
56
56
  end
57
57
 
58
58
  it 'should call callbacks' do
59
- mapper.trait(:with_trait).should_receive(:set_default_attr_b).and_call_original
59
+ expect(mapper.trait(:with_trait)).to receive(:set_default_attr_b).and_call_original
60
60
  mapper.valid?
61
- mapper.attr_b.should == 'foo'
61
+ expect(mapper.attr_b).to eq 'foo'
62
62
  end
63
63
 
64
64
  it 'should have all the errors' do
65
65
  mapper.valid?
66
- mapper.errors[:attr_a].should == ["can't be blank"]
67
- mapper.errors[:attr_b].should == ["can't be foo"]
68
- mapper.errors[:attr_c].should == ["can't be blank"]
69
- mapper.errors[:attr_d].should == ["can't be blank"]
66
+ expect(mapper.errors[:attr_a]).to eq ["can't be blank"]
67
+ expect(mapper.errors[:attr_b]).to eq ["can't be foo"]
68
+ expect(mapper.errors[:attr_c]).to eq ["can't be blank"]
69
+ expect(mapper.errors[:attr_d]).to eq ["can't be blank"]
70
70
  end
71
71
  end
72
72
  end
@@ -5,7 +5,7 @@ describe FlatMap::Mapping::Factory do
5
5
 
6
6
  specify('#create should delegate all initialization params to new mapping') do
7
7
  mapper_stub = double('mapper')
8
- FlatMap::Mapping.should_receive(:new).with(mapper_stub, :foo, :bar, :baz)
8
+ expect(FlatMap::Mapping).to receive(:new).with(mapper_stub, :foo, :bar, :baz)
9
9
 
10
10
  factory.create(mapper_stub)
11
11
  end