effective_test_bot 1.5.3 → 1.5.5
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 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0c320a94c17497abc43a0f37559dcee2e608ba899a2aabc4f4a4b7cc7a9e5be8
         | 
| 4 | 
            +
              data.tar.gz: e5753beb4030d91505ee07ee221abe9b76d79a69d4da1c41a1a11542b1d703dd
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b0530afa717c87156b8b07b78b4660d62e82f13294d3075b8f27e09fc6fb26760bced8f3c579a9f0cfd442d4f70bd0dbcff1a7efc2b49300cf19c107e02e5076
         | 
| 7 | 
            +
              data.tar.gz: bbe0ab99a02579405943790b1da5fe05604e7a8b66451b80df844baa6757626a4f64df47e2d608be6ef7ab98d4c2c75bb36b0dbccc96501d97b7d84c92a32db4
         | 
| @@ -10,6 +10,7 @@ module EffectiveTestBot | |
| 10 10 | 
             
                  include EffectiveTestBotFormHelper
         | 
| 11 11 | 
             
                  include EffectiveTestBotLoginHelper
         | 
| 12 12 | 
             
                  include EffectiveTestBotMinitestHelper
         | 
| 13 | 
            +
                  include EffectiveTestBotPerformance
         | 
| 13 14 | 
             
                  include EffectiveTestBotScreenshotsHelper
         | 
| 14 15 | 
             
                  include EffectiveTestBotTestHelper
         | 
| 15 16 |  | 
| @@ -34,12 +34,12 @@ module TestSeedable | |
| 34 34 |  | 
| 35 35 | 
             
                  case seed
         | 
| 36 36 | 
             
                  when :all
         | 
| 37 | 
            -
                    load(db_seeds) if File. | 
| 38 | 
            -
                    load(test_seeds) if File. | 
| 37 | 
            +
                    load(db_seeds) if File.exist?(db_seeds)
         | 
| 38 | 
            +
                    load(test_seeds) if File.exist?(test_seeds)
         | 
| 39 39 | 
             
                  when :db
         | 
| 40 | 
            -
                    load(db_seeds) if File. | 
| 40 | 
            +
                    load(db_seeds) if File.exist?(db_seeds)
         | 
| 41 41 | 
             
                  when :test
         | 
| 42 | 
            -
                    load(test_seeds) if File. | 
| 42 | 
            +
                    load(test_seeds) if File.exist?(test_seeds)
         | 
| 43 43 | 
             
                  else
         | 
| 44 44 | 
             
                    raise('unexpected seed argument. use :all, :db or :test')
         | 
| 45 45 | 
             
                  end
         | 
| @@ -166,7 +166,7 @@ module EffectiveTestBotFormFaker | |
| 166 166 | 
             
                # If this is a file field, make sure the file is present at Rails.root/test/fixtures/
         | 
| 167 167 | 
             
                if fill.present? && fill != :unselect && field_name == 'input_file'
         | 
| 168 168 | 
             
                  filename = (fill.to_s.include?('/') ? fill : "#{Rails.root}/test/fixtures/#{fill}")
         | 
| 169 | 
            -
                  raise("Warning: Unable to load fill file #{fill}. Expected file #{filename}") unless File. | 
| 169 | 
            +
                  raise("Warning: Unable to load fill file #{fill}. Expected file #{filename}") unless File.exist?(filename)
         | 
| 170 170 | 
             
                  return filename
         | 
| 171 171 | 
             
                end
         | 
| 172 172 |  | 
| @@ -0,0 +1,62 @@ | |
| 1 | 
            +
            module EffectiveTestBotPerformance
         | 
| 2 | 
            +
              def assert_performance(milliseconds: 250, print_results: false, &block)
         | 
| 3 | 
            +
                result = performance_test(print_results: print_results, &block)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                assert (result < milliseconds), "Expected performance to be less than #{milliseconds}ms, but it was #{result}ms"
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              def performance_test(warmups: 2, iterations: 10, print_results: true, &block)
         | 
| 9 | 
            +
                raise('expected a block') unless block_given?
         | 
| 10 | 
            +
                raise('please install the ruby-prof gem') unless defined?(RubyProf)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                # Warmup
         | 
| 13 | 
            +
                warmups.times { block.call() }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                # Use ruby-prof to Profile
         | 
| 16 | 
            +
                profile = RubyProf::Profile.new(track_allocations: true)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                results = profile.profile do
         | 
| 19 | 
            +
                  iterations.times do
         | 
| 20 | 
            +
                    print '.'
         | 
| 21 | 
            +
                    block.call()
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                # Return a single number result
         | 
| 26 | 
            +
                milliseconds = ((results.threads.sum { |thread| thread.total_time } * 1000.0) / iterations.to_f).round
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                # Print results
         | 
| 29 | 
            +
                print_performance_test_results(results, milliseconds) if print_results
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                # Returns an integer number of milliseconds
         | 
| 32 | 
            +
                milliseconds
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              private
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              def print_performance_test_results(results, milliseconds)
         | 
| 38 | 
            +
                puts('')
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                path = Rails.application.root.join('tmp')
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                # Profile Graph
         | 
| 43 | 
            +
                filename = path.join('profile-graph.html')
         | 
| 44 | 
            +
                File.open(filename, 'w+') { |file| RubyProf::GraphHtmlPrinter.new(results).print(file) }
         | 
| 45 | 
            +
                puts("Profile Graph: #{filename}")
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                # Profile Flat
         | 
| 48 | 
            +
                filename = path.join('profile-flat.txt')
         | 
| 49 | 
            +
                File.open(filename, 'w+') { |file| RubyProf::FlatPrinter.new(results).print(file) }
         | 
| 50 | 
            +
                puts("Profile Flat: #{filename}")
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                # Profile Stack
         | 
| 53 | 
            +
                filename = path.join('profile-stack.html')
         | 
| 54 | 
            +
                File.open(filename, 'w+') { |file| RubyProf::CallStackPrinter.new(results).print(file) }
         | 
| 55 | 
            +
                puts("Profile Stack: #{filename}")
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                # Total Performance
         | 
| 58 | 
            +
                puts "Performance: #{milliseconds}ms"
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                puts('')
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: effective_test_bot
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.5. | 
| 4 | 
            +
              version: 1.5.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Code and Effect
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2024-03-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -161,6 +161,7 @@ files: | |
| 161 161 | 
             
            - test/support/effective_test_bot_login_helper.rb
         | 
| 162 162 | 
             
            - test/support/effective_test_bot_minitest_helper.rb
         | 
| 163 163 | 
             
            - test/support/effective_test_bot_mocks.rb
         | 
| 164 | 
            +
            - test/support/effective_test_bot_performance.rb
         | 
| 164 165 | 
             
            - test/support/effective_test_bot_screenshots_helper.rb
         | 
| 165 166 | 
             
            - test/support/effective_test_bot_test_helper.rb
         | 
| 166 167 | 
             
            - test/test_bot/system/application_test.rb
         | 
| @@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 191 192 | 
             
                - !ruby/object:Gem::Version
         | 
| 192 193 | 
             
                  version: '0'
         | 
| 193 194 | 
             
            requirements: []
         | 
| 194 | 
            -
            rubygems_version: 3. | 
| 195 | 
            +
            rubygems_version: 3.5.6
         | 
| 195 196 | 
             
            signing_key:
         | 
| 196 197 | 
             
            specification_version: 4
         | 
| 197 198 | 
             
            summary: A shared library of rails model & system tests that should pass in every
         |