active_mocker 1.1.10 → 1.1.11
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
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 461b70e002570b08fb40fd4f3bbfeeedaac59672
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c1a570d233029b13813e61ba849b388edc417183
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 80063db1732dec862301ce306b77a63b8097cb27f1b23d07d9c11ad25532b31c24f17ba5054410ec50b6fbd0677684bc91337a206b2045bf56cf981183efd171
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d336a09d187f76d1eec2fc3220cd277e5da941649bd378ad14e253b2be826b95f1ff5a317c0fce1edf1a17bd5b6c8ae80e8adff41b9232a14cd42745e56599b1
         
     | 
| 
         @@ -18,23 +18,24 @@ module ActiveMocker 
     | 
|
| 
       18 
18 
     | 
    
         
             
                  end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                  def self.add_to_cache(table)
         
     | 
| 
       21 
     | 
    
         
            -
                     
     | 
| 
       22 
     | 
    
         
            -
                     
     | 
| 
      
 21 
     | 
    
         
            +
                    @tables_cache ||= []
         
     | 
| 
      
 22 
     | 
    
         
            +
                    @tables_cache << table unless table.nil?
         
     | 
| 
       23 
23 
     | 
    
         
             
                  end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                  def self.search_cache(table_name)
         
     | 
| 
       26 
     | 
    
         
            -
                     
     | 
| 
       27 
     | 
    
         
            -
                     
     | 
| 
      
 26 
     | 
    
         
            +
                    @tables_cache ||= []
         
     | 
| 
      
 27 
     | 
    
         
            +
                    @tables_cache.find do |h|
         
     | 
| 
       28 
28 
     | 
    
         
             
                      h.name == table_name
         
     | 
| 
       29 
29 
     | 
    
         
             
                    end
         
     | 
| 
       30 
30 
     | 
    
         
             
                  end
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
32 
     | 
    
         
             
                  def self.clear_cache
         
     | 
| 
       33 
     | 
    
         
            -
                     
     | 
| 
      
 33 
     | 
    
         
            +
                    @tables_cache = []
         
     | 
| 
       34 
34 
     | 
    
         
             
                  end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
                  def self.search(table_name)
         
     | 
| 
       37 
37 
     | 
    
         
             
                    @table_search = table_name
         
     | 
| 
      
 38 
     | 
    
         
            +
                    search_cache(table_name)
         
     | 
| 
       38 
39 
     | 
    
         
             
                  end
         
     | 
| 
       39 
40 
     | 
    
         | 
| 
       40 
41 
     | 
    
         
             
                end
         
     | 
| 
         @@ -13,7 +13,7 @@ module ActiveMocker 
     | 
|
| 
       13 
13 
     | 
    
         
             
                def search(model_name)
         
     | 
| 
       14 
14 
     | 
    
         
             
                  @model_name = model_name
         
     | 
| 
       15 
15 
     | 
    
         
             
                  @table = search_schema_file
         
     | 
| 
       16 
     | 
    
         
            -
                  @table 
     | 
| 
      
 16 
     | 
    
         
            +
                  @table
         
     | 
| 
       17 
17 
     | 
    
         
             
                  @table
         
     | 
| 
       18 
18 
     | 
    
         
             
                end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
         @@ -23,16 +23,13 @@ module ActiveMocker 
     | 
|
| 
       23 
23 
     | 
    
         
             
                  model_name
         
     | 
| 
       24 
24 
     | 
    
         
             
                end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                def not_found
         
     | 
| 
       27 
     | 
    
         
            -
                  raise "#{table_name} table not found." if @schema_result.nil?
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
26 
     | 
    
         
             
                def search_schema_file
         
     | 
| 
       31 
27 
     | 
    
         
             
                  ActiveMocker::ActiveRecord::Schema.clear_cache if clear_cache
         
     | 
| 
       32 
     | 
    
         
            -
                  ActiveMocker::ActiveRecord::Schema.search(table_name)
         
     | 
| 
       33 
     | 
    
         
            -
                   
     | 
| 
       34 
     | 
    
         
            -
                   
     | 
| 
       35 
     | 
    
         
            -
                   
     | 
| 
      
 28 
     | 
    
         
            +
                  search_result = ActiveMocker::ActiveRecord::Schema.search(table_name)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  return search_result if search_result
         
     | 
| 
      
 30 
     | 
    
         
            +
                  schema_result = eval_file
         
     | 
| 
      
 31 
     | 
    
         
            +
                  raise "#{table_name} table not found." if schema_result.nil?
         
     | 
| 
      
 32 
     | 
    
         
            +
                  schema_result
         
     | 
| 
       36 
33 
     | 
    
         
             
                end
         
     | 
| 
       37 
34 
     | 
    
         | 
| 
       38 
35 
     | 
    
         
             
                def eval_file
         
     | 
    
        data/lib/active_mocker/table.rb
    CHANGED
    
    
| 
         @@ -57,7 +57,7 @@ describe ActiveMocker::SchemaReader do 
     | 
|
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
              context 'inject string_reader as file_reader' do
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
                let(:subject){described_class.new({schema_file:nil, file_reader: example_schema})}
         
     | 
| 
      
 60 
     | 
    
         
            +
                let(:subject){described_class.new({schema_file:nil, file_reader: example_schema, clear_cache: true})}
         
     | 
| 
       61 
61 
     | 
    
         | 
| 
       62 
62 
     | 
    
         
             
                let(:search){subject.search('people')}
         
     | 
| 
       63 
63 
     | 
    
         |