zertico 2.0.0.alpha.2 → 2.0.0.alpha.3
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.
- checksums.yaml +4 -4
 - data/lib/zertico/controller.rb +1 -1
 - data/lib/zertico/service/instance_methods.rb +23 -0
 - data/lib/zertico/service.rb +3 -26
 - data/lib/zertico/version.rb +1 -1
 - data/spec/zertico/service/instance_methods_spec.rb +121 -0
 - data/spec/zertico/service_spec.rb +7 -121
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 11c1692e1a912ed1299b06de71336e7fa7074e01
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 474b9270363f5a8873af6bab6b489823c700d3fa
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 47f60cb1d5b3f3ca8a3f5a814752f3dfde063d046e97bce0a30eb5893353cc55a743fbf9c73e98235260c1890237cfe07d5fd64a2f719d6c513deb3967e74bac
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: cd6fbe21a296e58b43a54075a888c06d70e21aa9638cf5a78484f89d128fb6833aafd764c5cff56af88ba8bf88734412cb465bc9aca46bfb22067d64babb8fe2
         
     | 
    
        data/lib/zertico/controller.rb
    CHANGED
    
    | 
         @@ -52,7 +52,7 @@ module Zertico 
     | 
|
| 
       52 
52 
     | 
    
         
             
                def initialize_service
         
     | 
| 
       53 
53 
     | 
    
         
             
                  @service = "::#{self.class.name.gsub('Controller', 'Service')}".constantize.new
         
     | 
| 
       54 
54 
     | 
    
         
             
                rescue NameError
         
     | 
| 
       55 
     | 
    
         
            -
                  @service = Zertico::Service.new
         
     | 
| 
      
 55 
     | 
    
         
            +
                  @service = Zertico::Service.new(self.class.name)
         
     | 
| 
       56 
56 
     | 
    
         
             
                end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                def set_responder
         
     | 
| 
         @@ -32,6 +32,29 @@ module Zertico 
     | 
|
| 
       32 
32 
     | 
    
         
             
                  def resource_source
         
     | 
| 
       33 
33 
     | 
    
         
             
                    self.class.resource_source || interface_class
         
     | 
| 
       34 
34 
     | 
    
         
             
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  def interface_class
         
     | 
| 
      
 37 
     | 
    
         
            +
                    return self.class.interface_class unless self.class.interface_class.nil?
         
     | 
| 
      
 38 
     | 
    
         
            +
                    name.chomp('Service').singularize.constantize
         
     | 
| 
      
 39 
     | 
    
         
            +
                  rescue NameError
         
     | 
| 
      
 40 
     | 
    
         
            +
                    name.chomp('Service').split('::').last.singularize.constantize
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  def interface_name
         
     | 
| 
      
 44 
     | 
    
         
            +
                    return self.class.interface_name unless self.class.interface_name.nil?
         
     | 
| 
      
 45 
     | 
    
         
            +
                    interface_class.name.singularize.underscore
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  def interface_id
         
     | 
| 
      
 49 
     | 
    
         
            +
                    return self.class.interface_id unless self.class.interface_id.nil?
         
     | 
| 
      
 50 
     | 
    
         
            +
                    if name.split('::').size > 1
         
     | 
| 
      
 51 
     | 
    
         
            +
                      "#{interface_name.gsub('/', '_')}_id"
         
     | 
| 
      
 52 
     | 
    
         
            +
                    else
         
     | 
| 
      
 53 
     | 
    
         
            +
                      'id'
         
     | 
| 
      
 54 
     | 
    
         
            +
                    end
         
     | 
| 
      
 55 
     | 
    
         
            +
                  rescue NameError
         
     | 
| 
      
 56 
     | 
    
         
            +
                    'id'
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
       35 
58 
     | 
    
         
             
                end
         
     | 
| 
       36 
59 
     | 
    
         
             
              end
         
     | 
| 
       37 
60 
     | 
    
         
             
            end
         
     | 
    
        data/lib/zertico/service.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Zertico
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Service
         
     | 
