0.0
No commit activity in last 3 years
No release in over 3 years
Mark the timestamp of RSpec example starts/ends, and log other stuff for profiling
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
>= 0
 Project Readme

SpecMarker - RSpec formatter that useful for profiling

Installation

Add this line to your application's Gemfile:

gem 'spec_marker'

And then execute:

$ bundle

Or install it yourself as:

$ gem install spec_marker

Usage

Basic

# to STDOUT
$ rspec --format SpecMarker ...

# to a File
$ rspec --format SpecMarker --out spec_marker.log ...
$ cat spec_marker.log

Log File

Log file is like this:

[suite:start][1355121779.69578] {"tag":"suite","at":1355121779.6957781,"meta":{},"kind":"start"}
[example_group:start][1355121779.69596] {"tag":"example_group","at":1355121779.695959,"meta":{"description":"foo"},"kind":"start"}
[example:start][1355121779.69616] {"tag":"example","at":1355121779.6961558,"meta":{"location":"./a_spec.rb:2","description":"hello"},"kind":"start"}
[example:end][1355121781.69764 (2.00148)] {"tag":"example","at":1355121781.6976361,"meta":{"location":"./a_spec.rb:2","description":"hello","result":"passed"},"kind":"end","elapsed":2.0014803409576416}
...

Each line is:

[TAG][TIMESTAMP (ELAPSED TIME)] JSON

Marking

describe "foo" do
  it "hello" do
    sleep 2
  end

  context "bar" do
    it "hello" do
      # Use SpecMarker.mark to mark the time on the log.
      SpecMarker.mark :foo
      #=> [foo][1355121541.62746] {"tag":"foo","at":1355121541.627462,"meta":{},"kind":null}

      # You can pass additional data to record in JSON.
      SpecMarker.mark :foo, meta: :data
      #=> [foo][1355121541.62750] {"tag":"foo","at":1355121541.627502,"meta":{"meta":"data"},"kind":null}
    end

    it "hello" do
      # You can record an elapsed time of any parts.
      SpecMarker.mark :bar, :start
      #=> [bar:start][1355121781.69903] {"tag":"bar","at":1355121781.699029,"meta":{},"kind":"start"}
      sleep 1

      # Then call with :end to record elapsed time.
      SpecMarker.mark :bar, :end
      #=> [bar:end][1355121782.70022 (1.00119)] {"tag":"bar","at":1355121782.700217,"meta":{},"kind":"end","elapsed":1.001188039779663}
      sleep 1
    end

    it "hello" do
      # You can also pass the metadata.
      SpecMarker.mark :bar, {meta: :data}, :start
      SpecMarker.mark :bar, {meta: :data}, :end
    end
  end
end