rspec-describe-method 0.0.1
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 +7 -0
- data/Gemfile +3 -0
- data/Guardfile +12 -0
- data/MIT-LICENSE +20 -0
- data/README.md +74 -0
- data/lib/rspec/describe_method.rb +8 -0
- data/lib/rspec/describe_method/class_extensions.rb +30 -0
- data/lib/rspec/describe_method/version.rb +13 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c980b97a7478ddfcb65daa147868a55c727f94ac
|
4
|
+
data.tar.gz: 86c7873513701191f6cf31d60de61936ebd465c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 65255b454f71f07e1dbbd9247fcafe65ea5aee696007cbfa1eb3833ed8c885941b4719f4b6db87241122c278477bb4a2b6b18c724a8b27573a544b8ead1d09bf
|
7
|
+
data.tar.gz: f62d7c8733b0ffe12eb0a3969371e21a83c894ca4c1d34f125c680473c799492b3b9a0ca4d82bd2da4a47819313184382040de5e6c8b85ad9777146c73459465
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011, 2012, 2013 by Brett Richardson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
[](https://travis-ci.org/brett-richardson/rspec-describe-method)
|
2
|
+
|
3
|
+
Using Rspec DescribeMethod
|
4
|
+
==========================
|
5
|
+
|
6
|
+
Using Rspec DescribeMethod is super simple.
|
7
|
+
|
8
|
+
|
9
|
+
In your Gemfile:
|
10
|
+
```ruby
|
11
|
+
group :development, :testing do
|
12
|
+
gem 'rspec-describe-method'
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
|
17
|
+
In your spec_helper.rb:
|
18
|
+
```ruby
|
19
|
+
require 'rspec/describe-method'
|
20
|
+
```
|
21
|
+
|
22
|
+
And your specs can look like this:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
describe String do
|
26
|
+
describe_method '.new' do
|
27
|
+
it{ should be_a String }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe_method '#concat', 'argument' do
|
31
|
+
it{ should match /argument/i }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with an instance' do
|
35
|
+
subject{ String.new 'test' }
|
36
|
+
|
37
|
+
describe_method '#upcase' do
|
38
|
+
it{ should eq 'TEST' }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
Describe a method call on the current test `subject` in your specs with 'describe_method', and a `#` for instance methods and a `.` for class methods.
|
46
|
+
|
47
|
+
Instances will automatically delagate to their class, and classes will automatically create an instance of themselves.
|
48
|
+
|
49
|
+
|
50
|
+
Alias method: when_calling
|
51
|
+
--------------------------
|
52
|
+
|
53
|
+
The alias method `when_calling` is provided which makes specs more human-readable, especially when calls are nested within eachother:
|
54
|
+
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
describe String do
|
58
|
+
subject{ String.new 'test' }
|
59
|
+
|
60
|
+
when_calling '#upcase' {
|
61
|
+
it{ should eq 'TEST' }
|
62
|
+
|
63
|
+
when_calling '#+', 'ING' {
|
64
|
+
it{ should eq 'TESTING' }
|
65
|
+
}
|
66
|
+
}
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
|
71
|
+
NOTE
|
72
|
+
----
|
73
|
+
When the subject is a Class, and you call an instance method `describe_method "#something"`
|
74
|
+
the class will call `.new` on itself with __NO ARGUMENTS__, you may not want this behavior.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RSpec
|
2
|
+
module DescribeMethod
|
3
|
+
module ClassExtensions
|
4
|
+
|
5
|
+
def describe_method( method, *args, &block )
|
6
|
+
throw ArgumentError.new 'Supplied method must be a String' unless method.kind_of? String
|
7
|
+
throw ArgumentError.new 'No block supplied to .describe_method' unless block.kind_of? Proc
|
8
|
+
|
9
|
+
describe "when calling #{method}" do
|
10
|
+
subject do
|
11
|
+
old = super()
|
12
|
+
|
13
|
+
case method[0]
|
14
|
+
when '#' # Instance method ---
|
15
|
+
if old.kind_of? Class then old.new else old end
|
16
|
+
when '.' # Class method ---
|
17
|
+
if old.kind_of? Class then old else old.class end
|
18
|
+
else # Method type not recognized ---
|
19
|
+
throw ArgumentError.new 'describe_method expects method name to begin with # or .'
|
20
|
+
end.send method[1..-1], *args
|
21
|
+
end
|
22
|
+
|
23
|
+
instance_eval &block
|
24
|
+
end
|
25
|
+
end
|
26
|
+
alias_method :when_calling, :describe_method
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-describe-method
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brett Richardson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
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: rake
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: growl
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: 'Adds a #describe_method method for use within RSpecs, which set the
|
126
|
+
test subject to the defined method'
|
127
|
+
email:
|
128
|
+
- Brett.Richardson.NZ@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- lib/rspec/describe_method/class_extensions.rb
|
134
|
+
- lib/rspec/describe_method/version.rb
|
135
|
+
- lib/rspec/describe_method.rb
|
136
|
+
- Gemfile
|
137
|
+
- Guardfile
|
138
|
+
- MIT-LICENSE
|
139
|
+
- README.md
|
140
|
+
homepage: http://www.dablweb.com
|
141
|
+
licenses: []
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.0.3
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: Tersely describe methods on Ruby objects in your RSpecs
|
163
|
+
test_files: []
|