Created
September 12, 2012 18:49
-
-
Save thinkerbot/3709029 to your computer and use it in GitHub Desktop.
Determine the context of RSpec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Determine the context of RSpec | |
# | |
# rspec context_spec.rb | |
# | |
# Example output: | |
# | |
# spec all each self | |
# a +++++ 2245888820 4 (2245891880) | |
# a. 2245888820 2245884460 (2245887200) | |
# a1 2245888820 2245884460 (2245887200) | |
# a. 2245888820 2245884460 (2245887200) | |
# a. 2245888820 2245876220 (2245878300) | |
# a2 2245888820 2245876220 (2245878300) | |
# a. 2245888820 2245876220 (2245878300) | |
# a. 2245888820 2245871360 (2245873220) | |
# a3 2245888820 2245871360 (2245873220) | |
# a. 2245888820 2245871360 (2245873220) | |
# b +++++ 2245869240 4 (2245869580) | |
# a. 2245869240 2245867760 (2245868840) | |
# b. 2245869240 2245867440 (2245868840) | |
# b1 2245869240 2245867440 (2245868840) | |
# b. 2245869240 2245867440 (2245868840) | |
# a. 2245869240 2245867440 (2245868840) | |
# b ----- 2245869240 4 (2245865720) | |
# c +++++ 2245864660 4 (2245865180) | |
# a. 2245864660 2245862720 (2245864180) | |
# c. 2245864660 2245862260 (2245864180) | |
# c1 2245864660 2245862260 (2245864180) | |
# c. 2245864660 2245862260 (2245864180) | |
# a. 2245864660 2245862260 (2245864180) | |
# a. 2245864660 2245857240 (2245860140) | |
# c. 2245864660 2245856560 (2245860140) | |
# c2 2245864660 2245856560 (2245860140) | |
# c. 2245864660 2245856560 (2245860140) | |
# a. 2245864660 2245856560 (2245860140) | |
# d +++++ 2245854400 4 (2245854800) | |
# a. 2245854400 2245851940 (2245854000) | |
# c. 2245854400 2245851420 (2245854000) | |
# d. 2245854400 2245850820 (2245854000) | |
# d1 2245854400 2245850820 (2245854000) | |
# d. 2245854400 2245850820 (2245854000) | |
# c. 2245854400 2245850820 (2245854000) | |
# a. 2245854400 2245850820 (2245854000) | |
# d ----- 2245854400 4 (2245842320) | |
# c ----- 2245864660 4 (2245841020) | |
# a ----- 2245888820 4 (2245838320) | |
def cmethod(name) | |
before :all do | |
@all_var = Object.new | |
imethod(name + " +++++") | |
end | |
after :all do | |
imethod(name + " -----") | |
end | |
before :each do | |
@each_var = Object.new | |
imethod(name + ".") | |
end | |
after :each do | |
imethod(name + ".") | |
end | |
end | |
def imethod(spec_name) | |
$stderr.puts "%-3s\t%10s\t%10s\t(%10s)" % [spec_name, @all_var.object_id, @each_var.object_id, self.object_id] | |
end | |
$stderr.puts "%-3s\t%10s\t%10s\t%12s" % %w{spec all each self} | |
describe "a" do | |
cmethod "a" | |
it("a1") { imethod "a1" } | |
describe "b" do | |
cmethod "b" | |
it("b1") { imethod "b1" } | |
end | |
it("a2") { imethod "a2" } | |
describe "c" do | |
cmethod "c" | |
it("c1") { imethod "c1" } | |
describe "d" do | |
cmethod "d" | |
it("d1") { imethod "d1" } | |
end | |
it("c2") { imethod "c2" } | |
end | |
it("a3") { imethod "a3" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you'll have to walk me through this one.... !!