rspec_profiling 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -6
- data/lib/rspec_profiling/collectors/csv.rb +1 -0
- data/lib/rspec_profiling/collectors/psql.rb +1 -0
- data/lib/rspec_profiling/collectors/sql.rb +1 -0
- data/lib/rspec_profiling/run.rb +1 -0
- data/lib/rspec_profiling/vcs/git.rb +4 -0
- data/lib/rspec_profiling/vcs/git_svn.rb +4 -0
- data/lib/rspec_profiling/vcs/svn.rb +4 -0
- data/lib/rspec_profiling/version.rb +1 -1
- data/rspec_profiling +0 -0
- data/spec/collectors/psql_spec.rb +5 -0
- data/spec/collectors/sql_spec.rb +5 -0
- data/spec/run_spec.rb +24 -8
- data/spec/vcs/git_spec.rb +27 -0
- data/spec/vcs/svn_spec.rb +25 -0
- metadata +7 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fc2c3039e171c0935a2c938945e538e5ca46f1c2
         | 
| 4 | 
            +
              data.tar.gz: bf4e57b9289fe5a396084b0e80a836586259ad2c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 526049fc2f4db27873427c16cde7da2ab1a1abc87f513fac462fdef5c96aad5f214cb2a59658a4d04ee9fe0faf1c9ecaf577b76829cbefab2f914d54fd3ecea1
         | 
| 7 | 
            +
              data.tar.gz: ba80e7353e2b5f1b2187a08172a2b4bc280b16aaee9a79de1c99ac1db7f3f306e2b8de10a09b0c2ba9910e5e0f5f2d1b0380df16bbb66725f994e964a9884d1b
         | 
    
        data/README.md
    CHANGED
    
    | @@ -84,24 +84,32 @@ By default, profiles are collected in an SQL database. Make sure you've | |
| 84 84 | 
             
            run the installation rake task before attempting.
         | 
| 85 85 |  | 
| 86 86 | 
             
            You can review results by running the RspecProfiling console.
         | 
| 87 | 
            +
            The console has a preloaded `results` variable.
         | 
| 87 88 |  | 
| 88 89 | 
             
            ```
         | 
| 89 90 | 
             
            bundle exec rake rspec_profiling:console
         | 
| 90 91 |  | 
| 91 92 | 
             
            > results.count
         | 
| 92 93 | 
             
            => 1970
         | 
| 94 | 
            +
            ```
         | 
| 93 95 |  | 
| 96 | 
            +
            You can find the spec that runs the most queries:
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            ```
         | 
| 94 99 | 
             
            > results.order(:query_count).last.to_s
         | 
| 95 100 | 
             
            => "Updating my account - ./spec/features/account_spec.rb:15"
         | 
| 96 101 | 
             
            ```
         | 
| 97 102 |  | 
| 98 | 
            -
             | 
| 103 | 
            +
            Or find the spec that takes the most time:
         | 
| 99 104 |  | 
| 100 105 | 
             
            ```
         | 
| 101 | 
            -
            results. | 
| 102 | 
            -
             | 
| 106 | 
            +
            > results.order(:time).last.to_s
         | 
| 107 | 
            +
            => "Updating my account - ./spec/features/account_spec.rb:15"
         | 
| 103 108 | 
             
            ```
         | 
| 104 109 |  | 
| 110 | 
            +
            There are additional attributes available on the `Result` instances to enable
         | 
| 111 | 
            +
            debugging, such as `exception` and `status`.
         | 
| 112 | 
            +
             | 
| 105 113 | 
             
            #### CSV
         | 
| 106 114 |  | 
| 107 115 | 
             
            You can configure `RspecProfiling` to collect results in a CSV in `config/initializers/rspec_profiling.rb`:
         | 
| @@ -152,6 +160,17 @@ end | |
| 152 160 | 
             
            - `csv_path` - the directory in which CSV files are dumped
         | 
