zertico 1.3.0 → 2.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.hound.yml +17 -0
  4. data/.travis.yml +36 -23
  5. data/CHANGELOG.md +103 -0
  6. data/README.md +39 -19
  7. data/gemfiles/Gemfile.rails3-ruby1.8.7 +7 -0
  8. data/gemfiles/Gemfile.rails3-ruby1.9.2+ +6 -0
  9. data/gemfiles/Gemfile.rails4-ruby1.9.2+ +5 -0
  10. data/lib/zertico.rb +1 -0
  11. data/lib/zertico/controller.rb +24 -16
  12. data/lib/zertico/delegator.rb +12 -5
  13. data/lib/zertico/exceptions.rb +1 -0
  14. data/lib/zertico/exceptions/missing_strong_parameters.rb +9 -0
  15. data/lib/zertico/interactor.rb +15 -2
  16. data/lib/zertico/organizer.rb +7 -5
  17. data/lib/zertico/permitted_params.rb +21 -0
  18. data/lib/zertico/responder.rb +16 -31
  19. data/lib/zertico/responder/force_redirect.rb +34 -0
  20. data/lib/zertico/responder/pjax.rb +13 -0
  21. data/lib/zertico/service.rb +5 -62
  22. data/lib/zertico/service/class_methods.rb +29 -0
  23. data/lib/zertico/service/instance_methods.rb +60 -0
  24. data/lib/zertico/version.rb +1 -1
  25. data/spec/fake_app/app/controllers/admin/user_controller.rb +6 -0
  26. data/spec/fake_app/app/controllers/application_controller.rb +7 -0
  27. data/spec/fake_app/app/controllers/person/gifts_controller.rb +6 -0
  28. data/spec/fake_app/app/controllers/person/profile_controller.rb +6 -0
  29. data/spec/fake_app/app/controllers/user_controller.rb +2 -0
  30. data/spec/fake_app/app/controllers/users_controller.rb +7 -0
  31. data/spec/fake_app/{delegators → app/delegators}/admin/user_delegator.rb +0 -0
  32. data/spec/fake_app/{delegators → app/delegators}/profile/profile_delegator.rb +0 -0
  33. data/spec/fake_app/{delegators → app/delegators}/user_delegator.rb +0 -0
  34. data/spec/fake_app/{interactors → app/interactors}/create_invoice_interactor.rb +0 -0
  35. data/spec/fake_app/{interactors → app/interactors}/create_product_interactor.rb +0 -0
  36. data/spec/fake_app/{interactors → app/interactors}/create_user_interactor.rb +0 -0
  37. data/spec/fake_app/{interactors → app/interactors}/send_welcome_email_interactor.rb +0 -0
  38. data/spec/fake_app/{interfaces → app/interfaces}/invoice.rb +0 -0
  39. data/spec/fake_app/{interfaces → app/interfaces}/person/profile.rb +0 -0
  40. data/spec/fake_app/{interfaces → app/interfaces}/product.rb +0 -0
  41. data/spec/fake_app/app/interfaces/user.rb +32 -0
  42. data/spec/fake_app/{organizers → app/organizers}/buy_product_organizer.rb +0 -0
  43. data/spec/fake_app/{organizers → app/organizers}/register_organizer.rb +0 -0
  44. data/spec/fake_app/app/permitted_params/users_permitted_params.rb +9 -0
  45. data/spec/fake_app/app/responders/users_responder.rb +5 -0
  46. data/spec/fake_app/app/services/admin/user_service.rb +6 -0
  47. data/spec/fake_app/app/services/person/gifts_service.rb +4 -0
  48. data/spec/fake_app/app/services/person/profile_service.rb +4 -0
  49. data/spec/fake_app/app/services/user_service.rb +5 -0
  50. data/spec/fake_app/app/services/users_service.rb +3 -0
  51. data/spec/fake_app/app/views/layouts/application.html.erb +1 -0
  52. data/spec/fake_app/app/views/users/edit.html.erb +0 -0
  53. data/spec/fake_app/app/views/users/index.html.erb +0 -0
  54. data/spec/fake_app/app/views/users/new.html.erb +0 -0
  55. data/spec/fake_app/app/views/users/show.html.erb +0 -0
  56. data/spec/fake_app/config/application.rb +10 -0
  57. data/spec/fake_app/config/routes.rb +3 -0
  58. data/spec/fake_app/config/secrets.yml +4 -0
  59. data/spec/spec_helper.rb +17 -3
  60. data/spec/zertico/controller_integration_spec.rb +92 -0
  61. data/spec/zertico/controller_spec.rb +14 -151
  62. data/spec/zertico/delegator_spec.rb +60 -11
  63. data/spec/zertico/interactor_spec.rb +41 -1
  64. data/spec/zertico/organizer_spec.rb +21 -4
  65. data/spec/zertico/permitted_params_spec.rb +25 -0
  66. data/spec/zertico/responder_spec.rb +234 -0
  67. data/spec/zertico/service/class_methods_spec.rb +36 -0
  68. data/spec/zertico/service/instance_methods_spec.rb +218 -0
  69. data/zertico.gemspec +10 -2
  70. metadata +139 -55
  71. data/gemfiles/Gemfile.rails3.1 +0 -5
  72. data/gemfiles/Gemfile.rails3.2 +0 -5
  73. data/gemfiles/Gemfile.rails4.0 +0 -5
  74. data/gemfiles/Gemfile.rails4.1 +0 -5
  75. data/spec/fake_app/controllers/admin/user_controller.rb +0 -4
  76. data/spec/fake_app/controllers/profile/profile_controller.rb +0 -4
  77. data/spec/fake_app/controllers/user_controller.rb +0 -2
  78. data/spec/fake_app/controllers/users_controller.rb +0 -2
  79. data/spec/fake_app/interfaces/user.rb +0 -9
  80. data/spec/fake_app/services/admin/user_service.rb +0 -8
  81. data/spec/fake_app/services/person/profile_service.rb +0 -5
  82. data/spec/fake_app/services/user_service.rb +0 -6
  83. data/spec/zertico/service_spec.rb +0 -162
@@ -3,8 +3,48 @@ require 'spec_helper'
3
3
  describe Zertico::Interactor do
4
4
  let(:interactor) { Zertico::Interactor.new }
5
5
 
6
+ describe '#perform' do
7
+ it 'should raise a rollback exception' do
8
+ expect { interactor.perform({}) }.to raise_error
9
+ end
10
+ end
11
+
12
+ describe '#rollback' do
13
+ it 'should return true' do
14
+ expect(interactor.rollback).to eq(true)
15
+ end
16
+ end
17
+
18
+ describe '#inject_instances' do
19
+ before :each do
20
+ interactor.inject_instances({ 'a' => 'B' })
21
+ end
22
+
23
+ it 'should create instances based on a hash' do
24
+ expect(interactor.instance_variable_get('@a')).to eq('B')
25
+ end
26
+ end
27
+
28
+ describe '#get_instances' do
29
+ before :each do
30
+ interactor.instance_variable_set('@a', 'A')
31
+ interactor.instance_variable_set('@b', 'B')
32
+ interactor.instance_variable_set('@z', 'Z')
33
+ end
34
+
35
+ it 'should return a hash with all instance variables name and value' do
36
+ expect(interactor.get_instances).to eq({ 'a' => 'A', 'b' => 'B', 'z' => 'Z' })
37
+ end
38
+ end
39
+
40
+ describe '.interface_name' do
41
+ it 'should return the interface name' do
42
+ expect(Zertico::Interactor.interface_name).to eq('Zertico')
43
+ end
44
+ end
45
+
6
46
  describe '#fail' do
7
- it 'should raise the interactor exception' do
47
+ it 'should raise a rollback exception' do
8
48
  expect { interactor.fail! }.to raise_error
9
49
  end
10
50
  end
@@ -6,20 +6,37 @@ describe Zertico::Organizer do
6
6
 
7
7
  describe '.organize' do
8
8
  it 'should set the interactors to organize' do
9
- successful_organizer.interactors_classes.should == [ CreateProductInteractor, CreateInvoiceInteractor ]
9
+ expect(successful_organizer.interactors_classes).to eq([ CreateProductInteractor, CreateInvoiceInteractor ])
10
+ end
11
+
12
+ it 'should initialize the performed interactors array' do
13
+ expect(successful_organizer.performed).to eq([])
14
+ end
15
+
16
+ it 'should initialize the instance objects hash' do
17
+ expect(successful_organizer.instances).to eq({})
10
18
  end
