testme 0.5.45 → 0.5.85
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.
- data/README.md +10 -0
- data/lib/double.rb +11 -0
- data/lib/formatter.rb +23 -6
- data/lib/logic.rb +34 -15
- data/lib/testme.rb +4 -1
- data/spec/testme_spec.rb +1 -1
- data/test/double.test.rb +17 -0
- data/test/formatter.test.rb +2 -1
- data/test/testme.test.rb +3 -0
- metadata +4 -8
data/README.md
CHANGED
@@ -308,6 +308,15 @@ default test folder: `/test/**/*`
|
|
308
308
|
|
309
309
|
before { topic.do_some_factory_stuff }
|
310
310
|
|
311
|
+
***
|
312
|
+
|
313
|
+
#### Describing or Commenting
|
314
|
+
Use `-` followed by a String
|
315
|
+
|
316
|
+
-'this is a test description'
|
317
|
+
|
318
|
+
***
|
319
|
+
|
311
320
|
## "This is too easy! How can I make this more challenging?"
|
312
321
|
|
313
322
|
There is something about you that troubles me. Your manner is strange for a lonely code warrior.
|
@@ -321,6 +330,7 @@ When these features are completed
|
|
321
330
|
- Test more complex method stubbing
|
322
331
|
- Console color schemes
|
323
332
|
- HTML reporting
|
333
|
+
- JSON/XML logging
|
324
334
|
|
325
335
|
## Design Decisions
|
326
336
|
|
data/lib/double.rb
CHANGED
data/lib/formatter.rb
CHANGED
@@ -11,6 +11,10 @@ module TestMe
|
|
11
11
|
return Formatter::Console.new
|
12
12
|
when :html
|
13
13
|
return Formatter::HTML.new
|
14
|
+
when :json
|
15
|
+
return false
|
16
|
+
when :xml
|
17
|
+
return false
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
@@ -34,7 +38,7 @@ module TestMe
|
|
34
38
|
#TODO color_scheme
|
35
39
|
|
36
40
|
def test topic
|
37
|
-
log "\n test ".bright + topic.
|
41
|
+
log "\n test ".bright + topic.to_s.bright.color(250, 37, 115)
|
38
42
|
end
|
39
43
|
|
40
44
|
def given desc=nil, stubs=nil, &block
|
@@ -48,16 +52,25 @@ module TestMe
|
|
48
52
|
def is? method, actual, expected
|
49
53
|
success = actual == expected
|
50
54
|
|
51
|
-
|
55
|
+
if method.class == Proc
|
56
|
+
log ' is ' + block_to_string(&method) + '? ' + (success ? 'YES'.bright.green : "NO, it was '#{actual}'".bright.red) + "\n\n"
|
57
|
+
else
|
58
|
+
log ' is ' + method.to_s + ', ' + expected.to_s.yellow + '? ' + (success ? 'YES'.bright.green : "NO, it was '#{actual}'".bright.red) + "\n\n"
|
59
|
+
end
|
52
60
|
end
|
53
61
|
|
54
62
|
def compile
|
55
63
|
#do nothing
|
56
64
|
end
|
57
65
|
|
66
|
+
def describe msg
|
67
|
+
log ' ' + msg.bright.yellow
|
68
|
+
end
|
69
|
+
|
58
70
|
private
|
59
71
|
def block_to_string &block
|
60
|
-
|
72
|
+
loc = block.source_location
|
73
|
+
`head -#{loc[1]} #{loc[0]} | tail -1 | grep -o {.*}`[2..-4]
|
61
74
|
end
|
62
75
|
|
63
76
|
def log msg
|
@@ -68,7 +81,7 @@ module TestMe
|
|
68
81
|
str = ""
|
69
82
|
|
70
83
|
if desc.class == String || desc.class == Symbol
|
71
|
-
str += ":#{desc}: ".
|
84
|
+
str += ":#{desc}: ".bright.cyan
|
72
85
|
end
|
73
86
|
|
74
87
|
if desc.class == Hash
|
@@ -76,7 +89,7 @@ module TestMe
|
|
76
89
|
end
|
77
90
|
|
78
91
|
if stubs
|
79
|
-
str += stubs.map{|k,v| (k.to_s + ': ' + v.to_s)
|
92
|
+
str += stubs.map{|k,v| (k.to_s + ': ' + v.to_s)}.join(', ') + ' '
|
80
93
|
end
|
81
94
|
|
82
95
|
if block
|
@@ -90,7 +103,7 @@ module TestMe
|
|
90
103
|
|
91
104
|
class Text < Console
|
92
105
|
def test topic
|
93
|
-
log "test " + topic.
|
106
|
+
log "test " + topic.to_s
|
94
107
|
end
|
95
108
|
|
96
109
|
def given desc=nil, stubs=nil, &block
|
@@ -111,6 +124,10 @@ module TestMe
|
|
111
124
|
#do nothing
|
112
125
|
end
|
113
126
|
|
127
|
+
def describe msg
|
128
|
+
log msg
|
129
|
+
end
|
130
|
+
|
114
131
|
private
|
115
132
|
def block_to_string &block
|
116
133
|
"(block)"
|
data/lib/logic.rb
CHANGED
@@ -3,27 +3,24 @@ module TestMe
|
|
3
3
|
@topic
|
4
4
|
end
|
5
5
|
|
6
|
-
def test topic
|
6
|
+
def test topic, *args
|
7
7
|
@topic = nil
|
8
8
|
@before = nil
|
9
9
|
@contexts = {}
|
10
|
+
@args = args
|
10
11
|
|
11
12
|
@@formatter = Formatter::create(testme.format)
|
12
|
-
@@formatter.test topic
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
if topic.instance_of? Class
|
23
|
-
@topic = Double.new(topic.new)
|
14
|
+
case topic.class
|
15
|
+
when String || Symbol
|
16
|
+
@topic_class = Object
|
17
|
+
@@formatter.test topic
|
18
|
+
else
|
19
|
+
@topic_class = topic
|
20
|
+
@@formatter.test @topic_class
|
24
21
|
end
|
25
22
|
|
26
|
-
|
23
|
+
reset_topic
|
27
24
|
end
|
28
25
|
|
29
26
|
def given desc=nil, stubs=nil, &block
|
@@ -31,7 +28,7 @@ module TestMe
|
|
31
28
|
|
32
29
|
@@formatter.given desc, stubs, &block
|
33
30
|
|
34
|
-
|
31
|
+
reset_topic
|
35
32
|
|
36
33
|
if desc.class == String || desc.class == Symbol
|
37
34
|
if stubs == nil and block == nil
|
@@ -80,7 +77,7 @@ module TestMe
|
|
80
77
|
expected = args[1]
|
81
78
|
actual = topic.send(args[0], *params)
|
82
79
|
|
83
|
-
method = args[0].to_s + (params ? '(' + params.join(',') + ')' : '')
|
80
|
+
method = args[0].to_s + ( params.size > 0 ? '(' + params.join(',') + ')' : '')
|
84
81
|
end
|
85
82
|
|
86
83
|
expected = true if expected.nil?
|
@@ -96,11 +93,27 @@ module TestMe
|
|
96
93
|
@before = block
|
97
94
|
end
|
98
95
|
|
96
|
+
def self.formatter
|
97
|
+
return @@formatter
|
98
|
+
end
|
99
|
+
|
99
100
|
private
|
100
101
|
class Context
|
101
102
|
attr_accessor :name, :block, :stubs
|
102
103
|
end
|
103
104
|
|
105
|
+
def reset_topic
|
106
|
+
if @topic_class.instance_of? Module
|
107
|
+
o = Object.new
|
108
|
+
o.extend @topic_class
|
109
|
+
@topic = Double.new(o)
|
110
|
+
end
|
111
|
+
|
112
|
+
if @topic_class.instance_of? Class
|
113
|
+
@topic = Double.new(@topic_class.new(*@args))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
104
117
|
def class_from_string(str)
|
105
118
|
str.split('::').inject(Object) do |mod, class_name|
|
106
119
|
mod.const_get(class_name)
|
@@ -133,3 +146,9 @@ private
|
|
133
146
|
end
|
134
147
|
end
|
135
148
|
end
|
149
|
+
|
150
|
+
class String
|
151
|
+
def -@
|
152
|
+
TestMe::formatter.describe self
|
153
|
+
end
|
154
|
+
end
|
data/lib/testme.rb
CHANGED
@@ -19,7 +19,7 @@ module TestMe
|
|
19
19
|
|
20
20
|
# Set the topic of the test
|
21
21
|
# ` test Player `
|
22
|
-
def test topic; end
|
22
|
+
def test topic, *args; end
|
23
23
|
# ---------------------------------------------------------------- #
|
24
24
|
|
25
25
|
# Provide a context
|
@@ -50,6 +50,9 @@ module TestMe
|
|
50
50
|
def before █ end
|
51
51
|
# ---------------------------------------------------------------- #
|
52
52
|
|
53
|
+
# Describe the context (if necessary)
|
54
|
+
# ` -'create the context'`
|
55
|
+
|
53
56
|
# ---------------------------------------------------------------- #
|
54
57
|
# Config Module
|
55
58
|
# ---------------------------------------------------------------- #
|
data/spec/testme_spec.rb
CHANGED
data/test/double.test.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class TestObject
|
2
|
+
def hello; return 'hello'; end
|
3
|
+
def world; return 'world'; end
|
4
|
+
end
|
5
|
+
|
6
|
+
test TestMe::Double
|
7
|
+
given test: 5
|
8
|
+
is? :test, 5
|
9
|
+
|
10
|
+
#Stub chain
|
11
|
+
given { topic.test.test2 = 5 }
|
12
|
+
is? { topic.test.test2 == 5 }
|
13
|
+
|
14
|
+
#Stub chain over object
|
15
|
+
given test: TestMe::Double.new(TestObject.new)
|
16
|
+
also { topic.test.test2 = 5 }
|
17
|
+
is? { topic.test.test2 == 5 }
|
data/test/formatter.test.rb
CHANGED
@@ -7,6 +7,7 @@ module TestMe::Formatter
|
|
7
7
|
end
|
8
8
|
|
9
9
|
test TestMe::Formatter::Text
|
10
|
-
|
10
|
+
is? :test[TestMe::Formatter::Text], 'test TestMe::Formatter::Text'
|
11
11
|
is? :given[{description: "I format things"}], 'given description: I format things'
|
12
12
|
is? :also[{description: "I format things"}], 'also description: I format things'
|
13
|
+
is? :describe['testme'], 'testme'
|
data/test/testme.test.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.85
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -86,7 +86,9 @@ files:
|
|
86
86
|
- spec/double_spec.rb
|
87
87
|
- spec/spec_helper.rb
|
88
88
|
- spec/testme_spec.rb
|
89
|
+
- test/double.test.rb
|
89
90
|
- test/formatter.test.rb
|
91
|
+
- test/testme.test.rb
|
90
92
|
- testme.gemspec
|
91
93
|
homepage: http://github.com/danielshuey/testme
|
92
94
|
licenses: []
|
@@ -100,18 +102,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
102
|
- - ! '>='
|
101
103
|
- !ruby/object:Gem::Version
|
102
104
|
version: '0'
|
103
|
-
segments:
|
104
|
-
- 0
|
105
|
-
hash: -955234925
|
106
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
106
|
none: false
|
108
107
|
requirements:
|
109
108
|
- - ! '>='
|
110
109
|
- !ruby/object:Gem::Version
|
111
110
|
version: '0'
|
112
|
-
segments:
|
113
|
-
- 0
|
114
|
-
hash: -955234925
|
115
111
|
requirements: []
|
116
112
|
rubyforge_project:
|
117
113
|
rubygems_version: 1.8.24
|