| 
       3 
     | 
    
         
            -
                attr_reader : 
     | 
| 
      
 3 
     | 
    
         
            +
                attr_reader :name
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                autoload :ClassMethods, 'zertico/service/class_methods'
         
     | 
| 
       6 
6 
     | 
    
         
             
                autoload :InstanceMethods, 'zertico/service/instance_methods'
         
     | 
| 
         @@ -8,31 +8,8 @@ module Zertico 
     | 
|
| 
       8 
8 
     | 
    
         
             
                extend ClassMethods
         
     | 
| 
       9 
9 
     | 
    
         
             
                include InstanceMethods
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                def initialize( 
     | 
| 
       12 
     | 
    
         
            -
                  @ 
     | 
| 
       13 
     | 
    
         
            -
                  @interface_class ||= custom_interface_class
         
     | 
| 
       14 
     | 
    
         
            -
                  @interface_name = options.fetch(:interface_name, self.class.interface_name)
         
     | 
| 
       15 
     | 
    
         
            -
                  @interface_name ||= interface_class.name.singularize.underscore
         
     | 
| 
       16 
     | 
    
         
            -
                  @interface_id = options.fetch(:interface_id, self.class.interface_id)
         
     | 
| 
       17 
     | 
    
         
            -
                  @interface_id ||= custom_interface_id
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                private
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                def custom_interface_class
         
     | 
| 
       23 
     | 
    
         
            -
                  self.class.name.chomp('Service').singularize.constantize
         
     | 
| 
       24 
     | 
    
         
            -
                rescue NameError
         
     | 
| 
       25 
     | 
    
         
            -
                  self.class.name.chomp('Service').split('::').last.singularize.constantize
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                def custom_interface_id
         
     | 
| 
       29 
     | 
    
         
            -
                  if self.class.name.chomp('Controller').split('::').size > 1
         
     | 
| 
       30 
     | 
    
         
            -
                    "#{interface_name.gsub('/', '_')}_id"
         
     | 
| 
       31 
     | 
    
         
            -
                  else
         
     | 
| 
       32 
     | 
    
         
            -
                    'id'
         
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
       34 
     | 
    
         
            -
                rescue NameError
         
     | 
| 
       35 
     | 
    
         
            -
                  'id'
         
     | 
| 
      
 11 
     | 
    
         
            +
                def initialize(controller_name = nil)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @name = (controller_name or self.class.name).gsub('Controller', 'Service')
         
     | 
| 
       36 
13 
     | 
    
         
             
                end
         
     | 
| 
       37 
14 
     | 
    
         
             
              end
         
     | 
| 
       38 
15 
     | 
    
         
             
            end
         
     | 
    
        data/lib/zertico/version.rb
    CHANGED
    
    
| 
         @@ -121,4 +121,125 @@ describe Zertico::Service do 
     | 
|
| 
       121 
121 
     | 
    
         
             
                  end
         
     | 
| 
       122 
122 
     | 
    
         
             
                end
         
     | 
| 
       123 
123 
     | 
    
         
             
              end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
              describe '#interface_id' do
         
     | 
| 
      
 126 
     | 
    
         
            +
                context 'with a custom controller without a custom service' do
         
     | 
| 
      
 127 
     | 
    
         
            +
                  before :each do
         
     | 
| 
      
 128 
     | 
    
         
            +
                    @service = Zertico::Service.new('UserController')
         
     | 
| 
      
 129 
     | 
    
         
            +
                  end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                  it 'should return id' do
         
     | 
| 
      
 132 
     | 
    
         
            +
                    expect(@service.send(:interface_id)).to eq('id')
         
     | 
| 
      
 133 
     | 
    
         
            +
                  end
         
     | 
| 
      
 134 
     | 
    
         
            +
                end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                context 'on a pluralized service' do
         
     | 
| 
      
 137 
     | 
    
         
            +
                  it 'should return id' do
         
     | 
| 
      
 138 
     | 
    
         
            +
                    expect(users_service.send(:interface_id)).to eq('id')
         
     | 
| 
      
 139 
     | 
    
         
            +
                  end
         
     | 
| 
      
 140 
     | 
    
         
            +
                end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                context 'on a namespaced service and interface model' do
         
     | 
| 
      
 143 
     | 
    
         
            +
                  it 'should return id with the model name' do
         
     | 
| 
      
 144 
     | 
    
         
            +
                    expect(profile_service.send(:interface_id)).to eq('person_profile_id')
         
     | 
| 
      
 145 
     | 
    
         
            +
                  end
         
     | 
| 
      
 146 
     | 
    
         
            +
                end
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                context 'on a namespaced service and non namespaced interface model' do
         
     | 
| 
      
 149 
     | 
    
         
            +
                  it 'should return id with the model name' do
         
     | 
| 
      
 150 
     | 
    
         
            +
                    expect(admin_service.send(:interface_id)).to eq('user_id')
         
     | 
| 
      
 151 
     | 
    
         
            +
                  end
         
     | 
| 
      
 152 
     | 
    
         
            +
                end
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
                context 'on a non namespaced service and non namespaced interface model' do
         
     | 
| 
      
 155 
     | 
    
         
            +
                  it 'should return id' do
         
     | 
| 
      
 156 
     | 
    
         
            +
                    expect(users_service.send(:interface_id)).to eq('id')
         
     | 
| 
      
 157 
     | 
    
         
            +
                  end
         
     | 
| 
      
 158 
     | 
    
         
            +
                end
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                context 'when defined on class' do
         
     | 
| 
      
 161 
     | 
    
         
            +
                  before :each do
         
     | 
| 
      
 162 
     | 
    
         
            +
                    Person::GiftsService.instance_variable_set('@interface_id', 'abc')
         
     | 
| 
      
 163 
     | 
    
         
            +
                    @gifts_service = Person::GiftsService.new
         
     | 
| 
      
 164 
     | 
    
         
            +
                  end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
                  it 'should return the defined value' do
         
     | 
| 
      
 167 
     | 
    
         
            +
                    expect(@gifts_service.send(:interface_id)).to eq('abc')
         
     | 
| 
      
 168 
     | 
    
         
            +
                  end
         
     | 
| 
      
 169 
     | 
    
         
            +
                end
         
     | 
| 
      
 170 
     | 
    
         
            +
              end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
              describe '#interface_name' do
         
     | 
| 
      
 173 
     | 
    
         
            +
                context 'with a custom controller without a custom service' do
         
     | 
| 
      
 174 
     | 
    
         
            +
                  before :each do
         
     | 
| 
      
 175 
     | 
    
         
            +
                    @service = Zertico::Service.new('Person::GiftsController')
         
     | 
| 
      
 176 
     | 
    
         
            +
                  end
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
                  it 'should return it' do
         
     | 
| 
      
 179 
     | 
    
         
            +
                    expect(@service.send(:interface_name)).to eq('gift')
         
     | 
| 
      
 180 
     | 
    
         
            +
                  end
         
     | 
| 
      
 181 
     | 
    
         
            +
                end
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
                it 'should return the interface name' do
         
     | 
| 
      
 184 
     | 
    
         
            +
                  expect(users_service.send(:interface_name)).to eq('user')
         
     | 
| 
      
 185 
     | 
    
         
            +
                end
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                context 'when defined on class' do
         
     | 
| 
      
 188 
     | 
    
         
            +
                  before :each do
         
     | 
| 
      
 189 
     | 
    
         
            +
                    Person::GiftsService.instance_variable_set('@interface_name', 'abc')
         
     | 
| 
      
 190 
     | 
    
         
            +
                    @gifts_service = Person::GiftsService.new
         
     | 
| 
      
 191 
     | 
    
         
            +
                  end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                  it 'should return the defined value' do
         
     | 
| 
      
 194 
     | 
    
         
            +
                    expect(@gifts_service.send(:interface_name)).to eq('abc')
         
     | 
| 
      
 195 
     | 
    
         
            +
                  end
         
     | 
| 
      
 196 
     | 
    
         
            +
                end
         
     | 
| 
      
 197 
     | 
    
         
            +
              end
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
              describe '#interface_class' do
         
     | 
| 
      
 200 
     | 
    
         
            +
                context 'with a custom controller without a custom service' do
         
     | 
| 
      
 201 
     | 
    
         
            +
                  before :each do
         
     | 
| 
      
 202 
     | 
    
         
            +
                    @service = Zertico::Service.new('Person::Gifts')
         
     | 
| 
      
 203 
     | 
    
         
            +
                  end
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
                  it 'should return it' do
         
     | 
| 
      
 206 
     | 
    
         
            +
                    expect(@service.send(:interface_class)).to eq(Gift)
         
     | 
| 
      
 207 
     | 
    
         
            +
                  end
         
     | 
| 
      
 208 
     | 
    
         
            +
                end
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
                context 'on a pluralized service' do
         
     | 
| 
      
 211 
     | 
    
         
            +
                  it 'should find the interface model' do
         
     | 
| 
      
 212 
     | 
    
         
            +
                    expect(users_service.send(:interface_class)).to eq(User)
         
     | 
| 
      
 213 
     | 
    
         
            +
                  end
         
     | 
| 
      
 214 
     | 
    
         
            +
                end
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
                context 'on a namespaced service and interface model' do
         
     | 
| 
      
 217 
     | 
    
         
            +
                  it 'should find the interface model' do
         
     | 
| 
      
 218 
     | 
    
         
            +
                    expect(profile_service.send(:interface_class)).to eq(Person::Profile)
         
     | 
| 
      
 219 
     | 
    
         
            +
                  end
         
     | 
| 
      
 220 
     | 
    
         
            +
                end
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
                context 'on a namespaced service and non namespaced interface model' do
         
     | 
| 
      
 223 
     | 
    
         
            +
                  it 'should find the interface model' do
         
     | 
| 
      
 224 
     | 
    
         
            +
                    expect(admin_service.send(:interface_class)).to eq(User)
         
     | 
| 
      
 225 
     | 
    
         
            +
                  end
         
     | 
| 
      
 226 
     | 
    
         
            +
                end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
                context 'on a non namespaced service and non namespaced interface model' do
         
     | 
| 
      
 229 
     | 
    
         
            +
                  it 'should find the interface model' do
         
     | 
| 
      
 230 
     | 
    
         
            +
                    expect(users_service.send(:interface_class)).to eq(User)
         
     | 
| 
      
 231 
     | 
    
         
            +
                  end
         
     | 
| 
      
 232 
     | 
    
         
            +
                end
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
                context 'when defined on class' do
         
     | 
| 
      
 235 
     | 
    
         
            +
                  before :each do
         
     | 
| 
      
 236 
     | 
    
         
            +
                    Person::GiftsService.instance_variable_set('@interface_class', User)
         
     | 
| 
      
 237 
     | 
    
         
            +
                    @gifts_service = Person::GiftsService.new
         
     | 
| 
      
 238 
     | 
    
         
            +
                  end
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
                  it 'should return the defined value' do
         
     | 
| 
      
 241 
     | 
    
         
            +
                    expect(@gifts_service.send(:interface_class)).to eq(User)
         
     | 
| 
      
 242 
     | 
    
         
            +
                  end
         
     | 
| 
      
 243 
     | 
    
         
            +
                end
         
     | 
| 
      
 244 
     | 
    
         
            +
              end
         
     | 
| 
       124 
245 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,130 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe Zertico::Service do
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              let(:users_service) { UsersService.new }
         
     | 
| 
       9 
     | 
    
         
            -
              let(:user) { User.new }
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              describe '#interface_id' do
         
     | 
| 
       12 
     | 
    
         
            -
                context 'when passed to initialize' do
         
     | 
| 
       13 
     | 
    
         
            -
                  before :each do
         
     | 
| 
       14 
     | 
    
         
            -
                    @gifts_service = Person::GiftsService.new(:interface_id => 'teste')
         
     | 
| 
       15 
     | 
    
         
            -
                  end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                  it 'should return it' do
         
     | 
| 
       18 
     | 
    
         
            -
                    expect(@gifts_service.send(:interface_id)).to eq('teste')
         
     | 
| 
       19 
     | 
    
         
            -
                  end
         
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                context 'on a pluralized service' do
         
     | 
| 
       23 
     | 
    
         
            -
                  it 'should return id' do
         
     | 
| 
       24 
     | 
    
         
            -
                    expect(users_service.send(:interface_id)).to eq('id')
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                context 'on a namespaced service and interface model' do
         
     | 
| 
       29 
     | 
    
         
            -
                  it 'should return id with the model name' do
         
     | 
| 
       30 
     | 
    
         
            -
                    expect(profile_service.send(:interface_id)).to eq('person_profile_id')
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe '#initialize' do
         
     | 
| 
      
 5 
     | 
    
         
            +
                context 'with a custom controller' do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  it 'should save the name based on the controller name' do
         
     | 
| 
      
 7 
     | 
    
         
            +
                    expect(Zertico::Service.new('UsersController').name).to eq('UsersService')
         
     | 
| 
       31 
8 
     | 
    
         
             
                  end
         
     | 
| 
       32 
9 
     | 
    
         
             
                end
         
     | 
| 
       33 
10 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
                context ' 
     | 
| 
       35 
     | 
    
         
            -
                  it 'should  
     | 
| 
       36 
     | 
    
         
            -
                    expect( 
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
       38 
     | 
    
         
            -
                end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                context 'on a non namespaced service and non namespaced interface model' do
         
     | 
| 
       41 
     | 
    
         
            -
                  it 'should return id' do
         
     | 
| 
       42 
     | 
    
         
            -
                    expect(users_service.send(:interface_id)).to eq('id')
         
     | 
| 
       43 
     | 
    
         
            -
                  end
         
     | 
| 
       44 
     | 
    
         
            -
                end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                context 'when defined on class' do
         
     | 
| 
       47 
     | 
    
         
            -
                  before :each do
         
     | 
| 
       48 
     | 
    
         
            -
                    Person::GiftsService.instance_variable_set('@interface_id', 'abc')
         
     | 
| 
       49 
     | 
    
         
            -
                    @gifts_service = Person::GiftsService.new
         
     | 
| 
       50 
     | 
    
         
            -
                  end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                  it 'should return the defined value' do
         
     | 
| 
       53 
     | 
    
         
            -
                    expect(@gifts_service.send(:interface_id)).to eq('abc')
         
     | 
| 
       54 
     | 
    
         
            -
                  end
         
     | 
| 
       55 
     | 
    
         
            -
                end
         
     | 
| 
       56 
     | 
    
         
            -
              end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
              describe '#interface_name' do
         
     | 
| 
       59 
     | 
    
         
            -
                context 'when passed to initialize' do
         
     | 
| 
       60 
     | 
    
         
            -
                  before :each do
         
     | 
| 
       61 
     | 
    
         
            -
                    @gifts_service = Person::GiftsService.new(:interface_name => 'teste')
         
     | 
| 
       62 
     | 
    
         
            -
                  end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                  it 'should return it' do
         
     | 
| 
       65 
     | 
    
         
            -
                    expect(@gifts_service.send(:interface_name)).to eq('teste')
         
     | 
| 
       66 
     | 
    
         
            -
                  end
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                it 'should return the interface name' do
         
     | 
| 
       70 
     | 
    
         
            -
                  expect(users_service.send(:interface_name)).to eq('user')
         
     | 
| 
       71 
     | 
    
         
            -
                end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                context 'when defined on class' do
         
     | 
| 
       74 
     | 
    
         
            -
                  before :each do
         
     | 
| 
       75 
     | 
    
         
            -
                    Person::GiftsService.instance_variable_set('@interface_name', 'abc')
         
     | 
| 
       76 
     | 
    
         
            -
                    @gifts_service = Person::GiftsService.new
         
     | 
| 
       77 
     | 
    
         
            -
                  end
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                  it 'should return the defined value' do
         
     | 
| 
       80 
     | 
    
         
            -
                    expect(@gifts_service.send(:interface_name)).to eq('abc')
         
     | 
| 
       81 
     | 
    
         
            -
                  end
         
     | 
| 
       82 
     | 
    
         
            -
                end
         
     | 
| 
       83 
     | 
    
         
            -
              end
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
              describe '#interface_class' do
         
     | 
| 
       86 
     | 
    
         
            -
                context 'when passed to initialize' do
         
     | 
| 
       87 
     | 
    
         
            -
                  before :each do
         
     | 
| 
       88 
     | 
    
         
            -
                    @gifts_service = Person::GiftsService.new(:interface_class => User)
         
     | 
| 
       89 
     | 
    
         
            -
                  end
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                  it 'should return it' do
         
     | 
| 
       92 
     | 
    
         
            -
                    expect(@gifts_service.send(:interface_class)).to eq(User)
         
     | 
| 
       93 
     | 
    
         
            -
                  end
         
     | 
| 
       94 
     | 
    
         
            -
                end
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                context 'on a pluralized service' do
         
     | 
| 
       97 
     | 
    
         
            -
                  it 'should find the interface model' do
         
     | 
| 
       98 
     | 
    
         
            -
                    expect(users_service.send(:interface_class)).to eq(User)
         
     | 
| 
       99 
     | 
    
         
            -
                  end
         
     | 
| 
       100 
     | 
    
         
            -
                end
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
                context 'on a namespaced service and interface model' do
         
     | 
| 
       103 
     | 
    
         
            -
                  it 'should find the interface model' do
         
     | 
| 
       104 
     | 
    
         
            -
                    expect(profile_service.send(:interface_class)).to eq(Person::Profile)
         
     | 
| 
       105 
     | 
    
         
            -
                  end
         
     | 
| 
       106 
     | 
    
         
            -
                end
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
                context 'on a namespaced service and non namespaced interface model' do
         
     | 
| 
       109 
     | 
    
         
            -
                  it 'should find the interface model' do
         
     | 
| 
       110 
     | 
    
         
            -
                    expect(admin_service.send(:interface_class)).to eq(User)
         
     | 
| 
       111 
     | 
    
         
            -
                  end
         
     | 
| 
       112 
     | 
    
         
            -
                end
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                context 'on a non namespaced service and non namespaced interface model' do
         
     | 
| 
       115 
     | 
    
         
            -
                  it 'should find the interface model' do
         
     | 
| 
       116 
     | 
    
         
            -
                    expect(users_service.send(:interface_class)).to eq(User)
         
     | 
| 
       117 
     | 
    
         
            -
                  end
         
     | 
| 
       118 
     | 
    
         
            -
                end
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
                context 'when defined on class' do
         
     | 
| 
       121 
     | 
    
         
            -
                  before :each do
         
     | 
| 
       122 
     | 
    
         
            -
                    Person::GiftsService.instance_variable_set('@interface_class', User)
         
     | 
| 
       123 
     | 
    
         
            -
                    @gifts_service = Person::GiftsService.new
         
     | 
| 
       124 
     | 
    
         
            -
                  end
         
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
                  it 'should return the defined value' do
         
     | 
| 
       127 
     | 
    
         
            -
                    expect(@gifts_service.send(:interface_class)).to eq(User)
         
     | 
| 
      
 11 
     | 
    
         
            +
                context 'without a custom controller' do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  it 'should save the name of the service' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                    expect(Zertico::Service.new.name).to eq('Zertico::Service')
         
     | 
| 
       128 
14 
     | 
    
         
             
                  end
         
     | 
| 
       129 
15 
     | 
    
         
             
                end
         
     | 
| 
       130 
16 
     | 
    
         
             
              end
         
     |