peeek 1.0.1 → 1.0.2

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.
@@ -0,0 +1,107 @@
1
+ require 'peeek/hook/specifier'
2
+
3
+ describe Peeek::Hook::Specifier do
4
+ let(:sample_hook_specifier) { described_class.parse('String#%') }
5
+
6
+ it 'identifies as key in a hash' do
7
+ hash = {sample_hook_specifier => :hook_spec}
8
+ hash.should be_key(described_class.parse('String#%'))
9
+ hash.should_not be_key(described_class.parse('String#index'))
10
+ hash.should_not be_key(described_class.parse('Regexp#%'))
11
+ hash.should_not be_key(described_class.parse('String.%'))
12
+ end
13
+
14
+ describe '.parse' do
15
+ context 'when given instance method name' do
16
+ subject { described_class.parse('String#%') }
17
+
18
+ it { should == described_class.new('String', '#', :%) }
19
+ end
20
+
21
+ context 'when given singleton method name' do
22
+ subject { described_class.parse('Regexp.quote') }
23
+
24
+ it { should == described_class.new('Regexp', '.', :quote) }
25
+ end
26
+
27
+ context 'when given singleton method name' do
28
+ subject { described_class.parse('Regexp.#quote') }
29
+
30
+ it { should == described_class.new('Regexp', '.', :quote) }
31
+ end
32
+
33
+ context 'when given singleton method name' do
34
+ subject { described_class.parse('Regexp::quote') }
35
+
36
+ it { should == described_class.new('Regexp', '.', :quote) }
37
+ end
38
+
39
+ context 'when given nested object name' do
40
+ subject { described_class.parse('Net::HTTP#request') }
41
+
42
+ it { should == described_class.new('Net::HTTP', '#', :request) }
43
+ end
44
+
45
+ context "when a method name isn't specified" do
46
+ subject { described_class.parse('String') }
47
+
48
+ it do
49
+ expect { subject }.to raise_error(ArgumentError, %(method name that is target of hook isn't specified in "String"))
50
+ end
51
+ end
52
+
53
+ context 'when an object name is empty' do
54
+ subject { described_class.parse('#%') }
55
+
56
+ it do
57
+ expect { subject }.to raise_error(ArgumentError, %(object name should not be empty for "#%"))
58
+ end
59
+ end
60
+
61
+ context 'when a method name is empty' do
62
+ subject { described_class.parse('String#') }
63
+
64
+ it do
65
+ expect { subject }.to raise_error(ArgumentError, %(method name should not be empty for "String#"))
66
+ end
67
+ end
68
+ end
69
+
70
+ describe '#initialize' do
71
+ context 'when invalid method prefix is specified' do
72
+ subject { described_class.new('String', '!', :%) }
73
+
74
+ it do
75
+ expect { subject }.to raise_error(ArgumentError, 'invalid method prefix, "#", ".", ".#" or "::" are valid')
76
+ end
77
+ end
78
+ end
79
+
80
+ describe '#method_specifier' do
81
+ subject { sample_hook_specifier.method_specifier }
82
+
83
+ it { should == '#%' }
84
+ end
85
+
86
+ describe '#to_s' do
87
+ subject { sample_hook_specifier.to_s }
88
+
89
+ it { should == 'String#%' }
90
+ end
91
+
92
+ describe '#inspect' do
93
+ subject { sample_hook_specifier.inspect }
94
+
95
+ it { should == "#<#{described_class} String#%>" }
96
+ end
97
+
98
+ describe '#==' do
99
+ subject { sample_hook_specifier }
100
+
101
+ it { should == described_class.parse('String#%') }
102
+ it { should_not == described_class.parse('String#index') }
103
+ it { should_not == described_class.parse('Regexp#%') }
104
+ it { should_not == described_class.parse('String.%') }
105
+ it { should_not == 'String#%' }
106
+ end
107
+ end
@@ -181,7 +181,7 @@ describe Peeek, '#hook' do
181
181
  @peeek.release
182
182
  end
183
183
 
184
- it "calls #{described_class}::Hook.create with the object, the method specification and the block" do
184
+ it "calls #{described_class}::Hook.create with the object, the method specifier and the block" do
185
185
  block = lambda { }
186
186
  Peeek::Hook.should_receive(:create).with($stdout, :write, &block).and_return(hook_stub)
187
187
  Peeek::Hook.should_receive(:create).with(Numeric, :abs, &block).and_return(hook_stub)
metadata CHANGED
@@ -1,55 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peeek
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Kondo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-03 00:00:00.000000000 Z
11
+ date: 2013-04-08 00:00:00.000000000 Z
12
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - ! '>='
17
+ - - '>='
32
18
  - !ruby/object:Gem::Version
33
19
  version: '0'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - ! '>='
24
+ - - '>='
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rspec
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ! '>='
31
+ - - '>='
46
32
  - !ruby/object:Gem::Version
47
33
  version: '0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ! '>='
38
+ - - '>='
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
41
  description: Peek at calls of a method
@@ -61,6 +47,7 @@ extensions: []
61
47
  extra_rdoc_files: []
62
48
  files:
63
49
  - .gitignore
50
+ - .travis.yml
64
51
  - Gemfile
65
52
  - LICENSE.txt
66
53
  - README.md
@@ -69,19 +56,26 @@ files:
69
56
  - lib/peeek.rb
70
57
  - lib/peeek/call.rb
71
58
  - lib/peeek/calls.rb
59
+ - lib/peeek/cli.rb
60
+ - lib/peeek/cli/options.rb
72
61
  - lib/peeek/hook.rb
73
62
  - lib/peeek/hook/instance.rb
74
63
  - lib/peeek/hook/linker.rb
75
64
  - lib/peeek/hook/singleton.rb
65
+ - lib/peeek/hook/specifier.rb
76
66
  - lib/peeek/hooks.rb
77
67
  - lib/peeek/supervisor.rb
78
68
  - lib/peeek/version.rb
79
69
  - peeek.gemspec
80
70
  - spec/peeek/call_spec.rb
81
71
  - spec/peeek/calls_spec.rb
72
+ - spec/peeek/cli/options_spec.rb
73
+ - spec/peeek/cli_sample.rb
74
+ - spec/peeek/cli_spec.rb
82
75
  - spec/peeek/hook/instance_spec.rb
83
76
  - spec/peeek/hook/linker_spec.rb
84
77
  - spec/peeek/hook/singleton_spec.rb
78
+ - spec/peeek/hook/specifier_spec.rb
85
79
  - spec/peeek/hook_spec.rb
86
80
  - spec/peeek/hooks_spec.rb
87
81
  - spec/peeek/supervisor_spec.rb
@@ -97,29 +91,32 @@ require_paths:
97
91
  - lib
98
92
  required_ruby_version: !ruby/object:Gem::Requirement
99
93
  requirements:
100
- - - ! '>='
94
+ - - '>='
101
95
  - !ruby/object:Gem::Version
102
96
  version: 1.8.7
103
97
  required_rubygems_version: !ruby/object:Gem::Requirement
104
98
  requirements:
105
- - - ! '>='
99
+ - - '>='
106
100
  - !ruby/object:Gem::Version
107
101
  version: '0'
108
102
  requirements: []
109
103
  rubyforge_project:
110
- rubygems_version: 2.0.2
104
+ rubygems_version: 2.0.0
111
105
  signing_key:
112
106
  specification_version: 4
113
107
  summary: Peek at calls of a method
114
108
  test_files:
115
109
  - spec/peeek/call_spec.rb
116
110
  - spec/peeek/calls_spec.rb
111
+ - spec/peeek/cli/options_spec.rb
112
+ - spec/peeek/cli_sample.rb
113
+ - spec/peeek/cli_spec.rb
117
114
  - spec/peeek/hook/instance_spec.rb
118
115
  - spec/peeek/hook/linker_spec.rb
119
116
  - spec/peeek/hook/singleton_spec.rb
117
+ - spec/peeek/hook/specifier_spec.rb
120
118
  - spec/peeek/hook_spec.rb
121
119
  - spec/peeek/hooks_spec.rb
122
120
  - spec/peeek/supervisor_spec.rb
123
121
  - spec/peeek_spec.rb
124
122
  - spec/spec_helper.rb
125
- has_rdoc: