pretentious 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -5
- data/example.rb +35 -32
- data/lib/pretentious/minitest_generator.rb +57 -30
- data/lib/pretentious/rspec_generator.rb +1 -0
- data/lib/pretentious/version.rb +1 -1
- data/pretentious.gemspec +3 -2
- data/run_test.sh +1 -1
- data/spec/fibonacci_spec.rb +1 -0
- data/spec/m_d5_spec.rb +1 -0
- data/spec/minitest_generator_spec.rb +1 -1
- data/spec/prententious_spec.rb +1 -1
- data/spec/test_class_for_auto_stub_spec.rb +2 -1
- data/spec/test_class_for_mocks_spec.rb +4 -4
- data/test/minitest_helper.rb +3 -0
- data/test/test_meme.rb +5 -3
- data/test/test_test_class1.rb +67 -0
- data/test/test_test_class2.rb +24 -0
- data/test/test_test_class3.rb +49 -0
- data/test/test_test_class4.rb +23 -0
- data/test/test_test_class_for_mocks.rb +54 -0
- metadata +35 -11
- data/test/test_helper.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0dde9fafa6d13f604e06b79bc3d7714698829c4
|
4
|
+
data.tar.gz: 7052900a02666fa5ea8a85997073a75bcee40cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4549b4ab18d247874a2ae1d9b3f9eaba6ee3201f63a923a3ad4616bc3f46dc15515e4c703c999ffddfed99e5cb967bb51e535cdf2b1812a32e5d22a3afc638a1
|
7
|
+
data.tar.gz: b7cab761d44df23c0a08e256d24f8538ceb7a14372db3cafb6474f0feafafc9fa3509d0a6d3a986c913ef30bf67c718418cccb2b52642103e80fd2d39c446fd5
|
data/README.md
CHANGED
@@ -7,10 +7,10 @@ here is a gem to deal with that. Now you CAN write your code first and then GENE
|
|
7
7
|
right! To repeat, this gem allows you to write your code first and then automatically generate tests using the code
|
8
8
|
you've written in a straightfoward manner!
|
9
9
|
|
10
|
-
On a serious note, this gem allows you to generate tests template
|
11
|
-
for various frameworks. It is also useful for "recording"
|
12
|
-
to prepare for refactoring. As a bonus it also exposes
|
13
|
-
any object, to obtain a ruby code on how it was created.
|
10
|
+
On a serious note, this gem allows you to generate tests template used for "characterization tests"
|
11
|
+
much better than those generated by default for various frameworks. It is also useful for "recording"
|
12
|
+
current behavior of existing components in order to prepare for refactoring. As a bonus it also exposes
|
13
|
+
an Object Deconstructor which allows you, given any object, to obtain a ruby code on how it was created.
|
14
14
|
|
15
15
|
|
16
16
|
## Table of Contents
|
@@ -363,7 +363,7 @@ should generate the following in rspec
|
|
363
363
|
Too lazy to generate rspec-mocks stubs? Let the Pretentious gem do it for you.
|
364
364
|
|
365
365
|
Simply call the _stub method on a class and pass the classes you want to generate
|
366
|
-
stubs for when passing calling spec_for (see below):
|
366
|
+
stubs for when passing calling spec_for or minitest_for (see below):
|
367
367
|
|
368
368
|
```ruby
|
369
369
|
Pretentious.spec_for(TestClass._stub(ClassUsedByTestClass)) do
|
@@ -375,6 +375,7 @@ end
|
|
375
375
|
|
376
376
|
should auto generate the stub like this:
|
377
377
|
|
378
|
+
|
378
379
|
```ruby
|
379
380
|
it 'should pass current expectations' do
|
380
381
|
|
@@ -388,6 +389,30 @@ it 'should pass current expectations' do
|
|
388
389
|
end
|
389
390
|
```
|
390
391
|
|
392
|
+
For minitest it returns something like:
|
393
|
+
|
394
|
+
```ruby
|
395
|
+
class Scenario2 < TestTestClassForMocks
|
396
|
+
def setup
|
397
|
+
@fixture = TestClassForMocks.new
|
398
|
+
end
|
399
|
+
|
400
|
+
def test_current_expectation
|
401
|
+
|
402
|
+
var_2174209040 = {val: 1, str: "hello world", message: "a message"}
|
403
|
+
|
404
|
+
TestMockSubClass.stub_any_instance(:return_hash, var_2174209040) do
|
405
|
+
#TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
|
406
|
+
assert_equal var_2174209040, @fixture.method_with_usage3("a message")
|
407
|
+
|
408
|
+
end
|
409
|
+
|
410
|
+
end
|
411
|
+
end
|
412
|
+
```
|
413
|
+
|
414
|
+
Note: Stubbing on minitest requires the minitest-stub_any_instance gem.
|
415
|
+
|
391
416
|
stubs that return different values every call are automatically detected an the appropriate rspec stub return
|
392
417
|
is generated (similar to below):
|
393
418
|
|
@@ -404,6 +429,8 @@ Pretentious.spec_for(TestClass._stub(ClassUsedByTestClass, AnotherClassUsedByTes
|
|
404
429
|
end
|
405
430
|
```
|
406
431
|
|
432
|
+
Note: different return values are only supported on RSpec for now
|
433
|
+
|
407
434
|
## Object Deconstruction Utility
|
408
435
|
|
409
436
|
As Pretentious as the gem is, there are other uses other than generating tests specs. Tools are also available to
|
data/example.rb
CHANGED
@@ -17,37 +17,38 @@ Pretentious.spec_for(Fibonacci) do
|
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
[:spec_for, :minitest_for].each do |method|
|
21
|
+
Pretentious.send(method, TestClass1, TestClass2, TestClass3, TestClass4) do
|
22
|
+
another_object = TestClass1.new("test")
|
23
|
+
test_class_one = TestClass1.new({hello: "world", test: another_object, arr_1: [1,2,3,4,5, another_object],
|
24
|
+
sub_hash: {yes: true, obj: another_object}})
|
25
|
+
test_class_two = TestClass2.new("This is message 2")
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
class_to_test = TestClass3.new(test_class_one, test_class_two)
|
28
|
+
class_to_test.show_messages
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
class_to_test = TestClass3.new(test_class_one, test_class_two)
|
31
|
+
class_to_test.show_messages
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
class_to_test4 = TestClass4.new {
|
34
|
+
another_object.message
|
35
|
+
}
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
test_class_one.set_block { |message|
|
38
|
+
message
|
39
|
+
}
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
test_class_one.call_block {
|
42
|
+
class_to_test4.message
|
43
|
+
}
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
test_class_one.just_returns_true
|
45
|
+
begin
|
46
|
+
test_class_one.something_is_wrong
|
47
|
+
rescue Exception=>e
|
48
|
+
end
|
50
49
|
|
50
|
+
test_class_one.just_returns_true
|
51
|
+
end
|
51
52
|
end
|
52
53
|
|
53
54
|
Pretentious.spec_for(Digest::MD5) do
|
@@ -55,15 +56,17 @@ Pretentious.spec_for(Digest::MD5) do
|
|
55
56
|
Digest::MD5.hexdigest(sample)
|
56
57
|
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
[:spec_for, :minitest_for].each do |m|
|
60
|
+
Pretentious.send(m, TestClassForMocks._stub(TestMockSubClass)) do
|
61
|
+
instance = TestClassForMocks.new
|
62
|
+
instance.method_with_assign = "test"
|
63
|
+
instance.method_with_usage
|
64
|
+
instance.method_with_usage2
|
65
|
+
instance.method_with_usage4
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
instance2 = TestClassForMocks.new
|
68
|
+
instance2.method_with_usage3("a message")
|
69
|
+
end
|
67
70
|
end
|
68
71
|
|
69
72
|
Pretentious.spec_for(TestClassForAutoStub._stub(ClassUsedByTestClass)) do
|
@@ -19,7 +19,7 @@ class Pretentious::MinitestGenerator
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def buffer(line, level = 0)
|
22
|
-
@output_buffer << "#{indentation(level)}#{line}\n"
|
22
|
+
@output_buffer << "#{indentation(level)}#{line}\n" if !line.nil? && line.strip != ''
|
23
23
|
end
|
24
24
|
|
25
25
|
def whitespace(level = 0)
|
@@ -28,7 +28,8 @@ class Pretentious::MinitestGenerator
|
|
28
28
|
|
29
29
|
def begin_spec(test_class)
|
30
30
|
@test_class = test_class
|
31
|
-
buffer("
|
31
|
+
buffer("#This file was automatically generated by the pretentious gem")
|
32
|
+
buffer("require 'minitest_helper'")
|
32
33
|
buffer('require "minitest/autorun"')
|
33
34
|
whitespace
|
34
35
|
buffer("class Test#{test_class.name} < Minitest::Test")
|
@@ -64,17 +65,17 @@ class Pretentious::MinitestGenerator
|
|
64
65
|
end
|
65
66
|
|
66
67
|
block_source = if !block.nil? && block.is_a?(Pretentious::RecordedProc)
|
67
|
-
get_block_source(block, test_instance.init_let_variables, declarations, @_indentation * 2)
|
68
|
+
get_block_source(block, test_instance.init_let_variables, declarations, @_indentation.length * 2)
|
68
69
|
else
|
69
70
|
''
|
70
71
|
end
|
71
72
|
|
72
73
|
if (dependencies.size > 0)
|
73
|
-
buffer(declare_dependencies(dependencies, test_instance.init_let_variables, 2
|
74
|
+
buffer(declare_dependencies(dependencies, test_instance.init_let_variables, 2, declarations))
|
74
75
|
end
|
75
76
|
|
76
77
|
if (args.size > 0)
|
77
|
-
buffer("@fixture = #{test_instance.test_class.name}.new(#{params_generator(args, test_instance.init_let_variables, declarations)})#{block_source}",
|
78
|
+
buffer("@fixture = #{test_instance.test_class.name}.new(#{params_generator(args, test_instance.init_let_variables, declarations)})#{block_source}",2)
|
78
79
|
else
|
79
80
|
buffer("@fixture = #{test_instance.test_class.name}.new#{block_source}",2)
|
80
81
|
end
|
@@ -109,6 +110,7 @@ class Pretentious::MinitestGenerator
|
|
109
110
|
end
|
110
111
|
|
111
112
|
def generate_expectation(fixture, method, let_variables, declarations, params, block, result)
|
113
|
+
str = ""
|
112
114
|
block_source = if !block.nil? && block.is_a?(Pretentious::RecordedProc)
|
113
115
|
get_block_source(block, let_variables, declarations, @_indentation * 2)
|
114
116
|
else
|
@@ -119,16 +121,18 @@ class Pretentious::MinitestGenerator
|
|
119
121
|
"#{fixture}.#{method.to_s}(#{params_generator(params, let_variables, declarations)})#{block_source}"
|
120
122
|
else
|
121
123
|
stmt = []
|
122
|
-
|
123
|
-
|
124
|
+
m_stmt = "#{fixture}.#{method.to_s}"
|
125
|
+
m_stmt << "(#{block_source})" unless block_source.empty?
|
126
|
+
stmt << m_stmt
|
124
127
|
stmt.join(' ')
|
125
128
|
end
|
126
129
|
|
127
130
|
if (result.kind_of? Exception)
|
128
|
-
|
131
|
+
str << pick_matcher(statement, result)
|
129
132
|
else
|
130
|
-
|
133
|
+
str << pick_matcher(statement, result)
|
131
134
|
end
|
135
|
+
str
|
132
136
|
end
|
133
137
|
|
134
138
|
def generate_specs(context_prefix, fixture, method_calls, let_variables)
|
@@ -169,13 +173,26 @@ class Pretentious::MinitestGenerator
|
|
169
173
|
end
|
170
174
|
|
171
175
|
if (params_collection.size > 0)
|
172
|
-
buffer(declare_dependencies(params_collection, let_variables,
|
176
|
+
buffer(declare_dependencies(params_collection, let_variables, 2, declaration))
|
173
177
|
end
|
174
178
|
|
175
179
|
if (mocks_collection.keys.size > 0)
|
176
|
-
buffer(
|
180
|
+
buffer(generate_minitest_stub(mocks_collection, let_variables, 2, declaration) { |indentation|
|
181
|
+
generate_test_scenarios(fixture, method_calls, context_prefix, let_variables, declaration, indentation)
|
182
|
+
},0)
|
183
|
+
else
|
184
|
+
buffer(generate_test_scenarios(fixture, method_calls, context_prefix, let_variables, declaration, 2), 0)
|
177
185
|
end
|
178
186
|
|
187
|
+
buffer("end", 1)
|
188
|
+
end
|
189
|
+
|
190
|
+
def generate_test_scenarios(fixture, method_calls, context_prefix, let_variables, declaration, indentation_level)
|
191
|
+
str = ""
|
192
|
+
indentation = ""
|
193
|
+
indentation_level.times {
|
194
|
+
indentation << @_indentation
|
195
|
+
}
|
179
196
|
method_calls.each_key do |k|
|
180
197
|
info_blocks_arr = method_calls[k]
|
181
198
|
|
@@ -187,31 +204,40 @@ class Pretentious::MinitestGenerator
|
|
187
204
|
""
|
188
205
|
end
|
189
206
|
|
190
|
-
|
191
|
-
generate_expectation(fixture, k, let_variables, declaration, block[:params], block[:block], block[:result])
|
207
|
+
str << "#{indentation}##{context_prefix}#{k} #{params_desc_str} should return #{block[:result]}\n"
|
208
|
+
str << "#{indentation}#{generate_expectation(fixture, k, let_variables, declaration, block[:params], block[:block], block[:result])}\n\n"
|
192
209
|
|
193
|
-
whitespace
|
194
210
|
end
|
195
|
-
|
196
|
-
|
197
211
|
end
|
198
|
-
|
212
|
+
str
|
199
213
|
end
|
200
214
|
|
201
|
-
def
|
202
|
-
indentation = ""
|
215
|
+
def generate_minitest_stub(mocks_collection, let_variables, indentation_level , declaration, &block)
|
203
216
|
|
204
|
-
indentation_level.times {
|
205
|
-
indentation << ' '
|
206
|
-
}
|
207
217
|
str = ""
|
218
|
+
current_indentation = indentation_level
|
219
|
+
|
208
220
|
mocks_collection.each do |k,values|
|
221
|
+
indentation = ""
|
222
|
+
current_indentation.times {
|
223
|
+
indentation << @_indentation
|
224
|
+
}
|
209
225
|
vals = values.collect { |v| Pretentious::value_ize(v[:result], let_variables, declaration) }
|
226
|
+
str << "#{indentation}#{values[0][:class].to_s}.stub_any_instance(:#{values[0][:method].to_s}, #{vals[0]}) do\n"
|
227
|
+
current_indentation+=1
|
228
|
+
end
|
210
229
|
|
211
|
-
|
212
|
-
vals = [vals[0]] if vals.uniq.size == 1
|
230
|
+
str << block.call(current_indentation)
|
213
231
|
|
214
|
-
|
232
|
+
current_indentation -= 1
|
233
|
+
|
234
|
+
mocks_collection.each do |k, values|
|
235
|
+
indentation = ""
|
236
|
+
current_indentation.times {
|
237
|
+
indentation << @_indentation
|
238
|
+
}
|
239
|
+
str << "#{indentation}end\n"
|
240
|
+
current_indentation -= 1
|
215
241
|
end
|
216
242
|
str
|
217
243
|
end
|
@@ -248,7 +274,7 @@ class Pretentious::MinitestGenerator
|
|
248
274
|
elsif result.is_a? FalseClass
|
249
275
|
"refute #{statement}"
|
250
276
|
elsif result.nil?
|
251
|
-
"assert_nil #{
|
277
|
+
"assert_nil #{statement}"
|
252
278
|
elsif result.kind_of? Exception
|
253
279
|
"assert_raises(#{result.class.to_s}) { #{statement} }"
|
254
280
|
else
|
@@ -284,7 +310,7 @@ class Pretentious::MinitestGenerator
|
|
284
310
|
deconstructor = Pretentious::Deconstructor.new
|
285
311
|
|
286
312
|
args = remove_primitives(args, variable_map)
|
287
|
-
deconstructor.deconstruct_to_ruby(level, variable_map, declarations, *args)
|
313
|
+
deconstructor.deconstruct_to_ruby(level * @_indentation.length, variable_map, declarations, *args)
|
288
314
|
end
|
289
315
|
|
290
316
|
def remove_primitives(args, let_lookup)
|
@@ -315,10 +341,11 @@ class Pretentious::MinitestGenerator
|
|
315
341
|
end
|
316
342
|
|
317
343
|
def self.helper(output_folder)
|
318
|
-
filename = File.join(output_folder,"
|
344
|
+
filename = File.join(output_folder,"minitest_helper.rb")
|
319
345
|
unless File.exists?(filename)
|
320
|
-
File.open(filename, 'w') {
|
321
|
-
|
346
|
+
File.open(filename, 'w') { |f|
|
347
|
+
f.write("# Place your requires here\n")
|
348
|
+
f.write("require 'minitest/stub_any_instance'\n")
|
322
349
|
}
|
323
350
|
puts "#{filename}"
|
324
351
|
end
|
data/lib/pretentious/version.rb
CHANGED
data/pretentious.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_dependency "binding_of_caller", "~> 0.7.2"
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "rspec"
|
24
|
-
spec.add_development_dependency "minitest"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.7"
|
25
|
+
spec.add_development_dependency "minitest-stub_any_instance", "~> 1.0"
|
25
26
|
end
|
data/run_test.sh
CHANGED
data/spec/fibonacci_spec.rb
CHANGED
data/spec/m_d5_spec.rb
CHANGED
@@ -18,7 +18,7 @@ RSpec.describe Pretentious::Generator do
|
|
18
18
|
result = Pretentious::Generator.generate_for(Fibonacci) do
|
19
19
|
Fibonacci.say_hello
|
20
20
|
end
|
21
|
-
expect(result).to eq({Fibonacci =>{output: "
|
21
|
+
expect(result).to eq({Fibonacci =>{output: "#This file was automatically generated by the pretentious gem\nrequire 'minitest_helper'\nrequire \"minitest/autorun\"\n\nclass TestFibonacci < Minitest::Test\nend\n\n def test_current_expectation\n\n #Fibonacci::say_hello should return hello\n assert_equal \"hello\", Fibonacci.say_hello\n\n\n end\n",
|
22
22
|
generator: Pretentious::MinitestGenerator }})
|
23
23
|
end
|
24
24
|
|
data/spec/prententious_spec.rb
CHANGED
@@ -19,7 +19,7 @@ RSpec.describe Pretentious::Generator do
|
|
19
19
|
Fibonacci.say_hello
|
20
20
|
end
|
21
21
|
expect(result).to eq({
|
22
|
-
Fibonacci =>{output: "
|
22
|
+
Fibonacci =>{output: "#This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n\n it 'should pass current expectations' do\n\n # Fibonacci::say_hello should return hello\n expect( Fibonacci.say_hello ).to eq(\"hello\")\n\n end\nend\n",
|
23
23
|
generator: Pretentious::RspecGenerator}})
|
24
24
|
end
|
25
25
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#This file was automatically generated by the pretentious gem
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
RSpec.describe TestClassForAutoStub do
|
@@ -11,7 +12,7 @@ RSpec.describe TestClassForAutoStub do
|
|
11
12
|
|
12
13
|
it 'should pass current expectations' do
|
13
14
|
|
14
|
-
|
15
|
+
var_2173901020 = ["Hello Glorious world", "HI THERE!!!!"]
|
15
16
|
|
16
17
|
allow_any_instance_of(ClassUsedByTestClass).to receive(:stubbed_method).and_return("Hello Glorious world")
|
17
18
|
allow_any_instance_of(AnotherClassUsedByTestClass).to receive(:get_message).and_return("HI THERE!!!!")
|
@@ -11,7 +11,7 @@ RSpec.describe TestClassForMocks do
|
|
11
11
|
|
12
12
|
it 'should pass current expectations' do
|
13
13
|
|
14
|
-
|
14
|
+
var_2166690320 = [2, 3, 4, 5]
|
15
15
|
|
16
16
|
allow_any_instance_of(TestMockSubClass).to receive(:test_method).and_return("a return string")
|
17
17
|
allow_any_instance_of(TestMockSubClass).to receive(:increment_val).and_return(2, 3, 4, 5)
|
@@ -40,12 +40,12 @@ RSpec.describe TestClassForMocks do
|
|
40
40
|
|
41
41
|
it 'should pass current expectations' do
|
42
42
|
|
43
|
-
|
43
|
+
var_2166592900 = {val: 1, str: "hello world", message: "a message"}
|
44
44
|
|
45
|
-
allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(
|
45
|
+
allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(var_2166592900)
|
46
46
|
|
47
47
|
# TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
|
48
|
-
expect( @fixture.method_with_usage3("a message") ).to eq(
|
48
|
+
expect( @fixture.method_with_usage3("a message") ).to eq(var_2166592900)
|
49
49
|
|
50
50
|
end
|
51
51
|
end
|
data/test/test_meme.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
#This file was automatically generated by the pretentious gem
|
2
|
+
require 'minitest_helper'
|
2
3
|
require "minitest/autorun"
|
3
4
|
|
4
5
|
class TestMeme < Minitest::Test
|
@@ -11,12 +12,13 @@ class Scenario1 < TestMeme
|
|
11
12
|
|
12
13
|
def test_current_expectation
|
13
14
|
|
14
|
-
|
15
|
+
#Meme#i_can_has_cheezburger? should return OHAI!
|
15
16
|
assert_equal "OHAI!", @fixture.i_can_has_cheezburger?
|
16
17
|
|
17
|
-
|
18
|
+
#Meme#will_it_blend? should return YES!
|
18
19
|
assert_equal "YES!", @fixture.will_it_blend?
|
19
20
|
|
21
|
+
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#This file was automatically generated by the pretentious gem
|
2
|
+
require 'minitest_helper'
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
class TestTestClass1 < Minitest::Test
|
6
|
+
end
|
7
|
+
|
8
|
+
class Scenario1 < TestTestClass1
|
9
|
+
def setup
|
10
|
+
@fixture = TestClass1.new("test")
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_current_expectation
|
14
|
+
|
15
|
+
#TestClass1#message should return test
|
16
|
+
assert_equal "test", @fixture.message
|
17
|
+
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Scenario2 < TestTestClass1
|
23
|
+
def setup
|
24
|
+
var_2175164340 = "test"
|
25
|
+
another_object = TestClass1.new(var_2175164340)
|
26
|
+
var_2175159080 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
|
27
|
+
|
28
|
+
@fixture = TestClass1.new(var_2175159080)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_current_expectation
|
32
|
+
|
33
|
+
var_2175164340 = "test"
|
34
|
+
another_object = TestClass1.new(var_2175164340)
|
35
|
+
var_2175159080 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
|
36
|
+
var_2175057940 = Proc.new { |message|
|
37
|
+
var_2175159080
|
38
|
+
}
|
39
|
+
|
40
|
+
e = nil
|
41
|
+
var_2175045040 = Proc.new {
|
42
|
+
# Variable return values ... can't figure out what goes in here...
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
#TestClass1#print_message should return
|
47
|
+
assert_nil @fixture.print_message
|
48
|
+
|
49
|
+
#TestClass1#print_message should return
|
50
|
+
assert_nil @fixture.print_message
|
51
|
+
|
52
|
+
#TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000103491d68@example.rb:73>
|
53
|
+
assert_equal var_2175057940, @fixture.set_block( &var_2175057940)
|
54
|
+
|
55
|
+
#TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x000001034cbe00 @message="test", @_init_arguments={:params=>["test"]}, @_variable_names={2175164340=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x000001034cbe00 @message="test", @_init_arguments={:params=>["test"]}, @_variable_names={2175164340=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x000001034cbe00 @message="test", @_init_arguments={:params=>["test"]}, @_variable_names={2175164340=>"message"}>}}
|
56
|
+
assert_equal var_2175159080, @fixture.call_block( &var_2175045040)
|
57
|
+
|
58
|
+
#TestClass1#something_is_wrong should return StandardError
|
59
|
+
assert_raises(StandardError) { @fixture.something_is_wrong }
|
60
|
+
|
61
|
+
#TestClass1#just_returns_true should return true
|
62
|
+
assert @fixture.just_returns_true
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#This file was automatically generated by the pretentious gem
|
2
|
+
require 'minitest_helper'
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
class TestTestClass2 < Minitest::Test
|
6
|
+
end
|
7
|
+
|
8
|
+
class Scenario1 < TestTestClass2
|
9
|
+
def setup
|
10
|
+
@fixture = TestClass2.new("This is message 2")
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_current_expectation
|
14
|
+
|
15
|
+
#TestClass2#print_message should return
|
16
|
+
assert_nil @fixture.print_message
|
17
|
+
|
18
|
+
#TestClass2#print_message should return
|
19
|
+
assert_nil @fixture.print_message
|
20
|
+
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#This file was automatically generated by the pretentious gem
|
2
|
+
require 'minitest_helper'
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
class TestTestClass3 < Minitest::Test
|
6
|
+
end
|
7
|
+
|
8
|
+
class Scenario1 < TestTestClass3
|
9
|
+
def setup
|
10
|
+
var_2175164340 = "test"
|
11
|
+
another_object = TestClass1.new(var_2175164340)
|
12
|
+
args = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
|
13
|
+
test_class_one = TestClass1.new(args)
|
14
|
+
args_1 = "This is message 2"
|
15
|
+
test_class_two = TestClass2.new(args_1)
|
16
|
+
|
17
|
+
@fixture = TestClass3.new(test_class_one, test_class_two)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_current_expectation
|
21
|
+
|
22
|
+
#TestClass3#show_messages should return awesome!!!
|
23
|
+
assert_equal "awesome!!!", @fixture.show_messages
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Scenario2 < TestTestClass3
|
30
|
+
def setup
|
31
|
+
var_2175164340 = "test"
|
32
|
+
another_object = TestClass1.new(var_2175164340)
|
33
|
+
args = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
|
34
|
+
test_class_one = TestClass1.new(args)
|
35
|
+
args_1 = "This is message 2"
|
36
|
+
test_class_two = TestClass2.new(args_1)
|
37
|
+
|
38
|
+
@fixture = TestClass3.new(test_class_one, test_class_two)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_current_expectation
|
42
|
+
|
43
|
+
#TestClass3#show_messages should return awesome!!!
|
44
|
+
assert_equal "awesome!!!", @fixture.show_messages
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#This file was automatically generated by the pretentious gem
|
2
|
+
require 'minitest_helper'
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
class TestTestClass4 < Minitest::Test
|
6
|
+
end
|
7
|
+
|
8
|
+
class Scenario1 < TestTestClass4
|
9
|
+
def setup
|
10
|
+
var_2175164340 = "test"
|
11
|
+
var_2175076740 = Proc.new {
|
12
|
+
"test"
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
@fixture = TestClass4.new &var_2175076740
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_current_expectation
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#This file was automatically generated by the pretentious gem
|
2
|
+
require 'minitest_helper'
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
class TestTestClassForMocks < Minitest::Test
|
6
|
+
end
|
7
|
+
|
8
|
+
class Scenario1 < TestTestClassForMocks
|
9
|
+
def setup
|
10
|
+
@fixture = TestClassForMocks.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_current_expectation
|
14
|
+
|
15
|
+
var_2162327080 = [2, 3, 4, 5]
|
16
|
+
|
17
|
+
TestMockSubClass.stub_any_instance(:test_method, "a return string") do
|
18
|
+
TestMockSubClass.stub_any_instance(:increment_val, 2) do
|
19
|
+
#TestClassForMocks#method_with_assign= when passed params2 = "test" should return test
|
20
|
+
assert_equal "test", @fixture.method_with_assign=("test")
|
21
|
+
|
22
|
+
#TestClassForMocks#method_with_usage should return a return string
|
23
|
+
assert_equal "a return string", @fixture.method_with_usage
|
24
|
+
|
25
|
+
#TestClassForMocks#method_with_usage2 should return [2, 3, 4, 5]
|
26
|
+
assert_equal [2, 3, 4, 5], @fixture.method_with_usage2
|
27
|
+
|
28
|
+
#TestClassForMocks#method_with_usage4 should return a return string
|
29
|
+
assert_equal "a return string", @fixture.method_with_usage4
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Scenario2 < TestTestClassForMocks
|
38
|
+
def setup
|
39
|
+
@fixture = TestClassForMocks.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_current_expectation
|
43
|
+
|
44
|
+
var_2174209040 = {val: 1, str: "hello world", message: "a message"}
|
45
|
+
|
46
|
+
TestMockSubClass.stub_any_instance(:return_hash, var_2174209040) do
|
47
|
+
#TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
|
48
|
+
assert_equal var_2174209040, @fixture.method_with_usage3("a message")
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretentious
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Emmanuel Dayo
|
@@ -56,30 +56,44 @@ dependencies:
|
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '5.7'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest-stub_any_instance
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
96
|
+
version: '1.0'
|
83
97
|
description: Do you have a pretentious boss or dev lead that pushes you to embrace
|
84
98
|
tdd but for reasons hate it or them? here is a gem to deal with that.
|
85
99
|
email:
|
@@ -118,9 +132,14 @@ files:
|
|
118
132
|
- spec/test_class4_spec.rb
|
119
133
|
- spec/test_class_for_auto_stub_spec.rb
|
120
134
|
- spec/test_class_for_mocks_spec.rb
|
135
|
+
- test/minitest_helper.rb
|
121
136
|
- test/test_generator.rb
|
122
|
-
- test/test_helper.rb
|
123
137
|
- test/test_meme.rb
|
138
|
+
- test/test_test_class1.rb
|
139
|
+
- test/test_test_class2.rb
|
140
|
+
- test/test_test_class3.rb
|
141
|
+
- test/test_test_class4.rb
|
142
|
+
- test/test_test_class_for_mocks.rb
|
124
143
|
- test_classes.rb
|
125
144
|
homepage: https://github.com/jedld/pretentious
|
126
145
|
licenses:
|
@@ -161,7 +180,12 @@ test_files:
|
|
161
180
|
- spec/test_class4_spec.rb
|
162
181
|
- spec/test_class_for_auto_stub_spec.rb
|
163
182
|
- spec/test_class_for_mocks_spec.rb
|
183
|
+
- test/minitest_helper.rb
|
164
184
|
- test/test_generator.rb
|
165
|
-
- test/test_helper.rb
|
166
185
|
- test/test_meme.rb
|
186
|
+
- test/test_test_class1.rb
|
187
|
+
- test/test_test_class2.rb
|
188
|
+
- test/test_test_class3.rb
|
189
|
+
- test/test_test_class4.rb
|
190
|
+
- test/test_test_class_for_mocks.rb
|
167
191
|
has_rdoc:
|
data/test/test_helper.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require_relative '../test_classes'
|