peeek 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +127 -0
- data/Rakefile +1 -0
- data/bin/peeek +16 -0
- data/lib/peeek.rb +147 -0
- data/lib/peeek/call.rb +134 -0
- data/lib/peeek/calls.rb +43 -0
- data/lib/peeek/hook.rb +188 -0
- data/lib/peeek/hook/instance.rb +51 -0
- data/lib/peeek/hook/linker.rb +29 -0
- data/lib/peeek/hook/singleton.rb +52 -0
- data/lib/peeek/hooks.rb +46 -0
- data/lib/peeek/supervisor.rb +120 -0
- data/lib/peeek/version.rb +3 -0
- data/peeek.gemspec +25 -0
- data/spec/peeek/call_spec.rb +226 -0
- data/spec/peeek/calls_spec.rb +86 -0
- data/spec/peeek/hook/instance_spec.rb +87 -0
- data/spec/peeek/hook/linker_spec.rb +15 -0
- data/spec/peeek/hook/singleton_spec.rb +82 -0
- data/spec/peeek/hook_spec.rb +380 -0
- data/spec/peeek/hooks_spec.rb +92 -0
- data/spec/peeek/supervisor_spec.rb +129 -0
- data/spec/peeek_spec.rb +335 -0
- data/spec/spec_helper.rb +78 -0
- metadata +125 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
def hook_stub(attrs = {})
|
2
|
+
stub('Peeek::Hook').tap do |s|
|
3
|
+
calls = Array.new(attrs[:calls] || 0)
|
4
|
+
defined = attrs[:defined] || true
|
5
|
+
linked = attrs[:linked] || false
|
6
|
+
|
7
|
+
s.stub!(:object => attrs[:object])
|
8
|
+
s.stub!(:method_name => attrs[:method_name])
|
9
|
+
s.stub!(:calls => calls)
|
10
|
+
s.stub!(:defined?).and_return { defined }
|
11
|
+
s.stub!(:linked?).and_return { linked }
|
12
|
+
|
13
|
+
s.stub!(:link).and_return do
|
14
|
+
linked = true
|
15
|
+
s
|
16
|
+
end
|
17
|
+
|
18
|
+
s.stub!(:unlink).and_return do
|
19
|
+
linked = false
|
20
|
+
s
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def instance_linker_stub(object, method_name)
|
26
|
+
original_method = object.instance_method(method_name)
|
27
|
+
linker = stub('Peeek::Hook::Linker', :link => original_method, :unlink => nil)
|
28
|
+
[linker, original_method]
|
29
|
+
end
|
30
|
+
|
31
|
+
def call_stub(result, attrs = {})
|
32
|
+
attrs = attrs.merge(
|
33
|
+
:returned? => result == :return_value,
|
34
|
+
:raised? => result == :exception
|
35
|
+
)
|
36
|
+
|
37
|
+
stub('Peeek::Call', attrs)
|
38
|
+
end
|
39
|
+
|
40
|
+
def one_or_more(array)
|
41
|
+
array.should_not be_empty
|
42
|
+
array
|
43
|
+
end
|
44
|
+
|
45
|
+
class SupervisionMatcher
|
46
|
+
def initialize(purpose)
|
47
|
+
@purpose = purpose
|
48
|
+
end
|
49
|
+
|
50
|
+
def matches?(object)
|
51
|
+
@object = object
|
52
|
+
callback_name = {:instance => :method_added, :singleton => :singleton_method_added}[@purpose]
|
53
|
+
method = object.method(callback_name)
|
54
|
+
require 'ruby18_source_location' unless method.respond_to?(:source_location)
|
55
|
+
source_location = method.source_location
|
56
|
+
!!(source_location && source_location[0].include?('lib/peeek/supervisor.rb'))
|
57
|
+
end
|
58
|
+
|
59
|
+
def description
|
60
|
+
"be supervised for #{@purpose} method"
|
61
|
+
end
|
62
|
+
|
63
|
+
def failure_message
|
64
|
+
"#{@object.inspect} should be supervised for #{@purpose} method, but not supervised"
|
65
|
+
end
|
66
|
+
|
67
|
+
def negative_failure_message
|
68
|
+
"#{@object.inspect} should not be supervised for #{@purpose} method, but supervised"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def be_supervised_for_instance
|
73
|
+
SupervisionMatcher.new(:instance)
|
74
|
+
end
|
75
|
+
|
76
|
+
def be_supervised_for_singleton
|
77
|
+
SupervisionMatcher.new(:singleton)
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: peeek
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takahiro Kondo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Peek at calls of a method
|
56
|
+
email:
|
57
|
+
- heartery@gmail.com
|
58
|
+
executables:
|
59
|
+
- peeek
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/peeek
|
69
|
+
- lib/peeek.rb
|
70
|
+
- lib/peeek/call.rb
|
71
|
+
- lib/peeek/calls.rb
|
72
|
+
- lib/peeek/hook.rb
|
73
|
+
- lib/peeek/hook/instance.rb
|
74
|
+
- lib/peeek/hook/linker.rb
|
75
|
+
- lib/peeek/hook/singleton.rb
|
76
|
+
- lib/peeek/hooks.rb
|
77
|
+
- lib/peeek/supervisor.rb
|
78
|
+
- lib/peeek/version.rb
|
79
|
+
- peeek.gemspec
|
80
|
+
- spec/peeek/call_spec.rb
|
81
|
+
- spec/peeek/calls_spec.rb
|
82
|
+
- spec/peeek/hook/instance_spec.rb
|
83
|
+
- spec/peeek/hook/linker_spec.rb
|
84
|
+
- spec/peeek/hook/singleton_spec.rb
|
85
|
+
- spec/peeek/hook_spec.rb
|
86
|
+
- spec/peeek/hooks_spec.rb
|
87
|
+
- spec/peeek/supervisor_spec.rb
|
88
|
+
- spec/peeek_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
homepage: https://github.com/takkkun/peeek
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.8.7
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.0.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Peek at calls of a method
|
114
|
+
test_files:
|
115
|
+
- spec/peeek/call_spec.rb
|
116
|
+
- spec/peeek/calls_spec.rb
|
117
|
+
- spec/peeek/hook/instance_spec.rb
|
118
|
+
- spec/peeek/hook/linker_spec.rb
|
119
|
+
- spec/peeek/hook/singleton_spec.rb
|
120
|
+
- spec/peeek/hook_spec.rb
|
121
|
+
- spec/peeek/hooks_spec.rb
|
122
|
+
- spec/peeek/supervisor_spec.rb
|
123
|
+
- spec/peeek_spec.rb
|
124
|
+
- spec/spec_helper.rb
|
125
|
+
has_rdoc:
|