| 153 161 | 
             
            - `collector` - collector to use
         | 
| 154 162 |  | 
| 163 | 
            +
            ### Usage in a script
         | 
| 164 | 
            +
             | 
| 165 | 
            +
            If you want to access the results from a Ruby script instead of the `rake rspec_profiling:console` shell command:
         | 
| 166 | 
            +
             | 
| 167 | 
            +
            ```ruby
         | 
| 168 | 
            +
            require 'rspec_profiling'
         | 
| 169 | 
            +
            require 'rspec_profiling/console'
         | 
| 170 | 
            +
            ```
         | 
| 171 | 
            +
             | 
| 172 | 
            +
            Then `results` will be available as a variable to the script. 
         | 
| 173 | 
            +
             | 
| 155 174 | 
             
            ## Uninstalling
         | 
| 156 175 |  | 
| 157 176 | 
             
            To remove the results database, run `bundle exec rake rspec_profiling:uninstall`.
         | 
| @@ -166,8 +185,8 @@ To remove the results database, run `bundle exec rake rspec_profiling:uninstall` | |
| 166 185 |  | 
| 167 186 | 
             
            ## About Foraker Labs
         | 
| 168 187 |  | 
| 169 | 
            -
             | 
| 188 | 
            +
            
         | 
| 170 189 |  | 
| 171 | 
            -
             | 
| 190 | 
            +
            Foraker Labs builds exciting web and mobile apps in Boulder, CO. Our work powers a wide variety of businesses with many different needs. We love open source software, and we're proud to contribute where we can. Interested to learn more? [Contact us today](https://www.foraker.com/contact-us).
         | 
| 172 191 |  | 
| 173 | 
            -
             | 
| 192 | 
            +
            This project is maintained by Foraker Labs. The names and logos of Foraker Labs are fully owned and copyright Foraker Design, LLC.
         | 
    
        data/lib/rspec_profiling/run.rb
    CHANGED
    
    
    
        data/rspec_profiling
    CHANGED
    
    | Binary file | 
| @@ -13,6 +13,7 @@ module RspecProfiling | |
| 13 13 |  | 
| 14 14 | 
             
                    before do
         | 