11
19
  end
12
20
 
13
21
  describe '.perform' do
14
22
  context 'with success' do
15
23
  it 'should return true' do
16
- successful_organizer.perform({}).should be_true
24
+ expect(successful_organizer.perform({})).to eq(true)
25
+ end
26
+
27
+ before :each do
28
+ @organizer = successful_organizer
29
+ @organizer.perform({})
30
+ end
31
+
32
+ it 'should set the pass the instances to the interactors' do
33
+ expect(@organizer.performed.last.instance_variable_get('@product')).to be_an_instance_of(Product)
17
34
  end
18
35
  end
19
36
 
20
37
  context 'with failure' do
21
38
  it "should return a mapping with the interactor's rollback results" do
22
- failed_organizer.perform({}).should == [true]
39
+ expect(failed_organizer.perform({})).to eq([true])
23
40
  end
24
41
  end
25
42
  end
@@ -27,7 +44,7 @@ describe Zertico::Organizer do
27
44
  describe '#rollback' do
28
45
  context 'when it raise an exception' do
29
46
  it "should return a mapping with the interactor's rollback results" do
30
- failed_organizer.rollback.should == [true]
47
+ expect(failed_organizer.rollback).to eq([true])
31
48
  end
32
49
  end
33
50
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Zertico::PermittedParams do
4
+ let(:user) { User.new }
5
+ let(:params) { ActionController::Parameters.new(:user => { :id => 1, :name => "name" }) }
6
+ let(:user_permitted_params) { UsersPermittedParams.new(params) }
7
+
8
+ describe '#create' do
9
+ it "should ignore the id" do
10
+ expect(user_permitted_params.create).to eq({ 'name' => 'name' })
11
+ end
12
+ end
13
+
14
+ describe '#update' do
15
+ it "should ignore the name" do
16
+ expect(user_permitted_params.update).to eq({ 'id' => 1 })
17
+ end
18
+ end
19
+
20
+ describe '.interface_class' do
21
+ it 'should return the interface singular name ' do
22
+ expect(UsersPermittedParams.interface_class).to eq(User)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,234 @@
1
+ require 'spec_helper'
2
+ require 'rspec/rails'
3
+
4
+ describe UsersResponder, :type => :controller do
5
+ let(:controller) { UsersController.new }
6
+ let(:user) { User.new }
7
+
8
+ before :each do @controller = controller; end
9
+
10
+ render_views
11
+
12
+ describe '#index' do
13
+ context 'from normal requisition' do
14
+ before :each do
15
+ get :index
16
+ end
17
+
18
+ it 'should have an HTTP status :ok' do
19
+ expect(response).to have_http_status(:ok)
20
+ end
21
+
22
+ it 'should render template index' do
23
+ expect(response).to render_template(:index)
24
+ end
25
+
26
+ it 'should render the application layout' do
27
+ expect(response).to render_template(:layout => 'application')
28
+ end
29
+ end
30
+
31
+ context 'from pjax' do
32
+ before :each do
33
+ request.env['X-PJAX'] = 'true' # For Rails 3.2
34
+ request.headers['X-PJAX'] = 'true'
35
+ get :index
36
+ end
37
+
38
+ it 'should not render any layout' do
39
+ expect(response).to render_template(:layout => false)
40
+ end
41
+ end
42
+ end
43
+
44
+ describe '#new' do
45
+ context 'from normal requisition' do
46
+ before :each do
47
+ get :new
48
+ end
49
+
50
+ it 'should have an HTTP status :ok' do
51
+ expect(response).to have_http_status(:ok)
52
+ end
53
+
54
+ it 'should render template new' do
55
+ expect(response).to render_template(:new)
56
+ end
57
+
58
+ it 'should render the application layout' do
59
+ expect(response).to render_template(:layout => 'application')
60
+ end
61
+ end
62
+
63
+ context 'from pjax' do
64
+ before :each do
65
+ request.env['X-PJAX'] = 'true' # For Rails 3.2
66
+ request.headers['X-PJAX'] = 'true'
67
+ get :new
68
+ end
69
+
70
+ it 'should not render any layout' do
71
+ expect(response).to render_template(:layout => false)
72
+ end
73
+ end
74
+ end
75
+
76
+ describe '#show' do
77
+ context 'from normal requisition' do
78
+ before :each do
79
+ get :show, :id => 1
80
+ end
81
+
82
+ it 'should have an HTTP status :ok' do
83
+ expect(response).to have_http_status(:ok)
84
+ end
85
+
86
+ it 'should render template show' do
87
+ expect(response).to render_template(:show)
88
+ end
89
+
90
+ it 'should render the application layout' do
91
+ expect(response).to render_template(:layout => 'application')
92
+ end
93
+ end
94
+
95
+ context 'from pjax' do
96
+ before :each do
97
+ request.env['X-PJAX'] = 'true' # For Rails 3.2
98
+ request.headers['X-PJAX'] = 'true'
99
+ get :show, :id => 1
100
+ end
101
+
102
+ it 'should not render any layout' do
103
+ expect(response).to render_template(:layout => false)
104
+ end
105
+ end
106
+ end
107
+
108
+ describe '#edit' do
109
+ context 'from normal requisition' do
110
+ before :each do
111
+ get :edit, :id => 1
112
+ end
113
+
114
+ it 'should have an HTTP status :ok' do
115
+ expect(response).to have_http_status(:ok)
116
+ end
117
+
118
+ it 'should render template edit' do
119
+ expect(response).to render_template(:edit)
120
+ end
121
+
122
+ it 'should render the application layout' do
123
+ expect(response).to render_template(:layout => 'application')
124
+ end
125
+ end
126
+
127
+ context 'from pjax' do
128
+ before :each do
129
+ request.env['X-PJAX'] = 'true' # For Rails 3.2
130
+ request.headers['X-PJAX'] = 'true'
131
+ get :edit, :id => 1
132
+ end
133
+
134
+ it 'should not render any layout' do
135
+ expect(response).to render_template(:layout => false)
136
+ end
137
+ end
138
+ end
139
+
140
+ describe '#create' do
141
+ context 'when successfull saving' do
142
+ before :each do
143
+ post :create, :user => { :name => 'name' }
144
+ end
145
+
146
+ it 'should have an HTTP status :found' do
147
+ expect(response).to have_http_status(:found)
148
+ end
149
+
150
+ it 'should redirect to #show' do
151
+ expect(response).to redirect_to(:action => :index)
152
+ end
153
+ end
154
+
155
+ context 'when fail to save' do
156
+ before :each do
157
+ allow(User).to receive(:create).and_return(user)
158
+ allow(user).to receive(:errors).and_return(['asd'])
159
+ post :create, :user => { :name => 'name' }
160
+ end
161
+
162
+ it 'should have an HTTP status :ok' do
163
+ expect(response).to have_http_status(:ok)
164
+ end
165
+
166
+ it 'should render template new' do
167
+ expect(response).to render_template(:new)
168
+ end
169
+ end
170
+ end
171
+
172
+ describe '#update' do
173
+ context 'when successfull updating' do
174
+ before :each do
175
+ allow(User).to receive(:find).and_return(user)
176
+ allow(user).to receive(:id).and_return(3)
177
+ put :update, :id => 1, :user => { :name => 'name' }
178
+ end
179
+
180
+ it 'should have an HTTP status :found' do
181
+ expect(response).to have_http_status(:found)
182
+ end
183
+
184
+ it 'should redirect to #show' do
185
+ expect(response).to redirect_to(:action => :show, :id => 3)
186
+ end
187
+ end
188
+
189
+ context 'when fail to save' do
190
+ before :each do
191
+ allow(User).to receive(:find).and_return(user)
192
+ allow(user).to receive(:id).and_return(3)
193
+ allow(user).to receive(:errors).and_return(['asd'])
194
+ put :update, :id => 1, :user => { :name => 'name' }
195
+ end
196
+
197
+ it 'should have an HTTP status :ok' do
198
+ expect(response).to have_http_status(:ok)
199
+ end
200
+
201
+ it 'should render template edit' do
202
+ expect(response).to render_template(:edit)
203
+ end
204
+ end
205
+ end
206
+
207
+ describe '#destroy' do
208
+ before :each do
209
+ delete :destroy, :id => 1
210
+ end
211
+
212
+ it 'should have an HTTP status :found' do
213
+ expect(response).to have_http_status(:found)
214
+ end
215
+
216
+ it 'should render template edit' do
217
+ expect(response).to redirect_to(:action => :index)
218
+ end
219
+ end
220
+
221
+ %w(index new edit create show destroy).each do |method_name|
222
+ describe "##{method_name}_options=" do
223
+ it "should set an hash of options for #{method_name} action" do
224
+ expect(controller.responder.send("#{method_name}_options", controller)).to eq({})
225
+ end
226
+ end
227
+
228
+ describe "##{method_name}_options" do
229
+ it "should return a hash of options for #{method_name} action" do
230
+ expect(controller.responder.send("#{method_name}_options", controller)).to eq({})
231
+ end
232
+ end
233
+ end
234
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Zertico::Service do
4
+ let(:user) { User.new }
5
+ let(:service_class) { UserService }
6
+ let(:service) { UserService.new }
7
+
8
+ describe '.use_as_id' do
9
+ it 'should define the id name' do
10
+ expect(service_class.interface_id).to eq('great_id')
11
+ end
12
+ end
13
+
14
+ describe '.use_as_variable_name' do
15
+ it 'should define the variable name' do
16
+ expect(service_class.interface_name).to eq('great_name')
17
+ end
18
+ end
19
+
20
+ describe '.use_interface' do
21
+ it 'should define the interface' do
22
+ expect(service_class.interface_class).to eq(Product)
23
+ end
24
+ end
25
+
26
+ describe '#resource_source=' do
27
+ before :each do
28
+ allow(User).to receive(:all).and_return([ user ])
29
+ service_class.resource_source = %w(User all)
30
+ end
31
+
32
+ it 'should set the resource' do
33
+ expect(service.resource_source).to eq([ user ])
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,218 @@
1
+ require 'spec_helper'
2
+
3
+ describe Zertico::Service do
4
+ let(:admin_service) { Admin::UserService.new }
5
+ let(:gifts_service) { Person::GiftsService.new }
6
+ let(:profile_service) { Person::ProfileService.new }
7
+ let(:object) { Object.new }
8
+ let(:users_service) { UsersService.new }
9
+ let(:user) { User.new }
10
+
11
+ before :each do
12
+ allow(User).to receive(:new).and_return(user)
13
+ end
14
+
15
+ describe '#index' do
16
+ it 'should return a collection of users' do
17
+ expect(users_service.index).to eq([user, user])
18
+ end
19
+
20
+ before :each do
21
+ users_service.index
22
+ end
23
+
24
+ it 'should save the collection in an instance variable' do
25
+ expect(users_service.users).to eq([user, user])
26
+ end
27
+ end
28
+
29
+ describe '#new' do
30
+ it 'should return a new user' do
31
+ expect(users_service.new).to eq(user)
32
+ end
33
+
34
+ before :each do
35
+ users_service.new
36
+ end
37
+
38
+ it 'should save the user in an instance variable' do
39
+ expect(users_service.user).to eq(user)
40
+ end
41
+ end
42
+
43
+ describe '#show' do
44
+ it 'should search for an user' do
45
+ expect(users_service.show({ :id => 1 })).to eq(user)
46
+ end
47
+
48
+ before :each do
49
+ users_service.show({ :id => 1 })
50
+ end
51
+
52
+ it 'should save the user found in an instance variable' do
53
+ expect(users_service.user).to eq(user)
54
+ end
55
+ end
56
+
57
+ describe '#create' do
58
+ it 'should search for an user' do
59
+ expect(users_service.create({ :user => {} })).to eq(user)
60
+ end
61
+
62
+ before :each do
63
+ users_service.create({ :user => {} })
64
+ end
65
+
66
+ it 'should save the created user in an instance variable' do
67
+ expect(users_service.user).to eq(user)
68
+ end
69
+ end
70
+
71
+ describe '#update' do
72
+ it 'should search for an user' do
73
+ expect(users_service.update({ :id => 1, :user => {} })).to eq(user)
74
+ end
75
+
76
+ before :each do
77
+ users_service.update({ :id => 1, :user => {} })
78
+ end
79
+
80
+ it 'should update the user' do
81
+ expect(users_service.user.updated).to eq(true)
82
+ end
83
+
84
+ it 'should save the updated user in an instance variable' do
85
+ expect(users_service.user).to eq(user)
86
+ end
87
+ end
88
+
89
+ describe '#destroy' do
90
+ it 'should search for an user' do
91
+ expect(users_service.destroy({ :id => 1 })).to eq(user)
92
+ end
93
+
94
+ before :each do
95
+ users_service.destroy({ :id => 1 })
96
+ end
97
+
98
+ it 'should destroy the user' do
99
+ expect(users_service.user.destroyed).to eq(true)
100
+ end
101
+
102
+ it 'should save the destroyed user in an instance variable' do
103
+ expect(users_service.user).to eq(user)
104
+ end
105
+ end
106
+
107
+ describe '#resource_source' do
108
+ context 'without a custom resource defined on class' do
109
+ it 'should return it!' do
110
+ expect(users_service.resource_source).to eq(User)
111
+ end
112
+ end
113
+
114
+ context 'with a custom resource defined on class' do
115
+ before :each do
116
+ UsersService.resource_source = [ Person::Profile ]
117
+ end
118
+
119
+ it 'should return it!' do
120
+ expect(users_service.resource_source).to eq(Person::Profile)
121
+ end
122
+ end
123
+ end
124
+
125
+ describe '#interface_id' do
126
+ context 'on a pluralized service' do
127
+ it 'should return id' do
128
+ expect(users_service.send(:interface_id)).to eq('id')
129
+ end
130
+ end
131
+
132
+ context 'on a namespaced service and interface model' do
133
+ it 'should return id with the model name' do
134
+ expect(profile_service.send(:interface_id)).to eq('person_profile_id')
135
+ end
136
+ end
137
+
138
+ context 'on a namespaced service and non namespaced interface model' do
139
+ it 'should return id with the model name' do
140
+ expect(admin_service.send(:interface_id)).to eq('user_id')
141
+ end
142
+ end
143
+
144
+ context 'on a non namespaced service and non namespaced interface model' do
145
+ it 'should return id' do
146
+ expect(users_service.send(:interface_id)).to eq('id')
147
+ end
148
+ end
149
+
150
+ context 'on a namespaced service and an undefined interface model' do
151
+ it 'should return id' do
152
+ expect(gifts_service.send(:interface_id)).to eq('id')
153
+ end
154
+ end
155
+
156
+ context 'when defined on class' do
157
+ before :each do
158
+ gifts_service.class.instance_variable_set('@interface_id', 'abc')
159
+ end
160
+
161
+ it 'should return the defined value' do
162
+ expect(gifts_service.send(:interface_id)).to eq('abc')
163
+ end
164
+ end
165
+ end
166
+
167
+ describe '#interface_name' do
168
+ it 'should return the interface name' do
169
+ expect(users_service.send(:interface_name)).to eq('user')
170
+ end
171
+
172
+ context 'when defined on class' do
173
+ before :each do
174
+ gifts_service.class.instance_variable_set('@interface_name', 'abc')
175
+ end
176
+
177
+ it 'should return the defined value' do
178
+ expect(gifts_service.send(:interface_name)).to eq('abc')
179
+ end
180
+ end
181
+ end
182
+
183
+ describe '#interface_class' do
184
+ context 'on a pluralized service' do
185
+ it 'should find the interface model' do
186
+ expect(users_service.send(:interface_class)).to eq(User)
187
+ end
188
+ end
189
+
190
+ context 'on a namespaced service and interface model' do
191
+ it 'should find the interface model' do
192
+ expect(profile_service.send(:interface_class)).to eq(Person::Profile)
193
+ end
194
+ end
195
+
196
+ context 'on a namespaced service and non namespaced interface model' do
197
+ it 'should find the interface model' do
198
+ expect(admin_service.send(:interface_class)).to eq(User)
199
+ end
200
+ end
201
+
202
+ context 'on a non namespaced service and non namespaced interface model' do
203
+ it 'should find the interface model' do
204
+ expect(users_service.send(:interface_class)).to eq(User)
205
+ end
206
+ end
207
+
208
+ context 'when defined on class' do
209
+ before :each do
210
+ gifts_service.class.instance_variable_set('@interface_class', User)
211
+ end
212
+
213
+ it 'should return the defined value' do
214
+ expect(gifts_service.send(:interface_class)).to eq(User)
215
+ end
216
+ end
217
+ end
218
+ end