coverband 4.0.1 → 4.1.0.alpha
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/.travis.yml +5 -1
 - data/README.md +69 -123
 - data/changes.md +1 -3
 - data/coverband.gemspec +1 -3
 - data/lib/coverband.rb +3 -0
 - data/lib/coverband/adapters/redis_store.rb +7 -2
 - data/lib/coverband/at_exit.rb +20 -0
 - data/lib/coverband/configuration.rb +3 -1
 - data/lib/coverband/integrations/background.rb +0 -7
 - data/lib/coverband/integrations/middleware.rb +3 -2
 - data/lib/coverband/integrations/resque.rb +18 -0
 - data/lib/coverband/reporters/web.rb +11 -4
 - data/lib/coverband/utils/html_formatter.rb +4 -2
 - data/lib/coverband/utils/tasks.rb +8 -17
 - data/lib/coverband/version.rb +1 -1
 - data/test/test_helper.rb +1 -6
 - data/test/unit/adapters_redis_store_test.rb +2 -2
 - data/test/unit/at_exit_test.rb +13 -0
 - data/test/unit/background_test.rb +0 -1
 - data/test/unit/configuration_test.rb +23 -0
 - data/test/unit/full_stack_test.rb +2 -6
 - data/test/unit/middleware_test.rb +1 -1
 - data/test/unit/reports_console_test.rb +1 -1
 - data/test/unit/reports_html_test.rb +20 -3
 - data/test/unit/reports_web_test.rb +18 -5
 - data/test/unit/resque_worker_test.rb +35 -0
 - data/test/unit/test_resque_job.rb +7 -0
 - data/views/layout.erb +3 -1
 - metadata +14 -20
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: dee2efe6e6763457859da3c235858f9de0a17189
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 441347a296e06c2189f02a26b3d966825a90e354
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: b9c5b36fbb46b80da1bb4ca4a098d12dbfec941059a1b7eb297d1d77f065674183df7cd115ac965289db3751f2f9595abfe81e947771c6fc4b5a9155726c8c1b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 68e90213cc0af16924c4e681b59e6ac8d77463921ec7ba019ac8b4bc3579805e62a0ad10e51a793a18b3bd037af09a9e13bfb9e245d8a5e9b309b2960d8a70bd
         
     | 
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -10,4 +10,8 @@ gemfile: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            services:
         
     | 
| 
       11 
11 
     | 
    
         
             
              - redis-server
         
     | 
| 
       12 
12 
     | 
    
         
             
            before_install:
         
     | 
| 
       13 
     | 
    
         
            -
              -  
     | 
| 
      
 13 
     | 
    
         
            +
              - echo 'this is a hack to clear default bundler and force bundler 1.17.3'
         
     | 
| 
      
 14 
     | 
    
         
            +
              - rm /home/travis/.rvm/gems/ruby-2.3.7@global/specifications/bundler-2.0.1.gemspec || true
         
     | 
| 
      
 15 
     | 
    
         
            +
              - gem uninstall bundler || true
         
     | 
| 
      
 16 
     | 
    
         
            +
              - gem install bundler -v '1.17.3'
         
     | 
| 
      
 17 
     | 
    
         
            +
              - bundler --version
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -6,9 +6,9 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
            <p align="center">
         
     | 
| 
       7 
7 
     | 
    
         
             
              <a href="#key-features">Key Features</a> •
         
     | 
| 
       8 
8 
     | 
    
         
             
              <a href="#installation">Installation</a> •
         
     | 
| 
       9 
     | 
    
         
            -
              <a href="# 
     | 
| 
       10 
     | 
    
         
            -
              <a href="# 
     | 
| 
       11 
     | 
    
         
            -
              <a href="# 
     | 
| 
      
 9 
     | 
    
         
            +
              <a href="#coverage-report">Coverage Report</a> •
         
     | 
| 
      
 10 
     | 
    
         
            +
              <a href="#verify-correct-installation">Verify Correct Installation</a> •
         
     | 
| 
      
 11 
     | 
    
         
            +
              <a href="#advanced-config">Advanced Config</a> •
         
     | 
| 
       12 
12 
     | 
    
         
             
              <a href="#license">License</a> •
         
     | 
| 
       13 
13 
     | 
    
         
             
              <a href="/changes.md">Change Log / Roadmap</a>
         
     | 
| 
       14 
14 
     | 
    
         
             
            </p>
         
     | 
| 
         @@ -28,10 +28,15 @@ The primary goal of Coverband is giving deep insight into your production runtim 
     | 
|
| 
       28 
28 
     | 
    
         
             
            * Development mode, offers deep insight of code usage details (number of LOC execution during single request, etc) during development.
         
     | 
| 
       29 
29 
     | 
    
         
             
            * Mountable web interface to easily share reports
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
31 
     | 
    
         
             
            # Installation
         
     | 
| 
       33 
32 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
            ## Redis
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            Coverband stores coverage data in Redis. The Redis endpoint is looked for in this order: 
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            1. `ENV['COVERBAND_REDIS_URL']`
         
     | 
| 
      
 38 
     | 
    
         
            +
            2. `ENV['REDIS_URL']`
         
     | 
| 
      
 39 
     | 
    
         
            +
            3. `localhost`
         
     | 
| 
       35 
40 
     | 
    
         | 
| 
       36 
41 
     | 
    
         
             
            ## Gem Installation
         
     | 
| 
       37 
42 
     | 
    
         | 
| 
         @@ -43,10 +48,8 @@ gem 'coverband' 
     | 
|
| 
       43 
48 
     | 
    
         | 
| 
       44 
49 
     | 
    
         
             
            ## Rails
         
     | 
| 
       45 
50 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
            The Railtie integration means you shouldn't need to do anything anything else.
         
     | 
| 
      
 51 
     | 
    
         
            +
            The Railtie integration means you shouldn't need to do anything anything else. If you have an issue with that, please [file an issue](https://github.com/danmayer/coverband/issues).
         
     | 
| 
       47 
52 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
            * By default Coverband will try to stored data to Redis
         
     | 
| 
       49 
     | 
    
         
            -
            	* Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
         
     | 
| 
       50 
53 
     | 
    
         | 
| 
       51 
54 
     | 
    
         
             
            ## Sinatra
         
     | 
| 
       52 
55 
     | 
    
         | 
| 
         @@ -60,65 +63,54 @@ use Coverband::Middleware 
     | 
|
| 
       60 
63 
     | 
    
         
             
            run ActionController::Dispatcher.new
         
     | 
| 
       61 
64 
     | 
    
         
             
            ```
         
     | 
| 
       62 
65 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
            # Report 
     | 
| 
      
 66 
     | 
    
         
            +
            # Coverage Report
         
     | 
| 
       64 
67 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
            Coverband comes with a mountable rack app for viewing reports. For Rails this can be done in `config/routes.rb` with:
         
     | 
| 
       66 
69 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 71 
     | 
    
         
            +
            Rails.application.routes.draw do
         
     | 
| 
      
 72 
     | 
    
         
            +
              mount Coverband::Reporters::Web.new, at: '/coverage'
         
     | 
| 
      
 73 
     | 
    
         
            +
            end
         
     | 
| 
      
 74 
     | 
    
         
            +
            ```
         
     | 
| 
       68 
75 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
      
 76 
     | 
    
         
            +
            But don't forget to *protect your source code with proper authentication*. Something like this when using devise:
         
     | 
| 
       70 
77 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
            ``` 
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
      
 78 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 79 
     | 
    
         
            +
            Rails.application.routes.draw do
         
     | 
| 
      
 80 
     | 
    
         
            +
              authenticate :user, lambda { |u| u.admin? } do
         
     | 
| 
      
 81 
     | 
    
         
            +
                mount Coverband::Reporters::Web.new, at: '/coverage'
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
            end
         
     | 
| 
       75 
84 
     | 
    
         
             
            ```
         
     | 
| 
       76 
85 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
            `rake coverband:coverage`
         
     | 
| 
      
 86 
     | 
    
         
            +
            ### Coverband Web Endpoint
         
     | 
| 
       80 
87 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 88 
     | 
    
         
            +
            The web endpoint is a barebones endpoint that you can either expose direct (after authentication) or you can just link to the actions you wish to expose. The index is intended as a example to showcase all the features.
         
     | 
| 
       82 
89 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
      
 90 
     | 
    
         
            +
            
         
     | 
| 
      
 91 
     | 
    
         
            +
            > The web index as available on the Coverband Demo site
         
     | 
| 
       84 
92 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
      
 93 
     | 
    
         
            +
            * __force coverage collection:__ This triggers coverage collection on the current webserver process
         
     | 
| 
      
 94 
     | 
    
         
            +
            * __reload Coverband files:__ This has Coverband reload files as configured (force reload of some files that might not capture Coverage on boot). This can be used to reload files on demand.
         
     | 
| 
      
 95 
     | 
    
         
            +
            * __clear coverage report:__ This will clear the coverage data. This wipes out all collected data (__dangerous__)
         
     | 
| 
       86 
96 
     | 
    
         | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
            Rails.application.routes.draw do
         
     | 
| 
       89 
     | 
    
         
            -
              # ... lots of routes
         
     | 
| 
       90 
     | 
    
         
            -
              mount Coverband::Reporters::Web.new, at: '/coverage'
         
     | 
| 
       91 
     | 
    
         
            -
            end
         
     | 
