code-spec 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/code-spec.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{code-spec}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
"lib/code_spec/matchers/match_lines.rb",
|
45
45
|
"lib/code_spec/matchers/multi/have_classes_modules.rb",
|
46
46
|
"lib/code_spec/matchers/multi/have_methods.rb",
|
47
|
+
"lib/code_spec/matchers/multi/have_subclasses.rb",
|
47
48
|
"spec/code-spec/fixtures/logfile.log",
|
48
49
|
"spec/code-spec/matchers/class_self_spec.rb",
|
49
50
|
"spec/code-spec/matchers/have_block_spec.rb",
|
@@ -61,6 +62,7 @@ Gem::Specification.new do |s|
|
|
61
62
|
"spec/code-spec/matchers/multi/have_classes_spec.rb",
|
62
63
|
"spec/code-spec/matchers/multi/have_methods_spec.rb",
|
63
64
|
"spec/code-spec/matchers/multi/have_modules_spec.rb",
|
65
|
+
"spec/code-spec/matchers/multi/have_subclasses_spec.rb",
|
64
66
|
"spec/spec_helper.rb"
|
65
67
|
]
|
66
68
|
s.homepage = %q{http://github.com/kristianmandrup/code-spec}
|
@@ -85,6 +87,7 @@ Gem::Specification.new do |s|
|
|
85
87
|
"spec/code-spec/matchers/multi/have_classes_spec.rb",
|
86
88
|
"spec/code-spec/matchers/multi/have_methods_spec.rb",
|
87
89
|
"spec/code-spec/matchers/multi/have_modules_spec.rb",
|
90
|
+
"spec/code-spec/matchers/multi/have_subclasses_spec.rb",
|
88
91
|
"spec/spec_helper.rb"
|
89
92
|
]
|
90
93
|
|
@@ -5,7 +5,7 @@ module RSpec::RubyContentMatchers
|
|
5
5
|
def initialize(*names)
|
6
6
|
postfix = last_arg_value({:postfix => ''}, names)
|
7
7
|
@names = names.to_strings
|
8
|
-
@postfix = postfix.to_s.camelize
|
8
|
+
@postfix = postfix ? postfix.to_s.camelize : nil
|
9
9
|
@type = :module
|
10
10
|
end
|
11
11
|
|
@@ -14,8 +14,13 @@ module RSpec::RubyContentMatchers
|
|
14
14
|
|
15
15
|
@content = content
|
16
16
|
|
17
|
+
return false if names.empty?
|
18
|
+
|
17
19
|
names.each do |name|
|
18
20
|
@name = name.camelize
|
21
|
+
@klass = name.camelize
|
22
|
+
@full_class = "#{@klass}#{@postfix}"
|
23
|
+
|
19
24
|
@end_option = name
|
20
25
|
match = is_match? content
|
21
26
|
return false if !match
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RSpec::RubyContentMatchers
|
2
|
+
class HaveSubClasses < HaveModules
|
3
|
+
attr_reader :superclass, :klass, :full_class
|
4
|
+
|
5
|
+
def initialize *names
|
6
|
+
superclass = last_arg_value({:superclass => ''}, names)
|
7
|
+
@superclass = superclass ? superclass.to_s.camelize : nil
|
8
|
+
super *names
|
9
|
+
@type = :class
|
10
|
+
end
|
11
|
+
|
12
|
+
def main_expr
|
13
|
+
if superclass
|
14
|
+
'class' + SPACES + "#{full_class}" + OPT_SPACES + '<' + OPT_SPACES + "#{superclass}" + ANY_GROUP
|
15
|
+
else
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message
|
21
|
+
super
|
22
|
+
"Expected there to be the subclass #{full_class} of #{superclass}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def negative_failure_message
|
26
|
+
super
|
27
|
+
"Did no expected there to be the subclass #{full_class} of #{superclass}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# can take :postfix and :superclass hash args
|
32
|
+
def have_subclasses *names
|
33
|
+
HaveSubClasses.new *names
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'classes matcher' do
|
4
|
+
context "no class" do
|
5
|
+
no_class = %q{
|
6
|
+
module X
|
7
|
+
hello
|
8
|
+
hi
|
9
|
+
end
|
10
|
+
}
|
11
|
+
|
12
|
+
it "should not have class X" do
|
13
|
+
no_class.should_not have_subclasses :x
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "content with class X" do
|
18
|
+
class_x = %q{
|
19
|
+
class X
|
20
|
+
def hello
|
21
|
+
blip
|
22
|
+
end
|
23
|
+
end
|
24
|
+
}
|
25
|
+
it "should not have subclass X of Y" do
|
26
|
+
class_x.should_not have_subclasses :x, :superclass => :y
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "content with subclass X of Y" do
|
31
|
+
class_x = %q{
|
32
|
+
class X < Y
|
33
|
+
def hello
|
34
|
+
blip
|
35
|
+
end
|
36
|
+
end
|
37
|
+
}
|
38
|
+
it "should have subclass X of Y" do
|
39
|
+
class_x.should have_subclasses :x, :superclass => :y
|
40
|
+
class_x.should_not have_subclasses :y, :superclass => :x
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "content with subclasses X and Y of Z" do
|
45
|
+
classs_x_y = %q{
|
46
|
+
class X < Z
|
47
|
+
def hello
|
48
|
+
blip
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Y < Z
|
53
|
+
def hello
|
54
|
+
blip
|
55
|
+
end
|
56
|
+
end
|
57
|
+
}
|
58
|
+
it "should have classs X and Y of Z" do
|
59
|
+
classs_x_y.should have_subclasses :x, :y, :superclass => :z
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 5
|
9
|
+
version: 0.2.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/code_spec/matchers/match_lines.rb
|
117
117
|
- lib/code_spec/matchers/multi/have_classes_modules.rb
|
118
118
|
- lib/code_spec/matchers/multi/have_methods.rb
|
119
|
+
- lib/code_spec/matchers/multi/have_subclasses.rb
|
119
120
|
- spec/code-spec/fixtures/logfile.log
|
120
121
|
- spec/code-spec/matchers/class_self_spec.rb
|
121
122
|
- spec/code-spec/matchers/have_block_spec.rb
|
@@ -133,6 +134,7 @@ files:
|
|
133
134
|
- spec/code-spec/matchers/multi/have_classes_spec.rb
|
134
135
|
- spec/code-spec/matchers/multi/have_methods_spec.rb
|
135
136
|
- spec/code-spec/matchers/multi/have_modules_spec.rb
|
137
|
+
- spec/code-spec/matchers/multi/have_subclasses_spec.rb
|
136
138
|
- spec/spec_helper.rb
|
137
139
|
has_rdoc: true
|
138
140
|
homepage: http://github.com/kristianmandrup/code-spec
|
@@ -183,4 +185,5 @@ test_files:
|
|
183
185
|
- spec/code-spec/matchers/multi/have_classes_spec.rb
|
184
186
|
- spec/code-spec/matchers/multi/have_methods_spec.rb
|
185
187
|
- spec/code-spec/matchers/multi/have_modules_spec.rb
|
188
|
+
- spec/code-spec/matchers/multi/have_subclasses_spec.rb
|
186
189
|
- spec/spec_helper.rb
|