| 15 15 | 
             
                      collector.insert({
         | 
| 16 | 
            +
                        branch: "master",
         | 
| 16 17 | 
             
                        commit: "ABC123",
         | 
| 17 18 | 
             
                        date: "Thu Dec 18 12:00:00 2012",
         | 
| 18 19 | 
             
                        file: "/some/file.rb",
         | 
| @@ -32,6 +33,10 @@ module RspecProfiling | |
| 32 33 | 
             
                      expect(collector.results.count).to eq 1
         | 
| 33 34 | 
             
                    end
         | 
| 34 35 |  | 
| 36 | 
            +
                    it "records the branch name" do
         | 
| 37 | 
            +
                      expect(result.branch).to eq "master"
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
             | 
| 35 40 | 
             
                    it "records the commit SHA" do
         | 
| 36 41 | 
             
                      expect(result.commit).to eq "ABC123"
         | 
| 37 42 | 
             
                    end
         | 
    
        data/spec/collectors/sql_spec.rb
    CHANGED
    
    | @@ -13,6 +13,7 @@ module RspecProfiling | |
| 13 13 |  | 
| 14 14 | 
             
                    before do
         | 
| 15 15 | 
             
                      collector.insert({
         | 
| 16 | 
            +
                        branch: "master",
         | 
| 16 17 | 
             
                        commit: "ABC123",
         | 
| 17 18 | 
             
                        date: "Thu Dec 18 12:00:00 2012",
         | 
| 18 19 | 
             
                        file: "/some/file.rb",
         | 
| @@ -32,6 +33,10 @@ module RspecProfiling | |
| 32 33 | 
             
                      expect(collector.results.count).to eq 1
         | 
| 33 34 | 
             
                    end
         | 
| 34 35 |  | 
| 36 | 
            +
                    it "records the branch name" do
         | 
| 37 | 
            +
                      expect(result.branch).to eq "master"
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
             | 
| 35 40 | 
             
                    it "records the commit SHA" do
         | 
| 36 41 | 
             
                      expect(result.commit).to eq "ABC123"
         | 
| 37 42 | 
             
                    end
         | 
    
        data/spec/run_spec.rb
    CHANGED
    
    | @@ -19,14 +19,9 @@ module RspecProfiling | |
| 19 19 |  | 
| 20 20 | 
             
                describe "#run_example" do
         | 
| 21 21 | 
             
                  let(:collector) { CollectorDouble.new }
         | 
| 22 | 
            -
                  let(: | 
| 22 | 
            +
                  let(:vcs) { VcsDouble.new }
         | 
| 23 | 
            +
                  let(:run)       { described_class.new(collector, vcs) }
         | 
| 23 24 | 
             
                  let(:result)    { collector.results.first }
         | 
| 24 | 
            -
                  let(:commit) do
         | 
| 25 | 
            -
                    double({
         | 
| 26 | 
            -
                      commit: "abc123",
         | 
| 27 | 
            -
                      time: Time.new(2012, 12, 12)
         | 
| 28 | 
            -
                    })
         | 
| 29 | 
            -
                  end
         | 
| 30 25 | 
             
                  let(:example) do
         | 
| 31 26 | 
             
                    ExampleDouble.new({
         | 
| 32 27 | 
             
                      file_path: "/something_spec.rb",
         | 
| @@ -45,7 +40,6 @@ module RspecProfiling | |
| 45 40 | 
             
                  end
         | 
| 46 41 |  | 
| 47 42 | 
             
                  before do
         | 
| 48 | 
            -
                    stub_const("RspecProfiling::CurrentCommit", commit)
         | 
| 49 43 | 
             
                    stub_const("ActiveSupport::Notifications", Notifications.new)
         | 
| 50 44 | 
             
                    simulate_test_suite_run
         | 
| 51 45 | 
             
                  end
         | 
| @@ -54,6 +48,14 @@ module RspecProfiling | |
| 54 48 | 
             
                    expect(collector.count).to eq 1
         | 
| 55 49 | 
             
                  end
         | 
| 56 50 |  | 
| 51 | 
            +
                  it "records the branch name" do
         | 
| 52 | 
            +
                    expect(result.branch).to eq "master"
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  it "records the commit SHA" do
         | 
| 56 | 
            +
                    expect(result.commit).to eq "abc123"
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 57 59 | 
             
                  it "counts two queries" do
         | 
| 58 60 | 
             
                    expect(result.query_count).to eq 2
         | 
| 59 61 | 
             
                  end
         | 
| @@ -103,6 +105,20 @@ module RspecProfiling | |
| 103 105 | 
             
                  end
         | 
| 104 106 | 
             
                end
         | 
| 105 107 |  | 
| 108 | 
            +
                class VcsDouble
         | 
| 109 | 
            +
                  def branch
         | 
| 110 | 
            +
                    "master"
         | 
| 111 | 
            +
                  end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                  def sha
         | 
| 114 | 
            +
                    "abc123"
         | 
| 115 | 
            +
                  end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                  def time
         | 
| 118 | 
            +
                    0.1
         | 
| 119 | 
            +
                  end
         | 
| 120 | 
            +
                end
         | 
| 121 | 
            +
             | 
| 106 122 | 
             
                class ExampleDouble
         | 
| 107 123 | 
             
                  attr_reader :metadata
         | 
| 108 124 |  | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require "rspec_profiling/vcs/git"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module RspecProfiling
         | 
| 4 | 
            +
              describe VCS::Git do
         | 
| 5 | 
            +
                describe "#branch" do
         | 
| 6 | 
            +
                  it "calls Git to get the current branch" do
         | 
| 7 | 
            +
                    expect(subject).to receive(:`).with("git rev-parse --abbrev-ref HEAD").and_return("master")
         | 
| 8 | 
            +
                    expect(subject.branch).to eq "master"
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                describe "#sha" do
         | 
| 13 | 
            +
                  it "calls Git to get the current commit's SHA" do
         | 
| 14 | 
            +
                    expect(subject).to receive(:`).with("git rev-parse HEAD").and_return("abc123")
         | 
| 15 | 
            +
                    expect(subject.sha).to eq "abc123"
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                describe "#time" do
         | 
| 20 | 
            +
                  it "calls Git to get the current commit's datetime" do
         | 
| 21 | 
            +
                    expect(subject).to receive(:`).with("git rev-parse HEAD").and_return("abc123")
         | 
| 22 | 
            +
                    expect(subject).to receive(:`).with("git show -s --format=%ci abc123").and_return("2017-01-31")
         | 
| 23 | 
            +
                    expect(subject.time).to eq Time.parse("2017-01-31")
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            require "rspec_profiling/vcs/svn"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module RspecProfiling
         | 
| 4 | 
            +
              describe VCS::Svn do
         | 
| 5 | 
            +
                describe "#branch" do
         | 
| 6 | 
            +
                  it "calls Git to get the current branch" do
         | 
| 7 | 
            +
                    expect(subject.branch).to be_nil
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                describe "#sha" do
         | 
| 12 | 
            +
                  it "calls Git to get the current commit's SHA" do
         | 
| 13 | 
            +
                    expect(subject).to receive(:`).with("svn info -r 'HEAD' | grep \"Revision\" | cut -f2 -d' '").and_return("abc123")
         | 
| 14 | 
            +
                    expect(subject.sha).to eq "abc123"
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                describe "#time" do
         | 
| 19 | 
            +
                  it "calls Git to get the current commit's datetime" do
         | 
| 20 | 
            +
                    expect(subject).to receive(:`).with("svn info -r 'HEAD' | grep \"Last Changed Date\" | cut -f4,5,6 -d' '").and_return("2017-01-31")
         | 
| 21 | 
            +
                    expect(subject.time).to eq Time.parse("2017-01-31")
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rspec_profiling
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ben Eddy
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2017-02-09 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: sqlite3
         | 
| @@ -141,6 +141,8 @@ files: | |
| 141 141 | 
             
            - spec/collectors/psql_spec.rb
         | 
| 142 142 | 
             
            - spec/collectors/sql_spec.rb
         | 
| 143 143 | 
             
            - spec/run_spec.rb
         | 
| 144 | 
            +
            - spec/vcs/git_spec.rb
         | 
| 145 | 
            +
            - spec/vcs/svn_spec.rb
         | 
| 144 146 | 
             
            homepage: https://github.com/foraker/rspec_profiling
         | 
| 145 147 | 
             
            licenses:
         | 
| 146 148 | 
             
            - MIT
         | 
| @@ -161,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 161 163 | 
             
                  version: '0'
         | 
| 162 164 | 
             
            requirements: []
         | 
| 163 165 | 
             
            rubyforge_project: 
         | 
| 164 | 
            -
            rubygems_version: 2.4. | 
| 166 | 
            +
            rubygems_version: 2.4.8
         | 
| 165 167 | 
             
            signing_key: 
         | 
| 166 168 | 
             
            specification_version: 4
         | 
| 167 169 | 
             
            summary: Profile RSpec test suites
         | 
| @@ -169,3 +171,5 @@ test_files: | |
| 169 171 | 
             
            - spec/collectors/psql_spec.rb
         | 
| 170 172 | 
             
            - spec/collectors/sql_spec.rb
         | 
| 171 173 | 
             
            - spec/run_spec.rb
         | 
| 174 | 
            +
            - spec/vcs/git_spec.rb
         | 
| 175 | 
            +
            - spec/vcs/svn_spec.rb
         |