| 
       92 
     | 
    
         
            -
            ```
         
     | 
| 
      
 97 
     | 
    
         
            +
            ### Rake Tasks
         
     | 
| 
       93 
98 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
      
 99 
     | 
    
         
            +
            The rake task generates a report locally and opens a browser pointing to `coverage/index.html`.
         
     | 
| 
       95 
100 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
      
 101 
     | 
    
         
            +
            `rake coverband:coverage`
         
     | 
| 
       97 
102 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
            # protect with existing Rails devise configuration
         
     | 
| 
       100 
     | 
    
         
            -
            devise_constraint = lambda do |request|
         
     | 
| 
       101 
     | 
    
         
            -
              request.env['warden'] && request.env['warden'].authenticate? && request.env['warden'].user.admin?
         
     | 
| 
       102 
     | 
    
         
            -
            end
         
     | 
| 
      
 103 
     | 
    
         
            +
            This is mostly useful in your local development environment.
         
     | 
| 
       103 
104 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
            # curl --user foo:bar http://localhost:3000/coverage
         
     | 
| 
       106 
     | 
    
         
            -
            Rails.application.routes.draw do
         
     | 
| 
       107 
     | 
    
         
            -
              # ... lots of routes
         
     | 
| 
      
 105 
     | 
    
         
            +
            ##### Example Output
         
     | 
| 
       108 
106 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
              AuthenticatedCoverband = Rack::Builder.new do 
         
     | 
| 
       111 
     | 
    
         
            -
                use Rack::Auth::Basic do |username, password|
         
     | 
| 
       112 
     | 
    
         
            -
                  username == 'foo' && password == 'bar'
         
     | 
| 
       113 
     | 
    
         
            -
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
            Since Coverband is [Simplecov](https://github.com/colszowka/simplecov) output compatible it should work with any of the `SimpleCov::Formatter`'s available. The output below is produced using the default Simplecov HTML formatter.
         
     | 
| 
       114 
108 
     | 
    
         | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
      
 109 
     | 
    
         
            +
            Index Page
         
     | 
| 
      
 110 
     | 
    
         
            +
            
         
     | 
| 
       117 
111 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
            end
         
     | 
| 
       121 
     | 
    
         
            -
            ```
         
     | 
| 
      
 112 
     | 
    
         
            +
            Details on an example Sinatra app
         
     | 
| 
      
 113 
     | 
    
         
            +
            
         
     | 
| 
       122 
114 
     | 
    
         | 
| 
       123 
115 
     | 
    
         
             
            # Verify Correct Installation
         
     | 
| 
       124 
116 
     | 
    
         | 
| 
         @@ -132,57 +124,19 @@ end 
     | 
|
| 
       132 
124 
     | 
    
         | 
| 
       133 
125 
     | 
    
         
             
            Take Coverband for a spin on the live Heroku deployed [Coverband Demo](https://coverband-demo.herokuapp.com/). The [full source code for the demo](https://github.com/danmayer/coverband_demo) is available to help with installation, configuration, and understanding of basic usage.
         
     | 
| 
       134 
126 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
            # How To Use
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
            Below is my Coverband workflow, which hopefully will help other best use this library.
         
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
            * <a href="#installation">Install Coverband</a>
         
     | 
| 
       140 
     | 
    
         
            -
            * Start your app and hit a few endpoints
         
     | 
| 
       141 
     | 
    
         
            -
            * Validate data collection and code coverage with  `rake coverband:coverage`
         
     | 
| 
       142 
     | 
    
         
            -
            * If you see app startup and recent visits showing, setup is correct
         
     | 
| 
       143 
     | 
    
         
            -
            * I generally configure the mountable web endpoint to [view the data via the web-app](https://github.com/danmayer/coverband#viewing--hosting-s3-coverband-results-in-app)
         
     | 
| 
       144 
     | 
    
         
            -
            * After Coverband has been verified to be working on production, I let it run for a few weeks.
         
     | 
| 
       145 
     | 
    
         
            -
            * Then I view the report and start submitting PRs for the team to review delete large related sets of code that no longer are in use.
         
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
            ### Coverband Web Endpoint
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
            The web endpoint is a barebones endpoint that you can either expose direct (after authentication) or you can just link to the actions you wish to expose. The index is intended as a example to showcase all the features.
         
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
            
         
     | 
| 
       152 
     | 
    
         
            -
            > The web index as available on the Coverband Demo site
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
            * __collect data, update report, & view:__ This does everything need to view up to date Coverage 
         
     | 
| 
       155 
     | 
    
         
            -
               * it triggers a coverage collection on the current webserver process
         
     | 
| 
       156 
     | 
    
         
            -
               * it generates a new html coverage report and pushes it to S3
         
     | 
| 
       157 
     | 
    
         
            -
               * it then loads that report for you to view
         
     | 
| 
       158 
     | 
    
         
            -
            * __view coverage report:__ Don't need to update the data just view the current report
         
     | 
| 
       159 
     | 
    
         
            -
            * __update coverage data (collect coverage):__ This triggers coverage collection on the current webserver process
         
     | 
| 
       160 
     | 
    
         
            -
            * __update coverage report (rebuild report):__ This will rebuild the HTML report from the latest available data
         
     | 
| 
       161 
     | 
    
         
            -
            * __clear coverage report:__ This will clear the coverage data. This wipes out all collected data (__dangerous__)
         
     | 
| 
       162 
     | 
    
         
            -
            * __reload Coverband files:__ This has Coverband reload files as configured (force reload of some files that might not capture Coverage on boot)
         
     | 
| 
       163 
127 
     | 
    
         | 
| 
       164 
128 
     | 
    
         
             
            ### Example apps
         
     | 
| 
       165 
129 
     | 
    
         | 
| 
       166 
     | 
    
         
            -
            - [Rails 5.2.x App](https://github.com/danmayer/ 
     | 
| 
      
 130 
     | 
    
         
            +
            - [Rails 5.2.x App](https://github.com/danmayer/coverband_demo)
         
     | 
| 
       167 
131 
     | 
    
         
             
            - [Sinatra app](https://github.com/danmayer/churn-site)
         
     | 
| 
       168 
132 
     | 
    
         
             
            - [Non Rack Ruby app](https://github.com/danmayer/coverband_examples)
         
     | 
| 
       169 
133 
     | 
    
         | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
            Since Coverband is [Simplecov](https://github.com/colszowka/simplecov) output compatible it should work with any of the `SimpleCov::Formatter`'s available. The output below is produced using the default Simplecov HTML formatter.
         
     | 
| 
      
 134 
     | 
    
         
            +
            # Advanced Config
         
     | 
| 
       173 
135 
     | 
    
         | 
| 
       174 
     | 
    
         
            -
            Index Page
         
     | 
| 
       175 
     | 
    
         
            -
            
         
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
            Details on a example Sinatra app
         
     | 
| 
       178 
     | 
    
         
            -
            
         
     | 
| 
       179 
136 
     | 
    
         | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
       182 
     | 
    
         
            -
            You may need to configure Coverband you can either do that passing in all configuration options to `Coverband.configure` in block format, or a simpler style is to call `Coverband.configure` with no params which will load `config/coverband.rb` expecting it to configure the app correctly.
         
     | 
| 
      
 137 
     | 
    
         
            +
            If you need to configure coverband, this can be done by creating a `config/coverband.rb` file relative to your project root.
         
     | 
| 
       183 
138 
     | 
    
         | 
| 
       184 
139 
     | 
    
         
             
            * See [lib/coverband/configuration.rb](https://github.com/danmayer/coverband/blob/master/lib/coverband/configuration.rb) for all options
         
     | 
| 
       185 
     | 
    
         
            -
            * I strongly recommend setting up the S3 report adapter, which can't be automatically configured
         
     | 
| 
       186 
140 
     | 
    
         
             
            * By default Coverband will try to stored data to Redis
         
     | 
| 
       187 
141 
     | 
    
         
             
            	* Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
         
     | 
| 
       188 
142 
     | 
    
         | 
| 
         @@ -191,6 +145,8 @@ You may need to configure Coverband you can either do that passing in all config 
     | 
|
| 
       191 
145 
     | 
    
         
             
            ```ruby
         
     | 
| 
       192 
146 
     | 
    
         
             
            #config/coverband.rb
         
     | 
| 
       193 
147 
     | 
    
         
             
            Coverband.configure do |config|
         
     | 
| 
      
 148 
     | 
    
         
            +
              config.store = Coverband::Adapters::RedisStore.new(Redis.new(url: ENV['MY_REDIS_URL']))
         
     | 
| 
      
 149 
     | 
    
         
            +
              config.logger = Rails.logger
         
     | 
| 
       194 
150 
     | 
    
         
             
              # configure S3 integration
         
     | 
| 
       195 
151 
     | 
    
         
             
              config.s3_bucket = 'coverband-demo'
         
     | 
| 
       196 
152 
     | 
    
         
             
              config.s3_region = 'us-east-1'
         
     | 
| 
         @@ -205,6 +161,22 @@ Coverband.configure do |config| 
     | 
|
| 
       205 
161 
     | 
    
         
             
            end
         
     | 
| 
       206 
162 
     | 
    
         
             
            ```
         
     | 
| 
       207 
163 
     | 
    
         | 
| 
      
 164 
     | 
    
         
            +
            ### Ignoring Files
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
            Sometimes you have files that are known to be valuable perhaps in other environments or something that is just run very infrequently. Opposed to having to mentally filter them out of the report, you can just have them ignored in the Coverband reporting by using `config.ignore` as shown below. Ignore takes a string but can also match with regex rules see how below ignores all rake tasks as an example.
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
            ```
         
     | 
| 
      
 169 
     | 
    
         
            +
            config.ignore =	['config/application.rb',
         
     | 
| 
      
 170 
     | 
    
         
            +
                               'config/boot.rb',
         
     | 
| 
      
 171 
     | 
    
         
            +
                               'config/puma.rb',
         
     | 
| 
      
 172 
     | 
    
         
            +
                               'config/schedule.rb',
         
     | 
| 
      
 173 
     | 
    
         
            +
                               'config/environments/test.rb',
         
     | 
| 
      
 174 
     | 
    
         
            +
                               'config/environments/development.rb',
         
     | 
| 
      
 175 
     | 
    
         
            +
                               'config/environments/staging.rb',
         
     | 
| 
      
 176 
     | 
    
         
            +
                               'config/environments/production.rb',
         
     | 
| 
      
 177 
     | 
    
         
            +
                               'lib/tasks/*']
         
     | 
| 
      
 178 
     | 
    
         
            +
            ```
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
       208 
180 
     | 
    
         
             
            ### Writing Coverband Results to S3
         
     | 
| 
       209 
181 
     | 
    
         | 
| 
       210 
182 
     | 
    
         
             
            If you add some additional Coverband configuration your coverage html report will be written directly to S3, update `config/coverband.rb` like below.
         
     | 
| 
         @@ -228,7 +200,7 @@ ENV['AWS_SECRET_ACCESS_KEY'] 
     | 
|
| 
       228 
200 
     | 
    
         | 
| 
       229 
201 
     | 
    
         
             
            ### Clear Coverage
         
     | 
| 
       230 
202 
     | 
    
         | 
| 
       231 
     | 
    
         
            -
            Now that Coverband uses MD5 hashes there should be no reason to manually clear coverage unless one is testing, changing versions, possibly debugging  
     | 
| 
      
 203 
     | 
    
         
            +
            Now that Coverband uses MD5 hashes there should be no reason to manually clear coverage unless one is testing, changing versions, possibly debugging Coverband itself.
         
     | 
| 
       232 
204 
     | 
    
         | 
| 
       233 
205 
     | 
    
         
             
            `rake coverband:clear`
         
     | 
| 
       234 
206 
     | 
    
         | 
| 
         @@ -254,9 +226,9 @@ rake coverband:coverage      # report runtime coverband code coverage 
     | 
|
| 
       254 
226 
     | 
    
         | 
| 
       255 
227 
     | 
    
         
             
            ### Forcing Coverband to Track Coverage on files loaded during boot `safe_reload_files`
         
     | 
| 
       256 
228 
     | 
    
         | 
| 
       257 
     | 
    
         
            -
             
     | 
| 
      
 229 
     | 
    
         
            +
            Coverband will report code usage for anything `required` or `loaded` after calling `Coverband.start` which happens automatically when coverband is required. This means some of the files loaded before coverband such as the Rails application.rb will be reported as having no coverage.
         
     | 
| 
       258 
230 
     | 
    
         | 
| 
       259 
     | 
    
         
            -
            The `safe_reload_files` reload option in the configuration options can help to ensure you can track any files  
     | 
| 
      
 231 
     | 
    
         
            +
            The `safe_reload_files` reload option in the configuration options can help to ensure you can track any files regardless of loading before Coverband. For example if I wanted to show the coverage of `config/coverband.rb`, which has to be loaded before calling `Coverband.start`, I could do that by adding that path to the `safe_reload_files` option.
         
     | 
| 
       260 
232 
     | 
    
         | 
| 
       261 
233 
     | 
    
         
             
            ```
         
     | 
| 
       262 
234 
     | 
    
         
             
            Coverband.configure do |config|
         
     | 
| 
         @@ -265,12 +237,12 @@ Coverband.configure do |config| 
     | 
|
| 
       265 
237 
     | 
    
         
             
              config.safe_reload_files = ['config/coverband.rb']
         
     | 
| 
       266 
238 
     | 
    
         
             
            end
         
     | 
| 
       267 
239 
     | 
    
         
             
            ```
         
     | 
| 
       268 
     | 
    
         
            -
            By adding any files above you will get reporting on those files as part of your coverage runtime report.
         
     | 
| 
      
 240 
     | 
    
         
            +
            By adding any files above you will get reporting on those files as part of your coverage runtime report. The files are reloaded when Coverband first starts, you can also trigger a reload via the web interface.
         
     | 
| 
       269 
241 
     | 
    
         | 
| 
       270 
242 
     | 
    
         | 
| 
       271 
243 
     | 
    
         
             
            ### Collecting Gem / Library Usage
         
     | 
| 
       272 
244 
     | 
    
         | 
| 
       273 
     | 
    
         
            -
            By default Coverband has assumed you are trying to track your application code usage not all the supporting framework and library (Gems) code usage. There  
     | 
| 
      
 245 
     | 
    
         
            +
            By default Coverband has assumed you are trying to track your application code usage and not all the supporting framework and library (Gems) code usage. There are reasons to track library usage though such as finding out which Gems aren't actually being used within production. See some of the discussion on [issue 21](https://github.com/danmayer/coverband/issues/21).
         
     | 
| 
       274 
246 
     | 
    
         | 
| 
       275 
247 
     | 
    
         
             
            How to collect gem usage with Coverband:
         
     | 
| 
       276 
248 
     | 
    
         | 
| 
         @@ -305,31 +277,6 @@ If you are trying to debug locally wondering what code is being run during a req 
     | 
|
| 
       305 
277 
     | 
    
         
             
                  ...
         
     | 
| 
       306 
278 
     | 
    
         
             
                 [517, 1617], [516, 38577]]
         
     | 
| 
       307 
279 
     | 
    
         | 
| 
       308 
     | 
    
         
            -
             
     | 
| 
       309 
     | 
    
         
            -
            ### Conflicting .Simplecov: Issue with Missing or 0% Coverage Report
         
     | 
| 
       310 
     | 
    
         
            -
             
     | 
| 
       311 
     | 
    
         
            -
            If you use SimpleCov to generate code coverage for your tests. You might have setup a `.simplecov` file to help control and focus it's output. Often the settings you want for your test's code coverage report are different than what you want Coverband to be reporting on. Since Coverband uses the SimpleCov HTML formatter to prepare it's report.
         
     | 
| 
       312 
     | 
    
         
            -
             
     | 
| 
       313 
     | 
    
         
            -
            So if you had something like this in a `.simplecov` file in the root of your project, as reported in [issue 83](https://github.com/danmayer/coverband/issues/83)
         
     | 
| 
       314 
     | 
    
         
            -
             
     | 
| 
       315 
     | 
    
         
            -
            ```
         
     | 
| 
       316 
     | 
    
         
            -
            require 'simplecov'
         
     | 
| 
       317 
     | 
    
         
            -
             
     | 
| 
       318 
     | 
    
         
            -
            SimpleCov.start do
         
     | 
| 
       319 
     | 
    
         
            -
              add_filter 'app/admin'
         
     | 
| 
       320 
     | 
    
         
            -
              add_filter '/spec/'
         
     | 
| 
       321 
     | 
    
         
            -
              add_filter '/config/'
         
     | 
| 
       322 
     | 
    
         
            -
              add_filter '/vendor/'
         
     | 
| 
       323 
     | 
    
         
            -
              add_filter 'userevents'
         
     | 
| 
       324 
     | 
    
         
            -
            end
         
     | 
| 
       325 
     | 
    
         
            -
            ```
         
     | 
| 
       326 
     | 
    
         
            -
             
     | 
| 
       327 
     | 
    
         
            -
            You could see some confusing results... To avoid this issue Coverband has a Rake task that will ignore all Simplecov filters.
         
     | 
| 
       328 
     | 
    
         
            -
             
     | 
| 
       329 
     | 
    
         
            -
            `rake coverband:coverage_no_filters`
         
     | 
| 
       330 
     | 
    
         
            -
             
     | 
| 
       331 
     | 
    
         
            -
            This will build the report after disabling any `.simplecov` applied settings.
         
     | 
| 
       332 
     | 
    
         
            -
             
     | 
| 
       333 
280 
     | 
    
         
             
            # Prerequisites
         
     | 
| 
       334 
281 
     | 
    
         | 
| 
       335 
282 
     | 
    
         
             
            * Coverband 3.0.X+ requires Ruby 2.3+
         
     | 
| 
         @@ -361,8 +308,7 @@ If you submit a change please make sure the tests and benchmarks are passing. 
     | 
|
| 
       361 
308 
     | 
    
         | 
| 
       362 
309 
     | 
    
         
             
            * __total fail__ on front end code, because of the precompiled template step basically coverage doesn't work well for `erb`, `slim`, and the like.
         
     | 
| 
       363 
310 
     | 
    
         
             
              * related it will try to report something, but the line numbers reported for `ERB` files are often off and aren't considered useful. I recommend filtering out .erb using the `config.ignore` option. The default configuration excludes these files
         
     | 
| 
       364 
     | 
    
         
            -
            *  
     | 
| 
       365 
     | 
    
         
            -
            * coverage doesn't show for Rails `config/application.rb` or `config/boot.rb` as they get loaded when loading the Rake environment prior to starting the `Coverage` library.
         
     | 
| 
      
 311 
     | 
    
         
            +
            * coverage doesn't show for Rails `config/application.rb` or `config/boot.rb` as they get loaded when loading the Rake environment prior to starting the `Coverage` library. See [reload files section](#forcing-coverband-to-track-coverage-on-files-loaded-during-boot-safe_reload_files).
         
     | 
| 
       366 
312 
     | 
    
         | 
| 
       367 
313 
     | 
    
         
             
            ### Debugging Redis Store
         
     | 
| 
       368 
314 
     | 
    
         | 
    
        data/changes.md
    CHANGED
    
    | 
         @@ -24,7 +24,6 @@ Will be the fully modern release that drops maintenance legacy support in favor 
     | 
|
| 
       24 
24 
     | 
    
         
             
              - add coverage timerange support
         
     | 
| 
       25 
25 
     | 
    
         
             
            - Drop Simplecov dependency
         
     | 
| 
       26 
26 
     | 
    
         
             
            - improved web reporting
         
     | 
| 
       27 
     | 
    
         
            -
              - no longer relying directly on HTML in S3 but dynamically generated from any adapter
         
     | 
| 
       28 
27 
     | 
    
         
             
              - lists current config options
         
     | 
| 
       29 
28 
     | 
    
         
             
              - eventually allow updating remote config
         
     | 
| 
       30 
29 
     | 
    
         
             
              - full theming
         
     | 
| 
         @@ -32,7 +31,6 @@ Will be the fully modern release that drops maintenance legacy support in favor 
     | 
|
| 
       32 
31 
     | 
    
         
             
            - additional adapters: Memcache, S3, and ActiveRecord
         
     | 
| 
       33 
32 
     | 
    
         
             
            - add articles / podcasts like prontos readme https://github.com/prontolabs/pronto
         
     | 
| 
       34 
33 
     | 
    
         
             
            - Add detailed Gem usage report, if we collect and send gem usage we can give percentage of gem code used, which should help application developers know when to remove gem dependencies (0%) or perhaps inline single methods for little usage (using <= 5%) for example.
         
     | 
| 
       35 
     | 
    
         
            -
            - add additional config / protection options on Coverage clear
         
     | 
| 
       36 
34 
     | 
    
         
             
            - add meta data information first seen last recorded to the coverage report views (probably need to drop simplecov for that).
         
     | 
| 
       37 
35 
     | 
    
         
             
              - more details in this issue: https://github.com/danmayer/coverband/issues/118
         
     | 
| 
       38 
36 
     | 
    
         
             
            - Make good video on setup, install, usage
         
     | 
| 
         @@ -66,7 +64,7 @@ Feature Ideas: 
     | 
|
| 
       66 
64 
     | 
    
         | 
| 
       67 
65 
     | 
    
         
             
            ### Coverband 4.0.2.alpha
         
     | 
| 
       68 
66 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
            -  
     | 
| 
      
 67 
     | 
    
         
            +
            - default disabled web clear, add config option to allow it
         
     | 
| 
       70 
68 
     | 
    
         | 
| 
       71 
69 
     | 
    
         
             
            # Released
         
     | 
| 
       72 
70 
     | 
    
         | 
    
        data/coverband.gemspec
    CHANGED
    
    | 
         @@ -24,7 +24,6 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       24 
24 
     | 
    
         
             
              # to test sdk 2 use this one
         
     | 
| 
       25 
25 
     | 
    
         
             
              spec.add_development_dependency 'aws-sdk-s3', '~> 1'
         
     | 
| 
       26 
26 
     | 
    
         
             
              spec.add_development_dependency 'benchmark-ips'
         
     | 
| 
       27 
     | 
    
         
            -
              spec.add_development_dependency 'bundler', '~> 1.3'
         
     | 
| 
       28 
27 
     | 
    
         
             
              spec.add_development_dependency 'capybara'
         
     | 
| 
       29 
28 
     | 
    
         
             
              spec.add_development_dependency 'm'
         
     | 
| 
       30 
29 
     | 
    
         
             
              spec.add_development_dependency 'memory_profiler'
         
     | 
| 
         @@ -33,8 +32,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       33 
32 
     | 
    
         
             
              spec.add_development_dependency 'rack'
         
     | 
| 
       34 
33 
     | 
    
         
             
              spec.add_development_dependency 'rack-test'
         
     | 
| 
       35 
34 
     | 
    
         
             
              spec.add_development_dependency 'rake'
         
     | 
| 
       36 
     | 
    
         
            -
              spec.add_development_dependency ' 
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
              spec.add_development_dependency 'resque'
         
     | 
| 
       38 
36 
     | 
    
         | 
| 
       39 
37 
     | 
    
         
             
              # TODO: used for benchmarking and tests I think we have other better benchmarking
         
     | 
| 
       40 
38 
     | 
    
         
             
              # perhaps time to drop this and refactor.
         
     | 
    
        data/lib/coverband.rb
    CHANGED
    
    | 
         @@ -5,6 +5,7 @@ require 'json' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            require 'redis'
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            require 'coverband/version'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'coverband/at_exit'
         
     | 
| 
       8 
9 
     | 
    
         
             
            require 'coverband/configuration'
         
     | 
| 
       9 
10 
     | 
    
         
             
            require 'coverband/adapters/base'
         
     | 
| 
       10 
11 
     | 
    
         
             
            require 'coverband/adapters/redis_store'
         
     | 
| 
         @@ -25,6 +26,7 @@ require 'coverband/integrations/rack_server_check' 
     | 
|
| 
       25 
26 
     | 
    
         
             
            require 'coverband/reporters/web'
         
     | 
| 
       26 
27 
     | 
    
         
             
            require 'coverband/integrations/middleware'
         
     | 
| 
       27 
28 
     | 
    
         
             
            require 'coverband/integrations/background'
         
     | 
| 
      
 29 
     | 
    
         
            +
            require 'coverband/integrations/resque' if defined? Resque
         
     | 
| 
       28 
30 
     | 
    
         | 
| 
       29 
31 
     | 
    
         
             
            module Coverband
         
     | 
| 
       30 
32 
     | 
    
         
             
              CONFIG_FILE = './config/coverband.rb'
         
     | 
| 
         @@ -51,6 +53,7 @@ module Coverband 
     | 
|
| 
       51 
53 
     | 
    
         | 
| 
       52 
54 
     | 
    
         
             
              def self.start
         
     | 
| 
       53 
55 
     | 
    
         
             
                Coverband::Collectors::Coverage.instance
         
     | 
| 
      
 56 
     | 
    
         
            +
                AtExit.register
         
     | 
| 
       54 
57 
     | 
    
         
             
                Background.start if configuration.background_reporting_enabled && !RackServerCheck.running?
         
     | 
| 
       55 
58 
     | 
    
         
             
              end
         
     | 
| 
       56 
59 
     | 
    
         | 
| 
         @@ -6,7 +6,12 @@ module Coverband 
     | 
|
| 
       6 
6 
     | 
    
         
             
                # RedisStore store a merged coverage file to redis
         
     | 
| 
       7 
7 
     | 
    
         
             
                ###
         
     | 
| 
       8 
8 
     | 
    
         
             
                class RedisStore < Base
         
     | 
| 
       9 
     | 
    
         
            -
                   
     | 
| 
      
 9 
     | 
    
         
            +
                  ###
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # This key isn't related to the coverband version, but to the interal format
         
     | 
| 
      
 11 
     | 
    
         
            +
                  # used to store data to redis. It is changed only when breaking changes to our
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # redis format are required.
         
     | 
| 
      
 13 
     | 
    
         
            +
                  ###
         
     | 
| 
      
 14 
     | 
    
         
            +
                  REDIS_STORAGE_FORMAT_VERSION = 'coverband3_1'
         
     | 
| 
       10 
15 
     | 
    
         | 
| 
       11 
16 
     | 
    
         
             
                  def initialize(redis, opts = {})
         
     | 
| 
       12 
17 
     | 
    
         
             
                    super()
         
     | 
| 
         @@ -24,7 +29,7 @@ module Coverband 
     | 
|
| 
       24 
29 
     | 
    
         
             
                  attr_reader :redis
         
     | 
| 
       25 
30 
     | 
    
         | 
| 
       26 
31 
     | 
    
         
             
                  def base_key
         
     | 
| 
       27 
     | 
    
         
            -
                    @base_key ||= [ 
     | 
| 
      
 32 
     | 
    
         
            +
                    @base_key ||= [REDIS_STORAGE_FORMAT_VERSION, @redis_namespace].compact.join('.')
         
     | 
| 
       28 
33 
     | 
    
         
             
                  end
         
     | 
| 
       29 
34 
     | 
    
         | 
| 
       30 
35 
     | 
    
         
             
                  def save_coverage(data)
         
     | 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Coverband
         
     | 
| 
      
 4 
     | 
    
         
            +
              class AtExit
         
     | 
| 
      
 5 
     | 
    
         
            +
                @semaphore = Mutex.new
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def self.register
         
     | 
| 
      
 8 
     | 
    
         
            +
                  return if @at_exit_registered
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @semaphore.synchronize do
         
     | 
| 
      
 10 
     | 
    
         
            +
                    return if @at_exit_registered
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @at_exit_registered = true
         
     | 
| 
      
 12 
     | 
    
         
            +
                    at_exit do
         
     | 
| 
      
 13 
     | 
    
         
            +
                      ::Coverband::Background.stop
         
     | 
| 
      
 14 
     | 
    
         
            +
                      Coverband::Collectors::Coverage.instance.report_coverage(true)
         
     | 
| 
      
 15 
     | 
    
         
            +
                      Coverband.configuration.logger&.debug('Coverband: Reported coverage before exit')
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -7,7 +7,8 @@ module Coverband 
     | 
|
| 
       7 
7 
     | 
    
         
             
                              :reporter, :reporting_frequency,
         
     | 
| 
       8 
8 
     | 
    
         
             
                              :redis_namespace, :redis_ttl,
         
     | 
| 
       9 
9 
     | 
    
         
             
                              :safe_reload_files, :background_reporting_enabled,
         
     | 
| 
       10 
     | 
    
         
            -
                              :background_reporting_sleep_seconds, :test_env
         
     | 
| 
      
 10 
     | 
    
         
            +
                              :background_reporting_sleep_seconds, :test_env,
         
     | 
| 
      
 11 
     | 
    
         
            +
                              :web_enable_clear
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
                attr_writer :logger, :s3_region, :s3_bucket, :s3_access_key_id, :s3_secret_access_key
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
         @@ -28,6 +29,7 @@ module Coverband 
     | 
|
| 
       28 
29 
     | 
    
         
             
                  @background_reporting_enabled = true
         
     | 
| 
       29 
30 
     | 
    
         
             
                  @background_reporting_sleep_seconds = 30
         
     | 
| 
       30 
31 
     | 
    
         
             
                  @test_env = nil
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @web_enable_clear = false
         
     | 
| 
       31 
33 
     | 
    
         | 
| 
       32 
34 
     | 
    
         
             
                  # TODO: should we push these to adapter configs
         
     | 
| 
       33 
35 
     | 
    
         
             
                  @s3_region = nil
         
     | 
| 
         @@ -18,7 +18,6 @@ module Coverband 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                  logger = Coverband.configuration.logger
         
     | 
| 
       20 
20 
     | 
    
         
             
                  @semaphore.synchronize do
         
     | 
| 
       21 
     | 
    
         
            -
                    binding.pry if defined?($debug) && $debug
         
     | 
| 
       22 
21 
     | 
    
         
             
                    return if @thread
         
     | 
| 
       23 
22 
     | 
    
         
             
                    logger&.debug('Coverband: Starting background reporting')
         
     | 
| 
       24 
23 
     | 
    
         
             
                    sleep_seconds = Coverband.configuration.background_reporting_sleep_seconds
         
     | 
| 
         @@ -29,12 +28,6 @@ module Coverband 
     | 
|
| 
       29 
28 
     | 
    
         
             
                        sleep(sleep_seconds)
         
     | 
| 
       30 
29 
     | 
    
         
             
                      end
         
     | 
| 
       31 
30 
     | 
    
         
             
                    end
         
     | 
| 
       32 
     | 
    
         
            -
                    binding.pry if defined?($debug) && $debug
         
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
       34 
     | 
    
         
            -
                  at_exit do
         
     | 
| 
       35 
     | 
    
         
            -
                    stop
         
     | 
| 
       36 
     | 
    
         
            -
                    Coverband::Collectors::Coverage.instance.report_coverage(true)
         
     | 
| 
       37 
     | 
    
         
            -
                    logger&.debug('Coverband: Reported coverage before exit')
         
     | 
| 
       38 
31 
     | 
    
         
             
                  end
         
     | 
| 
       39 
32 
     | 
    
         
             
                end
         
     | 
| 
       40 
33 
     | 
    
         
             
              end
         
     | 
| 
         @@ -9,10 +9,11 @@ module Coverband 
     | 
|
| 
       9 
9 
     | 
    
         
             
                def call(env)
         
     | 
| 
       10 
10 
     | 
    
         
             
                  @app.call(env)
         
     | 
| 
       11 
11 
     | 
    
         
             
                ensure
         
     | 
| 
      
 12 
     | 
    
         
            +
                  AtExit.register
         
     | 
| 
       12 
13 
     | 
    
         
             
                  if Coverband.configuration.background_reporting_enabled
         
     | 
| 
       13 
     | 
    
         
            -
                     
     | 
| 
      
 14 
     | 
    
         
            +
                    Background.start
         
     | 
| 
       14 
15 
     | 
    
         
             
                  else
         
     | 
| 
       15 
     | 
    
         
            -
                     
     | 
| 
      
 16 
     | 
    
         
            +
                    Collectors::Coverage.instance.report_coverage
         
     | 
| 
       16 
17 
     | 
    
         
             
                  end
         
     | 
| 
       17 
18 
     | 
    
         
             
                end
         
     | 
| 
       18 
19 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Resque.after_fork do |job|
         
     | 
| 
      
 4 
     | 
    
         
            +
              Coverband.start
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module Coverband
         
     | 
| 
      
 8 
     | 
    
         
            +
              module ResqueWorker
         
     | 
| 
      
 9 
     | 
    
         
            +
                def perform
         
     | 
| 
      
 10 
     | 
    
         
            +
                  super
         
     | 
| 
      
 11 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 12 
     | 
    
         
            +
                  Coverband::Collectors::Coverage.instance.report_coverage(true)
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            Resque::Job.prepend(Coverband::ResqueWorker)
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
         @@ -1,6 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            begin
         
     | 
| 
      
 4 
     | 
    
         
            +
              require 'rack'
         
     | 
| 
      
 5 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
       4 
7 
     | 
    
         | 
| 
       5 
8 
     | 
    
         
             
            module Coverband
         
     | 
| 
       6 
9 
     | 
    
         
             
              module Reporters
         
     | 
| 
         @@ -32,7 +35,7 @@ module Coverband 
     | 
|
| 
       32 
35 
     | 
    
         
             
                      case request.path_info
         
     | 
| 
       33 
36 
     | 
    
         
             
                      when /.*\.(css|js|gif|png)/
         
     | 
| 
       34 
37 
     | 
    
         
             
                        @static.call(env)
         
     | 
| 
       35 
     | 
    
         
            -
                      when %r{ 
     | 
| 
      
 38 
     | 
    
         
            +
                      when %r{\/$}
         
     | 
| 
       36 
39 
     | 
    
         
             
                        [200, { 'Content-Type' => 'text/html' }, [index]]
         
     | 
| 
       37 
40 
     | 
    
         
             
                      else
         
     | 
| 
       38 
41 
     | 
    
         
             
                        [404, { 'Content-Type' => 'text/html' }, ['404 error!']]
         
     | 
| 
         @@ -57,8 +60,12 @@ module Coverband 
     | 
|
| 
       57 
60 
     | 
    
         
             
                  end
         
     | 
| 
       58 
61 
     | 
    
         | 
| 
       59 
62 
     | 
    
         
             
                  def clear
         
     | 
| 
       60 
     | 
    
         
            -
                    Coverband.configuration. 
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
      
 63 
     | 
    
         
            +
                    if Coverband.configuration.web_enable_clear
         
     | 
| 
      
 64 
     | 
    
         
            +
                      Coverband.configuration.store.clear!
         
     | 
| 
      
 65 
     | 
    
         
            +
                      notice = 'coverband coverage cleared'
         
     | 
| 
      
 66 
     | 
    
         
            +
                    else
         
     | 
| 
      
 67 
     | 
    
         
            +
                      notice = 'web_enable_clear isnt enabled in your configuration'
         
     | 
| 
      
 68 
     | 
    
         
            +
                    end
         
     | 
| 
       62 
69 
     | 
    
         
             
                    [301, { 'Location' => "#{base_path}?notice=#{notice}" }, []]
         
     | 
| 
       63 
70 
     | 
    
         
             
                  end
         
     | 
| 
       64 
71 
     | 
    
         | 
| 
         @@ -56,7 +56,7 @@ module Coverband 
     | 
|
| 
       56 
56 
     | 
    
         | 
| 
       57 
57 
     | 
    
         
             
                  def asset_output_path
         
     | 
| 
       58 
58 
     | 
    
         
             
                    return @asset_output_path if defined?(@asset_output_path) && @asset_output_path
         
     | 
| 
       59 
     | 
    
         
            -
                    @asset_output_path = File.join(output_path 
     | 
| 
      
 59 
     | 
    
         
            +
                    @asset_output_path = File.join(output_path)
         
     | 
| 
       60 
60 
     | 
    
         
             
                    FileUtils.mkdir_p(@asset_output_path)
         
     | 
| 
       61 
61 
     | 
    
         
             
                    @asset_output_path
         
     | 
| 
       62 
62 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -123,8 +123,10 @@ module Coverband 
     | 
|
| 
       123 
123 
     | 
    
         
             
                    "<abbr class=\"timeago\" title=\"#{time.iso8601}\">#{time.iso8601}</abbr>"
         
     | 
| 
       124 
124 
     | 
    
         
             
                  end
         
     | 
| 
       125 
125 
     | 
    
         | 
| 
      
 126 
     | 
    
         
            +
                  # a bug that existed in simplecov was not checking that root was at the start of the file name
         
     | 
| 
      
 127 
     | 
    
         
            +
                  # I had previously patched this in my local Rails app
         
     | 
| 
       126 
128 
     | 
    
         
             
                  def shortened_filename(source_file)
         
     | 
| 
       127 
     | 
    
         
            -
                    source_file.filename.sub(Coverband.configuration.root, '.').gsub(/^\.\//, '')
         
     | 
| 
      
 129 
     | 
    
         
            +
                    source_file.filename.sub(%r{^#{Coverband.configuration.root}}, '.').gsub(/^\.\//, '')
         
     | 
| 
       128 
130 
     | 
    
         
             
                  end
         
     | 
| 
       129 
131 
     | 
    
         | 
| 
       130 
132 
     | 
    
         
             
                  def link_to_source_file(source_file)
         
     | 
| 
         @@ -3,27 +3,17 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            namespace :coverband do
         
     | 
| 
       4 
4 
     | 
    
         
             
              Coverband.configure
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
               
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              # You might want to override them and clear the filters.
         
     | 
| 
       9 
     | 
    
         
            -
              # Or run the task `coverage_no_filters` below.
         
     | 
| 
       10 
     | 
    
         
            -
              ###
         
     | 
| 
       11 
     | 
    
         
            -
              desc 'report runtime Coverband code coverage'
         
     | 
| 
       12 
     | 
    
         
            -
              task coverage: :environment do
         
     | 
| 
       13 
     | 
    
         
            -
                if Coverband.configuration.reporter == 'scov'
         
     | 
| 
       14 
     | 
    
         
            -
                  Coverband::Reporters::HTMLReport.report(Coverband.configuration.store)
         
     | 
| 
       15 
     | 
    
         
            -
                else
         
     | 
| 
       16 
     | 
    
         
            -
                  Coverband::Reporters::ConsoleReport.report(Coverband.configuration.store)
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              def environment
         
     | 
| 
      
 7 
     | 
    
         
            +
                Rake.application['environment'].invoke if Rake::Task.task_defined?('environment')
         
     | 
| 
       18 
8 
     | 
    
         
             
              end
         
     | 
| 
       19 
9 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
              desc 'report runtime  
     | 
| 
       21 
     | 
    
         
            -
              task  
     | 
| 
      
 10 
     | 
    
         
            +
              desc 'report runtime Coverband code coverage'
         
     | 
| 
      
 11 
     | 
    
         
            +
              task :coverage do
         
     | 
| 
      
 12 
     | 
    
         
            +
                environment
         
     | 
| 
       22 
13 
     | 
    
         
             
                if Coverband.configuration.reporter == 'scov'
         
     | 
| 
       23 
     | 
    
         
            -
                  clear_simplecov_filters
         
     | 
| 
       24 
14 
     | 
    
         
             
                  Coverband::Reporters::HTMLReport.report(Coverband.configuration.store)
         
     | 
| 
       25 
15 
     | 
    
         
             
                else
         
     | 
| 
       26 
     | 
    
         
            -
                   
     | 
| 
      
 16 
     | 
    
         
            +
                  Coverband::Reporters::ConsoleReport.report(Coverband.configuration.store)
         
     | 
| 
       27 
17 
     | 
    
         
             
                end
         
     | 
| 
       28 
18 
     | 
    
         
             
              end
         
     | 
| 
       29 
19 
     | 
    
         | 
| 
         @@ -31,7 +21,8 @@ namespace :coverband do 
     | 
|
| 
       31 
21 
     | 
    
         
             
              # clear data helpful for development or after configuration issues
         
     | 
| 
       32 
22 
     | 
    
         
             
              ###
         
     | 
| 
       33 
23 
     | 
    
         
             
              desc 'reset Coverband coverage data, helpful for development, debugging, etc'
         
     | 
| 
       34 
     | 
    
         
            -
              task clear 
     | 
| 
      
 24 
     | 
    
         
            +
              task :clear do
         
     | 
| 
      
 25 
     | 
    
         
            +
                environment
         
     | 
| 
       35 
26 
     | 
    
         
             
                Coverband.configuration.store.clear!
         
     | 
| 
       36 
27 
     | 
    
         
             
              end
         
     | 
| 
       37 
28 
     | 
    
         
             
            end
         
     | 
    
        data/lib/coverband/version.rb
    CHANGED
    
    
    
        data/test/test_helper.rb
    CHANGED
    
    | 
         @@ -14,17 +14,12 @@ require 'mocha/minitest' 
     | 
|
| 
       14 
14 
     | 
    
         
             
            require 'ostruct'
         
     | 
| 
       15 
15 
     | 
    
         
             
            require 'json'
         
     | 
| 
       16 
16 
     | 
    
         
             
            require 'redis'
         
     | 
| 
      
 17 
     | 
    
         
            +
            require 'resque'
         
     | 
| 
       17 
18 
     | 
    
         
             
            require 'pry-byebug'
         
     | 
| 
       18 
19 
     | 
    
         
             
            $VERBOSE = original_verbosity
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
       20 
21 
     | 
    
         
             
            Coveralls.wear!
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
            SimpleCov.start do
         
     | 
| 
       23 
     | 
    
         
            -
              add_filter 'specs/ruby/1.9.1/gems/'
         
     | 
| 
       24 
     | 
    
         
            -
              add_filter '/test/'
         
     | 
| 
       25 
     | 
    
         
            -
              add_filter '/config/'
         
     | 
| 
       26 
     | 
    
         
            -
            end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
23 
     | 
    
         
             
            module Coverband
         
     | 
| 
       29 
24 
     | 
    
         
             
              module Test
         
     | 
| 
       30 
25 
     | 
    
         
             
                def self.reset
         
     | 
| 
         @@ -3,7 +3,7 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require File.expand_path('../test_helper', File.dirname(__FILE__))
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            class RedisTest < Minitest::Test
         
     | 
| 
       6 
     | 
    
         
            -
               
     | 
| 
      
 6 
     | 
    
         
            +
              REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
              def setup
         
     | 
| 
       9 
9 
     | 
    
         
             
                super
         
     | 
| 
         @@ -46,7 +46,7 @@ class RedisTest < Minitest::Test 
     | 
|
| 
       46 
46 
     | 
    
         
             
              end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
              def test_clear
         
     | 
| 
       49 
     | 
    
         
            -
                @redis.expects(:del).with( 
     | 
| 
      
 49 
     | 
    
         
            +
                @redis.expects(:del).with(REDIS_STORAGE_FORMAT_VERSION).once
         
     | 
| 
       50 
50 
     | 
    
         
             
                @store.clear!
         
     | 
| 
       51 
51 
     | 
    
         
             
              end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require File.expand_path('../test_helper', File.dirname(__FILE__))
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class AtExitTest < Minitest::Test
         
     | 
| 
      
 6 
     | 
    
         
            +
              test 'only registers once' do
         
     | 
| 
      
 7 
     | 
    
         
            +
                Coverband::AtExit.instance_eval { @at_exit_registered = nil }
         
     | 
| 
      
 8 
     | 
    
         
            +
                Coverband::AtExit.expects(:at_exit).yields.once.returns(true)
         
     | 
| 
      
 9 
     | 
    
         
            +
                2.times { Coverband::AtExit.register }
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
         @@ -22,7 +22,6 @@ class BackgroundTest < Minitest::Test 
     | 
|
| 
       22 
22 
     | 
    
         
             
                Thread.expects(:new).yields.returns(ThreadDouble.new)
         
     | 
| 
       23 
23 
     | 
    
         
             
                Coverband::Background.expects(:loop).yields
         
     | 
| 
       24 
24 
     | 
    
         
             
                Coverband::Background.expects(:sleep).with(30)
         
     | 
| 
       25 
     | 
    
         
            -
                Coverband::Background.expects(:at_exit).returns(false)
         
     | 
| 
       26 
25 
     | 
    
         
             
                Coverband::Collectors::Coverage.instance.expects(:report_coverage).once
         
     | 
| 
       27 
26 
     | 
    
         
             
                2.times { Coverband::Background.start }
         
     | 
| 
       28 
27 
     | 
    
         
             
              end
         
     | 
| 
         @@ -20,4 +20,27 @@ class BaseTest < Minitest::Test 
     | 
|
| 
       20 
20 
     | 
    
         
             
                coverband = Coverband::Collectors::Coverage.instance.reset_instance
         
     | 
| 
       21 
21 
     | 
    
         
             
                assert_equal ['vendor', 'internal:prelude', 'schema.rb'], coverband.instance_variable_get('@ignore_patterns')
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              test 's3 options' do
         
     | 
| 
      
 25 
     | 
    
         
            +
                Coverband::Collectors::Coverage.instance.reset_instance
         
     | 
| 
      
 26 
     | 
    
         
            +
                Coverband.configure do |config|
         
     | 
| 
      
 27 
     | 
    
         
            +
                  config.s3_bucket = 'bucket'
         
     | 
| 
      
 28 
     | 
    
         
            +
                  config.s3_region = 'region'
         
     | 
| 
      
 29 
     | 
    
         
            +
                  config.s3_access_key_id = 'key_id'
         
     | 
| 
      
 30 
     | 
    
         
            +
                  config.s3_secret_access_key = 'secret'
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
                assert_equal 'bucket', Coverband.configuration.s3_bucket
         
     | 
| 
      
 33 
     | 
    
         
            +
                assert_equal 'region', Coverband.configuration.s3_region
         
     | 
| 
      
 34 
     | 
    
         
            +
                assert_equal 'key_id', Coverband.configuration.s3_access_key_id
         
     | 
| 
      
 35 
     | 
    
         
            +
                assert_equal 'secret', Coverband.configuration.s3_secret_access_key
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              test 'store raises issues' do
         
     | 
| 
      
 39 
     | 
    
         
            +
                Coverband::Collectors::Coverage.instance.reset_instance
         
     | 
| 
      
 40 
     | 
    
         
            +
                assert_raises RuntimeError do
         
     | 
| 
      
 41 
     | 
    
         
            +
                  Coverband.configure do |config|
         
     | 
| 
      
 42 
     | 
    
         
            +
                    config.store = 'fake'
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
       23 
46 
     | 
    
         
             
            end
         
     | 
| 
         @@ -4,10 +4,11 @@ require File.expand_path('../test_helper', File.dirname(__FILE__)) 
     | 
|
| 
       4 
4 
     | 
    
         
             
            require 'rack'
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            class FullStackTest < Minitest::Test
         
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
      
 7 
     | 
    
         
            +
              REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
         
     | 
| 
       8 
8 
     | 
    
         
             
              TEST_RACK_APP = '../fake_app/basic_rack.rb'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              def setup
         
     | 
| 
      
 11 
     | 
    
         
            +
                super
         
     | 
| 
       11 
12 
     | 
    
         
             
                Coverband::Collectors::Coverage.instance.reset_instance
         
     | 
| 
       12 
13 
     | 
    
         
             
                Coverband.configure do |config|
         
     | 
| 
       13 
14 
     | 
    
         
             
                  config.reporting_frequency = 100.0
         
     | 
| 
         @@ -35,11 +36,6 @@ class FullStackTest < Minitest::Test 
     | 
|
| 
       35 
36 
     | 
    
         
             
                sleep(0.1)
         
     | 
| 
       36 
37 
     | 
    
         
             
                expected = [nil, nil, 1, nil, 1, 1, 2, nil, nil]
         
     | 
| 
       37 
38 
     | 
    
         
             
                assert_equal expected, Coverband.configuration.store.coverage[@rack_file]['data']
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                # expected = nil
         
     | 
| 
       40 
     | 
    
         
            -
                # TODO: read the html to test it matches expectations? or return data as a hash?
         
     | 
| 
       41 
     | 
    
         
            -
                # actual = Coverband::Reporters::HTMLReport.report(Coverband.configuration.store, open_report: false)
         
     | 
| 
       42 
     | 
    
         
            -
                # assert_equal expected, actual
         
     | 
| 
       43 
39 
     | 
    
         
             
              end
         
     | 
| 
       44 
40 
     | 
    
         | 
| 
       45 
41 
     | 
    
         
             
              private
         
     | 
| 
         @@ -4,7 +4,7 @@ require File.expand_path('../test_helper', File.dirname(__FILE__)) 
     | 
|
| 
       4 
4 
     | 
    
         
             
            require 'rack'
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            class MiddlewareTest < Minitest::Test
         
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
      
 7 
     | 
    
         
            +
              REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              def setup
         
     | 
| 
       10 
10 
     | 
    
         
             
                super
         
     | 
| 
         @@ -3,7 +3,7 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require File.expand_path('../test_helper', File.dirname(__FILE__))
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            class HTMLReportTest < Minitest::Test
         
     | 
| 
       6 
     | 
    
         
            -
               
     | 
| 
      
 6 
     | 
    
         
            +
              REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
              def setup
         
     | 
| 
       9 
9 
     | 
    
         
             
                super
         
     | 
| 
         @@ -3,7 +3,7 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require File.expand_path('../test_helper', File.dirname(__FILE__))
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            class ReportHTMLTest < Minitest::Test
         
     | 
| 
       6 
     | 
    
         
            -
               
     | 
| 
      
 6 
     | 
    
         
            +
              REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
              def setup
         
     | 
| 
       9 
9 
     | 
    
         
             
                super
         
     | 
| 
         @@ -12,7 +12,7 @@ class ReportHTMLTest < Minitest::Test 
     | 
|
| 
       12 
12 
     | 
    
         
             
                @store.clear!
         
     | 
| 
       13 
13 
     | 
    
         
             
              end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
              test 'generate scov report' do
         
     | 
| 
      
 15 
     | 
    
         
            +
              test 'generate scov html report' do
         
     | 
| 
       16 
16 
     | 
    
         
             
                Coverband.configure do |config|
         
     | 
| 
       17 
17 
     | 
    
         
             
                  config.reporter          = 'scov'
         
     | 
| 
       18 
18 
     | 
    
         
             
                  config.store             = @store
         
     | 
| 
         @@ -23,7 +23,24 @@ class ReportHTMLTest < Minitest::Test 
     | 
|
| 
       23 
23 
     | 
    
         
             
                @store.send(:save_report, basic_coverage)
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                html = Coverband::Reporters::HTMLReport.report(@store,
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
                                                               html: true,
         
     | 
| 
      
 27 
     | 
    
         
            +
                                                               open_report: false)
         
     | 
| 
       27 
28 
     | 
    
         
             
                assert_match 'Generated by', html
         
     | 
| 
       28 
29 
     | 
    
         
             
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              test 'generate scov report file' do
         
     | 
| 
      
 32 
     | 
    
         
            +
                Coverband.configure do |config|
         
     | 
| 
      
 33 
     | 
    
         
            +
                  config.reporter          = 'scov'
         
     | 
| 
      
 34 
     | 
    
         
            +
                  config.store             = @store
         
     | 
| 
      
 35 
     | 
    
         
            +
                  config.s3_bucket         = nil
         
     | 
| 
      
 36 
     | 
    
         
            +
                  config.ignore            = ['notsomething.rb']
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
                mock_file_hash
         
     | 
| 
      
 39 
     | 
    
         
            +
                @store.send(:save_report, basic_coverage)
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                Coverband::Utils::HTMLFormatter.any_instance.expects(:format!).once
         
     | 
| 
      
 42 
     | 
    
         
            +
                Coverband::Reporters::HTMLReport.report(@store,
         
     | 
| 
      
 43 
     | 
    
         
            +
                                                        html: false,
         
     | 
| 
      
 44 
     | 
    
         
            +
                                                        open_report: false)
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
       29 
46 
     | 
    
         
             
            end
         
     | 
| 
         @@ -21,18 +21,31 @@ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0') 
     | 
|
| 
       21 
21 
     | 
    
         
             
                    Coverband.configuration.s3_bucket = nil
         
     | 
| 
       22 
22 
     | 
    
         
             
                  end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                  # TODO: add tests for all endpoints
         
     | 
| 
       25 
24 
     | 
    
         
             
                  test 'renders index content' do
         
     | 
| 
       26 
25 
     | 
    
         
             
                    get '/'
         
     | 
| 
       27 
26 
     | 
    
         
             
                    assert last_response.ok?
         
     | 
| 
       28 
27 
     | 
    
         
             
                    assert_match 'Coverband Admin', last_response.body
         
     | 
| 
       29 
28 
     | 
    
         
             
                  end
         
     | 
| 
       30 
29 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                  test 'renders  
     | 
| 
       32 
     | 
    
         
            -
                    Coverband::Reporters::HTMLReport.expects(:report).returns('content')
         
     | 
| 
      
 30 
     | 
    
         
            +
                  test 'renders 404' do
         
     | 
| 
       33 
31 
     | 
    
         
             
                    get '/show'
         
     | 
| 
       34 
     | 
    
         
            -
                    assert last_response. 
     | 
| 
       35 
     | 
    
         
            -
                    assert_equal ' 
     | 
| 
      
 32 
     | 
    
         
            +
                    assert last_response.not_found?
         
     | 
| 
      
 33 
     | 
    
         
            +
                    assert_equal '404 error!', last_response.body
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  test 'clears coverband' do
         
     | 
| 
      
 37 
     | 
    
         
            +
                    post '/clear'
         
     | 
| 
      
 38 
     | 
    
         
            +
                    assert_equal 301, last_response.status
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  test 'collect_coverage' do
         
     | 
| 
      
 42 
     | 
    
         
            +
                    post '/collect_coverage'
         
     | 
| 
      
 43 
     | 
    
         
            +
                    assert_equal 301, last_response.status
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  test 'reload_files' do
         
     | 
| 
      
 47 
     | 
    
         
            +
                    post '/reload_files'
         
     | 
| 
      
 48 
     | 
    
         
            +
                    assert_equal 301, last_response.status
         
     | 
| 
       36 
49 
     | 
    
         
             
                  end
         
     | 
| 
       37 
50 
     | 
    
         
             
                end
         
     | 
| 
       38 
51 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require File.expand_path('../test_helper', File.dirname(__FILE__))
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class ResqueWorkerTest < Minitest::Test
         
     | 
| 
      
 6 
     | 
    
         
            +
              def enqueue_and_run_job
         
     | 
| 
      
 7 
     | 
    
         
            +
                Resque.enqueue(TestResqueJob)
         
     | 
| 
      
 8 
     | 
    
         
            +
                queue = ENV['QUEUE'] ='resque_coverband'
         
     | 
| 
      
 9 
     | 
    
         
            +
                Resque::Worker.new.work_one_job
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 13 
     | 
    
         
            +
                super
         
     | 
| 
      
 14 
     | 
    
         
            +
                Coverband.configure do |config|
         
     | 
| 
      
 15 
     | 
    
         
            +
                  config.background_reporting_enabled = false
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
                Coverband.start
         
     | 
| 
      
 18 
     | 
    
         
            +
                redis = Coverband.configuration.store.send(:redis)
         
     | 
| 
      
 19 
     | 
    
         
            +
                Resque.redis = redis
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              test 'resque job coverage' do
         
     | 
| 
      
 23 
     | 
    
         
            +
                resque_job_file = File.expand_path('./test_resque_job.rb', File.dirname(__FILE__))
         
     | 
| 
      
 24 
     | 
    
         
            +
                require resque_job_file
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                #report after loading the file in parent process
         
     | 
| 
      
 27 
     | 
    
         
            +
                Coverband::Collectors::Coverage.instance.report_coverage(true)
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                enqueue_and_run_job
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                puts "assert_equal 1, Coverband.configuration.store.coverage['#{resque_job_file}']['data'][4]"
         
     | 
| 
      
 32 
     | 
    
         
            +
                assert_equal 1, Coverband.configuration.store.coverage[resque_job_file]['data'][4]
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
    
        data/views/layout.erb
    CHANGED
    
    | 
         @@ -18,7 +18,9 @@ 
     | 
|
| 
       18 
18 
     | 
    
         
             
                    <a href='<%= base_path %>'>Coverband Admin</a>  
         
     | 
| 
       19 
19 
     | 
    
         
             
                    <%= button("#{base_path}collect_coverage", 'force coverage collection') %>  
         
     | 
| 
       20 
20 
     | 
    
         
             
                    <%= button("#{base_path}reload_files", 'reload Coverband files') %>  
         
     | 
| 
       21 
     | 
    
         
            -
                     
     | 
| 
      
 21 
     | 
    
         
            +
                    <% if Coverband.configuration.web_enable_clear %>
         
     | 
| 
      
 22 
     | 
    
         
            +
                      <%= button("#{base_path}clear", 'clear coverage report', delete: true) %>
         
     | 
| 
      
 23 
     | 
    
         
            +
                    <% end %>
         
     | 
| 
       22 
24 
     | 
    
         
             
                  </div>
         
     | 
| 
       23 
25 
     | 
    
         
             
                  <% if notice.to_s.length > 0 %>
         
     | 
| 
       24 
26 
     | 
    
         
             
                  <div class="notice"><%= notice %></div>
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: coverband
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.1.0.alpha
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Dan Mayer
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date:  
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2019-02-02 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: aws-sdk-s3
         
     | 
| 
         @@ -39,20 +39,6 @@ dependencies: 
     | 
|
| 
       39 
39 
     | 
    
         
             
                - - ">="
         
     | 
| 
       40 
40 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       41 
41 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       42 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       43 
     | 
    
         
            -
              name: bundler
         
     | 
| 
       44 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       45 
     | 
    
         
            -
                requirements:
         
     | 
| 
       46 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       47 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       48 
     | 
    
         
            -
                    version: '1.3'
         
     | 
| 
       49 
     | 
    
         
            -
              type: :development
         
     | 
| 
       50 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       51 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       52 
     | 
    
         
            -
                requirements:
         
     | 
| 
       53 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       54 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       55 
     | 
    
         
            -
                    version: '1.3'
         
     | 
| 
       56 
42 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       57 
43 
     | 
    
         
             
              name: capybara
         
     | 
| 
       58 
44 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -166,7 +152,7 @@ dependencies: 
     | 
|
| 
       166 
152 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       167 
153 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       168 
154 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       169 
     | 
    
         
            -
              name:  
     | 
| 
      
 155 
     | 
    
         
            +
              name: resque
         
     | 
| 
       170 
156 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       171 
157 
     | 
    
         
             
                requirements:
         
     | 
| 
       172 
158 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -258,11 +244,13 @@ files: 
     | 
|
| 
       258 
244 
     | 
    
         
             
            - lib/coverband/adapters/base.rb
         
     | 
| 
       259 
245 
     | 
    
         
             
            - lib/coverband/adapters/file_store.rb
         
     | 
| 
       260 
246 
     | 
    
         
             
            - lib/coverband/adapters/redis_store.rb
         
     | 
| 
      
 247 
     | 
    
         
            +
            - lib/coverband/at_exit.rb
         
     | 
| 
       261 
248 
     | 
    
         
             
            - lib/coverband/collectors/coverage.rb
         
     | 
| 
       262 
249 
     | 
    
         
             
            - lib/coverband/configuration.rb
         
     | 
| 
       263 
250 
     | 
    
         
             
            - lib/coverband/integrations/background.rb
         
     | 
| 
       264 
251 
     | 
    
         
             
            - lib/coverband/integrations/middleware.rb
         
     | 
| 
       265 
252 
     | 
    
         
             
            - lib/coverband/integrations/rack_server_check.rb
         
     | 
| 
      
 253 
     | 
    
         
            +
            - lib/coverband/integrations/resque.rb
         
     | 
| 
       266 
254 
     | 
    
         
             
            - lib/coverband/reporters/base.rb
         
     | 
| 
       267 
255 
     | 
    
         
             
            - lib/coverband/reporters/console_report.rb
         
     | 
| 
       268 
256 
     | 
    
         
             
            - lib/coverband/reporters/html_report.rb
         
     | 
| 
         @@ -331,6 +319,7 @@ files: 
     | 
|
| 
       331 
319 
     | 
    
         
             
            - test/unit/adapters_base_test.rb
         
     | 
| 
       332 
320 
     | 
    
         
             
            - test/unit/adapters_file_store_test.rb
         
     | 
| 
       333 
321 
     | 
    
         
             
            - test/unit/adapters_redis_store_test.rb
         
     | 
| 
      
 322 
     | 
    
         
            +
            - test/unit/at_exit_test.rb
         
     | 
| 
       334 
323 
     | 
    
         
             
            - test/unit/background_test.rb
         
     | 
| 
       335 
324 
     | 
    
         
             
            - test/unit/collectors_coverage_test.rb
         
     | 
| 
       336 
325 
     | 
    
         
             
            - test/unit/configuration_test.rb
         
     | 
| 
         @@ -344,6 +333,8 @@ files: 
     | 
|
| 
       344 
333 
     | 
    
         
             
            - test/unit/reports_console_test.rb
         
     | 
| 
       345 
334 
     | 
    
         
             
            - test/unit/reports_html_test.rb
         
     | 
| 
       346 
335 
     | 
    
         
             
            - test/unit/reports_web_test.rb
         
     | 
| 
      
 336 
     | 
    
         
            +
            - test/unit/resque_worker_test.rb
         
     | 
| 
      
 337 
     | 
    
         
            +
            - test/unit/test_resque_job.rb
         
     | 
| 
       347 
338 
     | 
    
         
             
            - test/unit/utils/file_list_test.rb
         
     | 
| 
       348 
339 
     | 
    
         
             
            - test/unit/utils/lines_classifier_test.rb
         
     | 
| 
       349 
340 
     | 
    
         
             
            - test/unit/utils/result_test.rb
         
     | 
| 
         @@ -368,12 +359,12 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       368 
359 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       369 
360 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       370 
361 
     | 
    
         
             
              requirements:
         
     | 
| 
       371 
     | 
    
         
            -
              - - " 
     | 
| 
      
 362 
     | 
    
         
            +
              - - ">"
         
     | 
| 
       372 
363 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       373 
     | 
    
         
            -
                  version:  
     | 
| 
      
 364 
     | 
    
         
            +
                  version: 1.3.1
         
     | 
| 
       374 
365 
     | 
    
         
             
            requirements: []
         
     | 
| 
       375 
366 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       376 
     | 
    
         
            -
            rubygems_version: 2.5. 
     | 
| 
      
 367 
     | 
    
         
            +
            rubygems_version: 2.5.2.3
         
     | 
| 
       377 
368 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       378 
369 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       379 
370 
     | 
    
         
             
            summary: Rack middleware to help measure production code usage (LOC runtime usage)
         
     | 
| 
         @@ -409,6 +400,7 @@ test_files: 
     | 
|
| 
       409 
400 
     | 
    
         
             
            - test/unit/adapters_base_test.rb
         
     | 
| 
       410 
401 
     | 
    
         
             
            - test/unit/adapters_file_store_test.rb
         
     | 
| 
       411 
402 
     | 
    
         
             
            - test/unit/adapters_redis_store_test.rb
         
     | 
| 
      
 403 
     | 
    
         
            +
            - test/unit/at_exit_test.rb
         
     | 
| 
       412 
404 
     | 
    
         
             
            - test/unit/background_test.rb
         
     | 
| 
       413 
405 
     | 
    
         
             
            - test/unit/collectors_coverage_test.rb
         
     | 
| 
       414 
406 
     | 
    
         
             
            - test/unit/configuration_test.rb
         
     | 
| 
         @@ -422,6 +414,8 @@ test_files: 
     | 
|
| 
       422 
414 
     | 
    
         
             
            - test/unit/reports_console_test.rb
         
     | 
| 
       423 
415 
     | 
    
         
             
            - test/unit/reports_html_test.rb
         
     | 
| 
       424 
416 
     | 
    
         
             
            - test/unit/reports_web_test.rb
         
     | 
| 
      
 417 
     | 
    
         
            +
            - test/unit/resque_worker_test.rb
         
     | 
| 
      
 418 
     | 
    
         
            +
            - test/unit/test_resque_job.rb
         
     | 
| 
       425 
419 
     | 
    
         
             
            - test/unit/utils/file_list_test.rb
         
     | 
| 
       426 
420 
     | 
    
         
             
            - test/unit/utils/lines_classifier_test.rb
         
     | 
| 
       427 
421 
     | 
    
         
             
            - test/unit/utils/result_test.rb
         
     |