pretentious 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +13 -1
- data/Rakefile +2 -2
- data/bin/pretentious +49 -0
- data/lib/pretentious.rb +1 -0
- data/lib/pretentious/deconstructor.rb +1 -1
- data/lib/pretentious/trigger.rb +2 -5
- data/lib/pretentious/utils/file_writer.rb +30 -0
- data/lib/pretentious/version.rb +1 -1
- data/run_test.sh +1 -1
- data/spec/{fibonacci_spec.rb → generated/fibonacci_spec.rb} +0 -0
- data/spec/{m_d5_spec.rb → generated/m_d5_spec.rb} +0 -0
- data/spec/generated/spec_helper.rb +1 -0
- data/spec/{test_class1_spec.rb → generated/test_class1_spec.rb} +9 -9
- data/spec/{test_class2_spec.rb → generated/test_class2_spec.rb} +0 -0
- data/spec/{test_class3_spec.rb → generated/test_class3_spec.rb} +4 -4
- data/spec/{test_class4_spec.rb → generated/test_class4_spec.rb} +2 -2
- data/spec/{test_class_for_auto_stub_spec.rb → generated/test_class_for_auto_stub_spec.rb} +1 -1
- data/spec/{test_class_for_mocks_spec.rb → generated/test_class_for_mocks_spec.rb} +4 -4
- data/spec/utils/filewriter_spec.rb +26 -0
- data/test/generated/minitest_helper.rb +2 -0
- data/test/{test_fibonacci.rb → generated/test_fibonacci.rb} +0 -0
- data/test/{test_m_d5.rb → generated/test_m_d5.rb} +0 -0
- data/test/{test_meme.rb → generated/test_meme.rb} +0 -0
- data/test/{test_test_class1.rb → generated/test_test_class1.rb} +9 -9
- data/test/{test_test_class2.rb → generated/test_test_class2.rb} +0 -0
- data/test/{test_test_class3.rb → generated/test_test_class3.rb} +4 -4
- data/test/{test_test_class4.rb → generated/test_test_class4.rb} +2 -2
- data/test/{test_test_class_for_mocks.rb → generated/test_test_class_for_mocks.rb} +4 -4
- data/test/test_generator.rb +1 -1
- metadata +46 -37
- data/bin/ddtgen +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93b54d67b903a92f2ceb44c3802c79692c0196ad
|
4
|
+
data.tar.gz: 88864af8c6c668bcb5f56e365b9a89f35e83cf9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 213be948569e21541d057647ac45aefcff46fbef223c84a4d5ea2709f39f1e36b6919627e7f346a2d418e41c255d392af7b4d4423f676b9887670d96fc32e573
|
7
|
+
data.tar.gz: bd240b81e83fdf30fc91e7f993c8d778fad178519b03226c42280b3a1e1675bfb6b369b78a94e2726ba278a14199ece040de71be3789af31817079f3d433f58d
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -101,7 +101,7 @@ end
|
|
101
101
|
|
102
102
|
Save your file and then switch to the terminal to invoke:
|
103
103
|
|
104
|
-
$
|
104
|
+
$ pretentious example.rb
|
105
105
|
|
106
106
|
This will automatically generate rspec tests for Fibonacci under /spec of the current working directory.
|
107
107
|
|
@@ -293,6 +293,18 @@ end
|
|
293
293
|
# spec files will be written to the project root
|
294
294
|
```
|
295
295
|
|
296
|
+
or, use the FileWriter utility to write it to a file
|
297
|
+
|
298
|
+
```ruby
|
299
|
+
# initializers/pretentious.rb
|
300
|
+
|
301
|
+
if Rails.env.test? #IMPORTANT don't run this when you don't need it!
|
302
|
+
Pretentious.on(UsersController).method_called(:login).spec_for(UserAuthentication) do |results|
|
303
|
+
file_writer = Pretentious::FileWriter.new
|
304
|
+
file_writer.write UserAuthenticaion, results[UserAuthenticaion]
|
305
|
+
end
|
306
|
+
end
|
307
|
+
```
|
296
308
|
IMPORTANT: If using rails or if it is part of a larger app, make sure to enable this only when you intend to generate specs!
|
297
309
|
delete the initializer or comment the code out when it is not needed.
|
298
310
|
|
data/Rakefile
CHANGED
data/bin/pretentious
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pretentious'
|
4
|
+
require 'optparse'
|
5
|
+
require 'ripper'
|
6
|
+
require 'readline'
|
7
|
+
require 'json'
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
output_folder = nil
|
11
|
+
output_subfolder =nil
|
12
|
+
|
13
|
+
# pretentious example.rb -t rspec -o rspec/
|
14
|
+
options = OptionParser.new do |o|
|
15
|
+
o.banner =
|
16
|
+
"Usage: pretentious FILENAME [options] # Generates tests using the specified example file\n"
|
17
|
+
o.separator ''
|
18
|
+
o.separator "options:"
|
19
|
+
o.on('-n=namespace', '--namespace=NAMESPACE',
|
20
|
+
'sub folder to place the generated files in (defaults to generated)') { |b| output_subfolder }
|
21
|
+
o.on('-o=OUTPUT_DIR', '--output-dir=OUTPUT_DIR',
|
22
|
+
'folder to place the files in -- defaults to spec (RSpec) or test (minitest)') { |b| output_folder = b}
|
23
|
+
o.parse!
|
24
|
+
end
|
25
|
+
|
26
|
+
filename = ARGV[0]
|
27
|
+
|
28
|
+
if filename.nil?
|
29
|
+
puts 'an example file is required.'
|
30
|
+
puts options
|
31
|
+
exit(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
example_body = ''
|
35
|
+
|
36
|
+
index = 0
|
37
|
+
File.open(filename, "r") do |f|
|
38
|
+
f.each_line do |line|
|
39
|
+
example_body << "#{line}\n"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
eval(example_body, binding, filename, 1)
|
44
|
+
|
45
|
+
# collect results and write them
|
46
|
+
puts "writing tests to #{output_folder}"
|
47
|
+
filewriter = Pretentious::FileWriter.new(output_folder: output_folder,
|
48
|
+
spec_output_folder: output_subfolder)
|
49
|
+
filewriter.write_results(Pretentious.last_results)
|
data/lib/pretentious.rb
CHANGED
@@ -216,7 +216,7 @@ module Pretentious
|
|
216
216
|
|
217
217
|
def self.primitive?(value)
|
218
218
|
value.is_a?(String) || value.is_a?(Fixnum) || value.is_a?(TrueClass) || value.is_a?(FalseClass) ||
|
219
|
-
|
219
|
+
value.is_a?(NilClass) || value.is_a?(Symbol) || value.is_a?(Class)
|
220
220
|
end
|
221
221
|
|
222
222
|
def self.block_param_names(proc)
|
data/lib/pretentious/trigger.rb
CHANGED
@@ -38,11 +38,8 @@ module Pretentious
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.output_file(result, klass, output_folder)
|
41
|
-
|
42
|
-
result
|
43
|
-
filename = result[:generator].naming(output_folder, klass)
|
44
|
-
File.open(filename, 'w') { |f| f.write(result[:output]) }
|
45
|
-
filename
|
41
|
+
file_writer = FileWriter.new({ output_folder: output_folder })
|
42
|
+
file_writer.write klass, result
|
46
43
|
end
|
47
44
|
|
48
45
|
private
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Pretentious
|
2
|
+
# Utility function for saving pretentious test artifacts to a file.
|
3
|
+
class FileWriter
|
4
|
+
# options for the file writer
|
5
|
+
def initialize(options = {})
|
6
|
+
@spec_output_folder ||= (options[:spec_output_folder] || 'generated')
|
7
|
+
@output_folder = options[:output_folder] || nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def write(klass, result)
|
11
|
+
output_folder = result[:generator].location(@output_folder)
|
12
|
+
spec_output_folder = File.join(output_folder, @spec_output_folder)
|
13
|
+
FileUtils.mkdir_p result[:generator].location(@output_folder)
|
14
|
+
FileUtils.mkdir_p spec_output_folder
|
15
|
+
result[:generator].helper(output_folder)
|
16
|
+
filename = result[:generator].naming(spec_output_folder, klass)
|
17
|
+
File.open(filename, 'w') { |f| f.write(result[:output]) }
|
18
|
+
filename
|
19
|
+
end
|
20
|
+
|
21
|
+
def write_results(results)
|
22
|
+
results.each do |g, result_per_generator|
|
23
|
+
puts "#{g}:"
|
24
|
+
result_per_generator.each do |klass, result|
|
25
|
+
puts write(klass, result)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/pretentious/version.rb
CHANGED
data/run_test.sh
CHANGED
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# Place your requires here
|
@@ -21,12 +21,12 @@ RSpec.describe TestClass1 do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should pass current expectations' do
|
24
|
-
|
24
|
+
var_2172599780 = proc { |message|
|
25
25
|
@message
|
26
26
|
}
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
filewriter = nil
|
29
|
+
var_2172592820 = proc {
|
30
30
|
# Variable return values ... can't figure out what goes in here...
|
31
31
|
}
|
32
32
|
|
@@ -36,11 +36,11 @@ RSpec.describe TestClass1 do
|
|
36
36
|
# TestClass1#print_message should return
|
37
37
|
expect(@fixture.print_message).to be_nil
|
38
38
|
|
39
|
-
# TestClass1#set_block should return #<Pretentious::RecordedProc:
|
40
|
-
expect(@fixture.set_block &
|
39
|
+
# TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000102fe47e8@example.rb:73>
|
40
|
+
expect(@fixture.set_block &var_2172599780).to eq(var_2172599780)
|
41
41
|
|
42
|
-
# TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:
|
43
|
-
expect(@fixture.call_block &
|
42
|
+
# TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x00000102dfcd40 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2171593180=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x00000102dfcd40 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2171593180=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x00000102dfcd40 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2171593180=>"message"}>}}
|
43
|
+
expect(@fixture.call_block &var_2172592820).to eq(@message)
|
44
44
|
|
45
45
|
# TestClass1#something_is_wrong should return StandardError
|
46
46
|
expect { @fixture.something_is_wrong }.to raise_error
|
@@ -57,7 +57,7 @@ RSpec.describe TestClass1 do
|
|
57
57
|
|
58
58
|
it 'should pass current expectations' do
|
59
59
|
another_object = TestClass1.new('test')
|
60
|
-
# TestClass1#return_self when passed message = #<TestClass1:
|
60
|
+
# TestClass1#return_self when passed message = #<TestClass1:0x00000102dfcd40> should return #<TestClass1:0x00000102dfcd40>
|
61
61
|
expect(@fixture.return_self(another_object)).to eq(another_object)
|
62
62
|
end
|
63
63
|
end
|
@@ -69,7 +69,7 @@ RSpec.describe TestClass1 do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should pass current expectations' do
|
72
|
-
# TestClass1#message should return #<TestClass1:
|
72
|
+
# TestClass1#message should return #<TestClass1:0x00000102dfcd40>
|
73
73
|
expect(@fixture.message).to eq(@message)
|
74
74
|
end
|
75
75
|
end
|
File without changes
|
@@ -5,8 +5,8 @@ RSpec.describe TestClass3 do
|
|
5
5
|
context 'Scenario 1' do
|
6
6
|
before do
|
7
7
|
another_object = TestClass1.new('test')
|
8
|
-
|
9
|
-
testclass1 = TestClass1.new(
|
8
|
+
var_2171643980 = { hello: 'world', test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: { yes: true, obj: another_object } }
|
9
|
+
testclass1 = TestClass1.new(var_2171643980)
|
10
10
|
testclass2 = TestClass2.new('This is message 2', nil)
|
11
11
|
@fixture = TestClass3.new(testclass1, testclass2)
|
12
12
|
end
|
@@ -20,8 +20,8 @@ RSpec.describe TestClass3 do
|
|
20
20
|
context 'Scenario 2' do
|
21
21
|
before do
|
22
22
|
another_object = TestClass1.new('test')
|
23
|
-
|
24
|
-
testclass1 = TestClass1.new(
|
23
|
+
var_2171643980 = { hello: 'world', test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: { yes: true, obj: another_object } }
|
24
|
+
testclass1 = TestClass1.new(var_2171643980)
|
25
25
|
testclass2 = TestClass2.new('This is message 2', nil)
|
26
26
|
@fixture = TestClass3.new(testclass1, testclass2)
|
27
27
|
end
|
@@ -5,11 +5,11 @@ RSpec.describe TestClass4 do
|
|
5
5
|
context 'Scenario 1' do
|
6
6
|
before do
|
7
7
|
var_8 = nil
|
8
|
-
|
8
|
+
var_2172496800 = proc {
|
9
9
|
# Variable return values ... can't figure out what goes in here...
|
10
10
|
}
|
11
11
|
|
12
|
-
@fixture = TestClass4.new(&
|
12
|
+
@fixture = TestClass4.new(&var_2172496800)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should pass current expectations' do
|
@@ -8,7 +8,7 @@ RSpec.describe TestClassForAutoStub do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should pass current expectations' do
|
11
|
-
|
11
|
+
var_2183970200 = ['Hello Glorious world', 'HI THERE!!!!']
|
12
12
|
allow_any_instance_of(ClassUsedByTestClass).to receive(:stubbed_method).and_return('Hello Glorious world')
|
13
13
|
allow_any_instance_of(AnotherClassUsedByTestClass).to receive(:get_message).and_return('HI THERE!!!!')
|
14
14
|
|
@@ -8,7 +8,7 @@ RSpec.describe TestClassForMocks do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should pass current expectations' do
|
11
|
-
|
11
|
+
var_2182775400 = [2, 3, 4, 5]
|
12
12
|
allow_any_instance_of(TestMockSubClass).to receive(:test_method).and_return('a return string')
|
13
13
|
allow_any_instance_of(TestMockSubClass).to receive(:increment_val).and_return(2, 3, 4, 5)
|
14
14
|
|
@@ -32,11 +32,11 @@ RSpec.describe TestClassForMocks do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should pass current expectations' do
|
35
|
-
|
36
|
-
allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(
|
35
|
+
var_2182709200 = { val: 1, str: 'hello world', message: 'a message' }
|
36
|
+
allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(var_2182709200)
|
37
37
|
|
38
38
|
# TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
|
39
|
-
expect(@fixture.method_with_usage3('a message')).to eq(
|
39
|
+
expect(@fixture.method_with_usage3('a message')).to eq(var_2182709200)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pretentious::FileWriter do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Pretentious.clear_results
|
7
|
+
Pretentious.spec_for(TestClass1) do
|
8
|
+
message = { test: 'message' }
|
9
|
+
object = TestClass1.new(message)
|
10
|
+
object.return_self(message)
|
11
|
+
end
|
12
|
+
@last_results = Pretentious.last_results
|
13
|
+
@instance = Pretentious::FileWriter.new({ output: 'generated'})
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'writes the class output to a file' do
|
17
|
+
file = double('file')
|
18
|
+
allow(Pretentious::RspecGenerator).to receive(:helper)
|
19
|
+
expect(File).to receive(:open).with('spec/generated/test_class1_spec.rb', 'w').and_yield(file)
|
20
|
+
expect(file).to receive(:write).with(@last_results[:spec][TestClass1][:output])
|
21
|
+
expect(FileUtils).to receive(:mkdir_p).with('spec')
|
22
|
+
expect(FileUtils).to receive(:mkdir_p).with('spec/generated')
|
23
|
+
|
24
|
+
@instance.write_results(Pretentious.last_results)
|
25
|
+
end
|
26
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -25,12 +25,12 @@ class TestClass1Scenario2 < TestClass1Test
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_current_expectation
|
28
|
-
|
28
|
+
var_2172317940 = proc { |message|
|
29
29
|
@message
|
30
30
|
}
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
filewriter = nil
|
33
|
+
var_2172155700 = proc {
|
34
34
|
# Variable return values ... can't figure out what goes in here...
|
35
35
|
}
|
36
36
|
|
@@ -49,12 +49,12 @@ class TestClass1Scenario2 < TestClass1Test
|
|
49
49
|
assert_nil @fixture.print_message
|
50
50
|
|
51
51
|
|
52
|
-
# TestClass1#set_block should return #<Pretentious::RecordedProc:
|
53
|
-
assert_equal
|
52
|
+
# TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000102f0f2c8@example.rb:73>
|
53
|
+
assert_equal var_2172317940, @fixture.set_block( &var_2172317940)
|
54
54
|
|
55
55
|
|
56
|
-
# TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:
|
57
|
-
assert_equal @message, @fixture.call_block( &
|
56
|
+
# TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x000001049e89a0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2186233220=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x000001049e89a0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2186233220=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x000001049e89a0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2186233220=>"message"}>}}
|
57
|
+
assert_equal @message, @fixture.call_block( &var_2172155700)
|
58
58
|
|
59
59
|
|
60
60
|
# TestClass1#something_is_wrong should return StandardError
|
@@ -75,7 +75,7 @@ class TestClass1Scenario3 < TestClass1Test
|
|
75
75
|
def test_current_expectation
|
76
76
|
another_object = TestClass1.new('test')
|
77
77
|
|
78
|
-
# TestClass1#return_self when passed message = #<TestClass1:
|
78
|
+
# TestClass1#return_self when passed message = #<TestClass1:0x000001049e89a0> should return #<TestClass1:0x000001049e89a0>
|
79
79
|
assert_equal another_object, @fixture.return_self(another_object)
|
80
80
|
|
81
81
|
end
|
@@ -88,7 +88,7 @@ class TestClass1Scenario4 < TestClass1Test
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_current_expectation
|
91
|
-
# TestClass1#message should return #<TestClass1:
|
91
|
+
# TestClass1#message should return #<TestClass1:0x000001049e89a0>
|
92
92
|
assert_equal @message, @fixture.message
|
93
93
|
|
94
94
|
end
|
File without changes
|
@@ -8,8 +8,8 @@ end
|
|
8
8
|
class TestClass3Scenario1 < TestClass3Test
|
9
9
|
def setup
|
10
10
|
another_object = TestClass1.new('test')
|
11
|
-
|
12
|
-
testclass1 = TestClass1.new(
|
11
|
+
var_2186185960 = { hello: 'world', test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: { yes: true, obj: another_object } }
|
12
|
+
testclass1 = TestClass1.new(var_2186185960)
|
13
13
|
testclass2 = TestClass2.new('This is message 2', nil)
|
14
14
|
@fixture = TestClass3.new(testclass1, testclass2)
|
15
15
|
end
|
@@ -24,8 +24,8 @@ end
|
|
24
24
|
class TestClass3Scenario2 < TestClass3Test
|
25
25
|
def setup
|
26
26
|
another_object = TestClass1.new('test')
|
27
|
-
|
28
|
-
testclass1 = TestClass1.new(
|
27
|
+
var_2186185960 = { hello: 'world', test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: { yes: true, obj: another_object } }
|
28
|
+
testclass1 = TestClass1.new(var_2186185960)
|
29
29
|
testclass2 = TestClass2.new('This is message 2', nil)
|
30
30
|
@fixture = TestClass3.new(testclass1, testclass2)
|
31
31
|
end
|
@@ -8,11 +8,11 @@ end
|
|
8
8
|
class TestClass4Scenario1 < TestClass4Test
|
9
9
|
def setup
|
10
10
|
var_8 = nil
|
11
|
-
|
11
|
+
var_2172413240 = proc {
|
12
12
|
# Variable return values ... can't figure out what goes in here...
|
13
13
|
}
|
14
14
|
|
15
|
-
@fixture = TestClass4.new(&
|
15
|
+
@fixture = TestClass4.new(&var_2172413240)
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_current_expectation
|
@@ -11,7 +11,7 @@ class TestClassForMocksScenario1 < TestClassForMocksTest
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_current_expectation
|
14
|
-
|
14
|
+
var_2184084360 = [2, 3, 4, 5]
|
15
15
|
|
16
16
|
TestMockSubClass.stub_any_instance(:test_method, 'a return string') do
|
17
17
|
TestMockSubClass.stub_any_instance(:increment_val, 2) do
|
@@ -42,11 +42,11 @@ class TestClassForMocksScenario2 < TestClassForMocksTest
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_current_expectation
|
45
|
-
|
45
|
+
var_2184042120 = { val: 1, str: 'hello world', message: 'a message' }
|
46
46
|
|
47
|
-
TestMockSubClass.stub_any_instance(:return_hash,
|
47
|
+
TestMockSubClass.stub_any_instance(:return_hash, var_2184042120) do
|
48
48
|
# TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
|
49
|
-
assert_equal
|
49
|
+
assert_equal var_2184042120, @fixture.method_with_usage3('a message')
|
50
50
|
|
51
51
|
end
|
52
52
|
|
data/test/test_generator.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretentious
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Emmanuel Dayo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|
@@ -156,16 +156,17 @@ description: Characterization Tests for Ruby - Do you have a pretentious boss or
|
|
156
156
|
email:
|
157
157
|
- joseph.dayo@gmail.com
|
158
158
|
executables:
|
159
|
-
-
|
159
|
+
- pretentious
|
160
160
|
extensions: []
|
161
161
|
extra_rdoc_files: []
|
162
162
|
files:
|
163
163
|
- ".gitignore"
|
164
|
+
- CHANGELOG.md
|
164
165
|
- Gemfile
|
165
166
|
- LICENSE.txt
|
166
167
|
- README.md
|
167
168
|
- Rakefile
|
168
|
-
- bin/
|
169
|
+
- bin/pretentious
|
169
170
|
- example.rb
|
170
171
|
- lib/pretentious.rb
|
171
172
|
- lib/pretentious/context.rb
|
@@ -176,32 +177,36 @@ files:
|
|
176
177
|
- lib/pretentious/recorded_proc.rb
|
177
178
|
- lib/pretentious/rspec_generator.rb
|
178
179
|
- lib/pretentious/trigger.rb
|
180
|
+
- lib/pretentious/utils/file_writer.rb
|
179
181
|
- lib/pretentious/version.rb
|
180
182
|
- pretentious.gemspec
|
181
183
|
- run_test.sh
|
182
184
|
- spec/deconstructor_spec.rb
|
183
|
-
- spec/fibonacci_spec.rb
|
185
|
+
- spec/generated/fibonacci_spec.rb
|
186
|
+
- spec/generated/m_d5_spec.rb
|
187
|
+
- spec/generated/spec_helper.rb
|
188
|
+
- spec/generated/test_class1_spec.rb
|
189
|
+
- spec/generated/test_class2_spec.rb
|
190
|
+
- spec/generated/test_class3_spec.rb
|
191
|
+
- spec/generated/test_class4_spec.rb
|
192
|
+
- spec/generated/test_class_for_auto_stub_spec.rb
|
193
|
+
- spec/generated/test_class_for_mocks_spec.rb
|
184
194
|
- spec/generator_spec.rb
|
185
|
-
- spec/m_d5_spec.rb
|
186
195
|
- spec/minitest_generator_spec.rb
|
187
196
|
- spec/prententious_spec.rb
|
188
197
|
- spec/spec_helper.rb
|
189
|
-
- spec/
|
190
|
-
-
|
191
|
-
-
|
192
|
-
-
|
193
|
-
-
|
194
|
-
-
|
198
|
+
- spec/utils/filewriter_spec.rb
|
199
|
+
- test/generated/minitest_helper.rb
|
200
|
+
- test/generated/test_fibonacci.rb
|
201
|
+
- test/generated/test_m_d5.rb
|
202
|
+
- test/generated/test_meme.rb
|
203
|
+
- test/generated/test_test_class1.rb
|
204
|
+
- test/generated/test_test_class2.rb
|
205
|
+
- test/generated/test_test_class3.rb
|
206
|
+
- test/generated/test_test_class4.rb
|
207
|
+
- test/generated/test_test_class_for_mocks.rb
|
195
208
|
- test/minitest_helper.rb
|
196
|
-
- test/test_fibonacci.rb
|
197
209
|
- test/test_generator.rb
|
198
|
-
- test/test_m_d5.rb
|
199
|
-
- test/test_meme.rb
|
200
|
-
- test/test_test_class1.rb
|
201
|
-
- test/test_test_class2.rb
|
202
|
-
- test/test_test_class3.rb
|
203
|
-
- test/test_test_class4.rb
|
204
|
-
- test/test_test_class_for_mocks.rb
|
205
210
|
- test_classes.rb
|
206
211
|
homepage: https://github.com/jedld/pretentious
|
207
212
|
licenses:
|
@@ -223,32 +228,36 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
228
|
version: '0'
|
224
229
|
requirements: []
|
225
230
|
rubyforge_project:
|
226
|
-
rubygems_version: 2.
|
231
|
+
rubygems_version: 2.2.2
|
227
232
|
signing_key:
|
228
233
|
specification_version: 4
|
229
234
|
summary: Characterization Tests generator for Ruby - Generate tests from existing/legacy
|
230
235
|
code as well as a way to deal with pretentious TDD/BDD developers
|
231
236
|
test_files:
|
232
237
|
- spec/deconstructor_spec.rb
|
233
|
-
- spec/fibonacci_spec.rb
|
238
|
+
- spec/generated/fibonacci_spec.rb
|
239
|
+
- spec/generated/m_d5_spec.rb
|
240
|
+
- spec/generated/spec_helper.rb
|
241
|
+
- spec/generated/test_class1_spec.rb
|
242
|
+
- spec/generated/test_class2_spec.rb
|
243
|
+
- spec/generated/test_class3_spec.rb
|
244
|
+
- spec/generated/test_class4_spec.rb
|
245
|
+
- spec/generated/test_class_for_auto_stub_spec.rb
|
246
|
+
- spec/generated/test_class_for_mocks_spec.rb
|
234
247
|
- spec/generator_spec.rb
|
235
|
-
- spec/m_d5_spec.rb
|
236
248
|
- spec/minitest_generator_spec.rb
|
237
249
|
- spec/prententious_spec.rb
|
238
250
|
- spec/spec_helper.rb
|
239
|
-
- spec/
|
240
|
-
-
|
241
|
-
-
|
242
|
-
-
|
243
|
-
-
|
244
|
-
-
|
251
|
+
- spec/utils/filewriter_spec.rb
|
252
|
+
- test/generated/minitest_helper.rb
|
253
|
+
- test/generated/test_fibonacci.rb
|
254
|
+
- test/generated/test_m_d5.rb
|
255
|
+
- test/generated/test_meme.rb
|
256
|
+
- test/generated/test_test_class1.rb
|
257
|
+
- test/generated/test_test_class2.rb
|
258
|
+
- test/generated/test_test_class3.rb
|
259
|
+
- test/generated/test_test_class4.rb
|
260
|
+
- test/generated/test_test_class_for_mocks.rb
|
245
261
|
- test/minitest_helper.rb
|
246
|
-
- test/test_fibonacci.rb
|
247
262
|
- test/test_generator.rb
|
248
|
-
|
249
|
-
- test/test_meme.rb
|
250
|
-
- test/test_test_class1.rb
|
251
|
-
- test/test_test_class2.rb
|
252
|
-
- test/test_test_class3.rb
|
253
|
-
- test/test_test_class4.rb
|
254
|
-
- test/test_test_class_for_mocks.rb
|
263
|
+
has_rdoc:
|
data/bin/ddtgen
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'pretentious'
|
4
|
-
require 'optparse'
|
5
|
-
require 'ripper'
|
6
|
-
require 'readline'
|
7
|
-
require 'json'
|
8
|
-
require 'fileutils'
|
9
|
-
|
10
|
-
# ddtgen example.rb -t rspec -o rspec/
|
11
|
-
options = OptionParser.new do |o|
|
12
|
-
o.banner =
|
13
|
-
"Usage: ddtgen FILENAME [options] # Generates tests using the specified example file\n"
|
14
|
-
o.separator ''
|
15
|
-
o.separator "options:"
|
16
|
-
o.on('-o', '--output-dir', 'folder to place the files in') { |b| $output_folder = b}
|
17
|
-
o.parse!
|
18
|
-
end
|
19
|
-
|
20
|
-
filename = ARGV[0]
|
21
|
-
|
22
|
-
if filename.nil?
|
23
|
-
puts 'an example file is required.'
|
24
|
-
puts options
|
25
|
-
exit(1)
|
26
|
-
end
|
27
|
-
|
28
|
-
example_body = ''
|
29
|
-
|
30
|
-
index = 0
|
31
|
-
File.open(filename, "r") do |f|
|
32
|
-
f.each_line do |line|
|
33
|
-
example_body << "#{line}\n"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
eval(example_body, binding, filename, 1)
|
38
|
-
|
39
|
-
# collect results
|
40
|
-
Pretentious.last_results.each do |g, result_per_generator|
|
41
|
-
puts "#{g}:"
|
42
|
-
result_per_generator.each do |klass, result|
|
43
|
-
output_folder = result[:generator].location(output_folder)
|
44
|
-
FileUtils.mkdir_p output_folder
|
45
|
-
result[:generator].helper(output_folder)
|
46
|
-
filename = result[:generator].naming(output_folder, klass)
|
47
|
-
File.open(filename, 'w') { |f| f.write(result[:output]) }
|
48
|
-
puts "#{filename}"
|
49
|
-
end
|
50
|
-
end
|