pretentious 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/pretentious/context.rb +31 -5
- data/lib/pretentious/minitest_generator.rb +2 -2
- data/lib/pretentious/rspec_generator.rb +8 -8
- data/lib/pretentious/version.rb +1 -1
- data/run_test.sh +1 -1
- data/spec/generated/test_class1_spec.rb +8 -11
- data/spec/generated/test_class2_spec.rb +0 -3
- data/spec/generated/test_class3_spec.rb +4 -4
- data/spec/generated/test_class4_spec.rb +3 -3
- data/spec/generated/test_class_for_auto_stub_spec.rb +1 -1
- data/spec/generated/test_class_for_mocks_spec.rb +4 -4
- data/spec/generator_spec.rb +13 -13
- data/spec/minitest_generator_spec.rb +1 -1
- data/spec/prententious_spec.rb +41 -9
- data/test/generated/test_fibonacci.rb +0 -70
- data/test/generated/test_m_d5.rb +0 -1
- data/test/generated/test_meme.rb +0 -2
- data/test/generated/test_test_class1.rb +8 -24
- data/test/generated/test_test_class2.rb +0 -10
- data/test/generated/test_test_class3.rb +4 -6
- data/test/generated/test_test_class4.rb +3 -3
- data/test/generated/test_test_class_for_mocks.rb +4 -9
- data/test_classes.rb +1 -1
- metadata +3 -8
- data/spec/generated/spec_helper.rb +0 -1
- data/test/generated/minitest_helper.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd9a7227d0c9e647c762d750c2fe37336b225ac4
|
4
|
+
data.tar.gz: 008e91daf0aa2e31f7c4e453909186c8e534d7f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6d24160b7215d81a453852dc9c93aadbe82c4d2927245bd7e7b71a1c38409c21ce7f640f289335659646cc29f4fde54904e3dc029336d48da40e3004a8f4ce9
|
7
|
+
data.tar.gz: 7ca8f91b6ae5005718451cc2786a581bf7947132ddc71c71c413cd9ae156b209eb76501ef59668866b49ad644097ad165db49d5ef5abe57b8ac1e552e0e7f269
|
data/CHANGELOG.md
CHANGED
data/lib/pretentious/context.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module Pretentious
|
2
2
|
# Contains references to scoped variables
|
3
3
|
class Context
|
4
|
+
# list of variable names to use. i j are not there on purpose
|
5
|
+
VARIABLE_NAMES = %w(a b c d e f g h k l m n o p q r s t u v w x y z)
|
6
|
+
|
4
7
|
attr_accessor :declared_names, :variable_map,
|
5
8
|
:previous_declarations
|
6
9
|
|
@@ -8,6 +11,7 @@ module Pretentious
|
|
8
11
|
@declared_names = declared_names
|
9
12
|
@variable_map = variable_map
|
10
13
|
@previous_declarations = previous_declarations
|
14
|
+
@current_name_dict = 0
|
11
15
|
end
|
12
16
|
|
13
17
|
def subcontext(declarations)
|
@@ -29,7 +33,7 @@ module Pretentious
|
|
29
33
|
end
|
30
34
|
|
31
35
|
def register_instance_variable(object_id)
|
32
|
-
@variable_map[object_id] = "@#{@previous_declarations[object_id]}" if @previous_declarations[object_id][0]!='@'
|
36
|
+
@variable_map[object_id] = "@#{@previous_declarations[object_id]}" if @previous_declarations[object_id][0] != '@'
|
33
37
|
end
|
34
38
|
|
35
39
|
def register(object_id, name)
|
@@ -43,16 +47,19 @@ module Pretentious
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def pick_name(object_id, value = :no_value_passed)
|
46
|
-
var_name = "var_#{object_id}"
|
47
|
-
|
48
50
|
object_id_to_declared_names = {}
|
49
51
|
|
50
52
|
if @declared_names
|
51
|
-
@declared_names.each
|
53
|
+
@declared_names.each do |k, v|
|
54
|
+
object_id_to_declared_names[v[:object_id]] = k if v
|
55
|
+
end
|
52
56
|
end
|
57
|
+
|
53
58
|
# return immediately if already mapped
|
54
59
|
return object_id_to_declared_names[object_id] if object_id_to_declared_names.include? object_id
|
55
60
|
|
61
|
+
var_name = "var_#{object_id}"
|
62
|
+
|
56
63
|
if !@variable_map.nil? && @variable_map.include?(object_id)
|
57
64
|
|
58
65
|
candidate_name = @variable_map[object_id].to_s
|
@@ -73,7 +80,16 @@ module Pretentious
|
|
73
80
|
|
74
81
|
end
|
75
82
|
else
|
76
|
-
|
83
|
+
v = nil
|
84
|
+
|
85
|
+
Kernel.loop do
|
86
|
+
v = provide_name
|
87
|
+
break if !@declared_names.key?(v) || v.nil?
|
88
|
+
end
|
89
|
+
|
90
|
+
var_name = v
|
91
|
+
|
92
|
+
@declared_names[var_name] = { count: 1, object_id: object_id }
|
77
93
|
end
|
78
94
|
|
79
95
|
var_name
|
@@ -82,5 +98,15 @@ module Pretentious
|
|
82
98
|
def value_of(value)
|
83
99
|
Pretentious.value_ize(self, value)
|
84
100
|
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def provide_name
|
105
|
+
if @current_name_dict < VARIABLE_NAMES.length
|
106
|
+
VARIABLE_NAMES[@current_name_dict].tap { @current_name_dict += 1 }
|
107
|
+
else
|
108
|
+
nil
|
109
|
+
end
|
110
|
+
end
|
85
111
|
end
|
86
112
|
end
|
@@ -150,8 +150,8 @@ module Pretentious
|
|
150
150
|
end
|
151
151
|
|
152
152
|
str << "#{indentation}# #{context_prefix}#{k} #{params_desc_str} should return #{block[:result]}\n"
|
153
|
-
str << "#{indentation}#{generate_expectation(context, fixture, k, block[:params], block[:block], block[:result])}\n
|
154
|
-
expectations << str
|
153
|
+
str << "#{indentation}#{generate_expectation(context, fixture, k, block[:params], block[:block], block[:result])}\n"
|
154
|
+
expectations << str unless expectations.include? str
|
155
155
|
end
|
156
156
|
end
|
157
157
|
expectations.join("\n")
|
@@ -1,4 +1,5 @@
|
|
1
1
|
module Pretentious
|
2
|
+
# Generator for RSPEC
|
2
3
|
class RspecGenerator < Pretentious::GeneratorBase
|
3
4
|
def begin_spec(test_class)
|
4
5
|
buffer('# This file was automatically generated by the pretentious gem')
|
@@ -56,10 +57,10 @@ module Pretentious
|
|
56
57
|
def generate_expectation(context, fixture, method, params, block, result)
|
57
58
|
output = ''
|
58
59
|
block_source = if !block.nil? && block.is_a?(Pretentious::RecordedProc)
|
59
|
-
|
60
|
+
get_block_source(context, block)
|
60
61
|
else
|
61
62
|
''
|
62
|
-
|
63
|
+
end
|
63
64
|
|
64
65
|
statement = if params.size > 0
|
65
66
|
"#{fixture}.#{method}(#{params_generator(context, params)})#{block_source}"
|
@@ -121,20 +122,19 @@ module Pretentious
|
|
121
122
|
|
122
123
|
expectations = []
|
123
124
|
method_calls.each_key do |k|
|
124
|
-
|
125
125
|
info_blocks_arr = method_calls[k]
|
126
126
|
|
127
127
|
info_blocks_arr.each do |block|
|
128
128
|
str = ''
|
129
129
|
params_desc_str = if block[:params].size > 0
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
"when passed #{desc_params(block)}"
|
131
|
+
else
|
132
|
+
''
|
133
|
+
end
|
134
134
|
|
135
135
|
buffer_to_string(str, "# #{context_prefix}#{k} #{params_desc_str} should return #{block[:result]}", 3)
|
136
136
|
buffer_inline_to_string(str, generate_expectation(context, fixture, k, block[:params], block[:block], block[:result]))
|
137
|
-
expectations << str
|
137
|
+
expectations << str unless expectations.include? str
|
138
138
|
end
|
139
139
|
end
|
140
140
|
buffer_inline_to_string(output, expectations.join("\n"))
|
data/lib/pretentious/version.rb
CHANGED
data/run_test.sh
CHANGED
@@ -21,26 +21,23 @@ RSpec.describe TestClass1 do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should pass current expectations' do
|
24
|
-
|
24
|
+
a = proc { |message|
|
25
25
|
@message
|
26
26
|
}
|
27
27
|
|
28
28
|
filewriter = nil
|
29
|
-
|
29
|
+
b = proc {
|
30
30
|
# Variable return values ... can't figure out what goes in here...
|
31
31
|
}
|
32
32
|
|
33
33
|
# TestClass1#print_message should return
|
34
34
|
expect(@fixture.print_message).to be_nil
|
35
35
|
|
36
|
-
# TestClass1#
|
37
|
-
expect(@fixture.
|
38
|
-
|
39
|
-
# TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000102fe47e8@example.rb:73>
|
40
|
-
expect(@fixture.set_block &var_2172599780).to eq(var_2172599780)
|
36
|
+
# TestClass1#set_block should return #<Pretentious::RecordedProc:0x0000000279b3f8@example.rb:73>
|
37
|
+
expect(@fixture.set_block &a).to eq(a)
|
41
38
|
|
42
|
-
# TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:
|
43
|
-
expect(@fixture.call_block &
|
39
|
+
# TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x000000028113c8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={21007100=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x000000028113c8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={21007100=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x000000028113c8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={21007100=>"message"}>}}
|
40
|
+
expect(@fixture.call_block &b).to eq(@message)
|
44
41
|
|
45
42
|
# TestClass1#something_is_wrong should return StandardError
|
46
43
|
expect { @fixture.something_is_wrong }.to raise_error
|
@@ -57,7 +54,7 @@ RSpec.describe TestClass1 do
|
|
57
54
|
|
58
55
|
it 'should pass current expectations' do
|
59
56
|
another_object = TestClass1.new('test')
|
60
|
-
# TestClass1#return_self when passed message = #<TestClass1:
|
57
|
+
# TestClass1#return_self when passed message = #<TestClass1:0x000000028113c8> should return #<TestClass1:0x000000028113c8>
|
61
58
|
expect(@fixture.return_self(another_object)).to eq(another_object)
|
62
59
|
end
|
63
60
|
end
|
@@ -69,7 +66,7 @@ RSpec.describe TestClass1 do
|
|
69
66
|
end
|
70
67
|
|
71
68
|
it 'should pass current expectations' do
|
72
|
-
# TestClass1#message should return #<TestClass1:
|
69
|
+
# TestClass1#message should return #<TestClass1:0x000000028113c8>
|
73
70
|
expect(@fixture.message).to eq(@message)
|
74
71
|
end
|
75
72
|
end
|
@@ -10,9 +10,6 @@ RSpec.describe TestClass2 do
|
|
10
10
|
it 'should pass current expectations' do
|
11
11
|
# TestClass2#print_message should return
|
12
12
|
expect(@fixture.print_message).to be_nil
|
13
|
-
|
14
|
-
# TestClass2#print_message should return
|
15
|
-
expect(@fixture.print_message).to be_nil
|
16
13
|
end
|
17
14
|
end
|
18
15
|
|
@@ -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
|
+
b = { 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(b)
|
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
|
+
b = { 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(b)
|
25
25
|
testclass2 = TestClass2.new('This is message 2', nil)
|
26
26
|
@fixture = TestClass3.new(testclass1, testclass2)
|
27
27
|
end
|
@@ -4,12 +4,12 @@ require 'spec_helper'
|
|
4
4
|
RSpec.describe TestClass4 do
|
5
5
|
context 'Scenario 1' do
|
6
6
|
before do
|
7
|
-
|
8
|
-
|
7
|
+
c = nil
|
8
|
+
d = 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(&d)
|
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
|
+
a = ['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
|
+
a = [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
|
+
a = { val: 1, str: 'hello world', message: 'a message' }
|
36
|
+
allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(a)
|
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(a)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
data/spec/generator_spec.rb
CHANGED
@@ -144,27 +144,27 @@ RSpec.describe Pretentious::Generator do
|
|
144
144
|
|
145
145
|
context "Pretentious::Generator#generate_for" do
|
146
146
|
around(:each) do |example|
|
147
|
-
Pretentious::Generator.test_generator= DummyGenerator
|
147
|
+
Pretentious::Generator.test_generator = DummyGenerator
|
148
148
|
example.run
|
149
|
-
Pretentious::Generator.test_generator= nil
|
149
|
+
Pretentious::Generator.test_generator = nil
|
150
150
|
end
|
151
151
|
|
152
152
|
it "generates call artifacts for target class" do
|
153
153
|
call_artifacts = Pretentious::Generator.generate_for(TestClass) do
|
154
154
|
instance = TestClass.new
|
155
|
-
instance.message(
|
155
|
+
instance.message('hello')
|
156
156
|
end
|
157
157
|
|
158
|
-
expect(call_artifacts).to eq(
|
159
|
-
[{:
|
160
|
-
{:
|
161
|
-
|
162
|
-
[{:
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
158
|
+
expect(call_artifacts).to eq(TestClass => { output:
|
159
|
+
[{ begin: TestClass },
|
160
|
+
{ instance: 'TestClassImpostor',
|
161
|
+
instance_method_calls:
|
162
|
+
[{ method: :message,
|
163
|
+
params: ["hello"],
|
164
|
+
block: nil,
|
165
|
+
names: [[:req, :params1]],
|
166
|
+
context: {calls: []}, result: 'hello'}],
|
167
|
+
instance_count: 1}, :end], generator: DummyGenerator})
|
168
168
|
end
|
169
169
|
|
170
170
|
context "auto mocks generator" do
|
@@ -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 FibonacciTest < Minitest::Test\nend\n\nclass FibonacciScenario1 < FibonacciTest\n def test_current_expectation\n # Fibonacci::say_hello should return hello\n assert_equal 'hello', Fibonacci.say_hello\n end\n\nend\n",
|
22
22
|
generator: Pretentious::MinitestGenerator })
|
23
23
|
end
|
24
24
|
|
data/spec/prententious_spec.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Pretentious::Generator do
|
4
|
-
|
5
4
|
context 'Pretentious::Generator' do
|
6
|
-
|
7
5
|
before do
|
8
6
|
@fixture = Pretentious::Generator.new
|
9
7
|
Pretentious::Generator.test_generator = Pretentious::RspecGenerator
|
10
8
|
end
|
11
9
|
|
12
|
-
|
13
10
|
it "uses instance variables when used both in test and in fixtures" do
|
14
11
|
call_artifacts = Pretentious::Generator.generate_for(TestClass1) do
|
15
12
|
message = {test: "message"}
|
@@ -39,20 +36,56 @@ RSpec.describe Pretentious::Generator do
|
|
39
36
|
expect(fib.fib(6)).to eq(8)
|
40
37
|
|
41
38
|
expect(result).to eq(
|
42
|
-
Fibonacci => { output:"# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n it 'should pass current expectations' do\n # Fibonacci::say_hello should return hello\n expect(Fibonacci.say_hello).to eq('hello')\n end\n\nend\n",
|
39
|
+
Fibonacci => { output: "# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n it 'should pass current expectations' do\n # Fibonacci::say_hello should return hello\n expect(Fibonacci.say_hello).to eq('hello')\n end\n\nend\n",
|
43
40
|
generator: Pretentious::RspecGenerator })
|
44
41
|
end
|
45
42
|
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
it 'Makes sure expectations are unique' do
|
45
|
+
result = Pretentious.spec_for(TestClass1) do
|
46
|
+
test_class = TestClass1.new("message")
|
47
|
+
test_class.message
|
48
|
+
test_class.message
|
49
|
+
end
|
50
|
+
expect(result[TestClass1][:output]
|
51
|
+
.scan(/expect\(@fixture.message\).to eq\('message'\)/).count)
|
52
|
+
.to eq(1)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "handles exceptions" do
|
56
|
+
result = Pretentious.spec_for(TestClass1) do
|
57
|
+
test_class = TestClass1.new('message')
|
58
|
+
begin
|
59
|
+
test_class.something_is_wrong
|
60
|
+
rescue StandardError => e
|
61
|
+
puts 'something is wrong'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
expect(result[TestClass1][:output]).to match('expect { @fixture.something_is_wrong }.to raise_error')
|
66
|
+
end
|
67
|
+
|
68
|
+
context "proc handling" do
|
69
|
+
it 'handles blocks passed to methods' do
|
70
|
+
result = Pretentious.spec_for(TestClass1) do
|
71
|
+
test_class = TestClass1.new('message')
|
72
|
+
test_class.set_block do
|
73
|
+
'a string'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
expect(result[TestClass1][:output]).to be < 'expect(@fixture.set_block &c).to eq(a)'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'unobstrusive generator' do
|
81
|
+
it 'declare watched classes beforehand and capture when certain methods are invoked' do
|
82
|
+
# declare intention
|
50
83
|
Pretentious.on(TestClass5).method_called(:test_method).spec_for(Fibonacci) do |results|
|
51
84
|
expect(results[Fibonacci][:output]).to eq("# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n context 'Scenario 1' do\n before do\n @fixture = Fibonacci.new\n end\n\n it 'should pass current expectations' do\n # Fibonacci#fib when passed n = 5 should return 5\n expect(@fixture.fib(5)).to eq(5)\n end\n end\n\nend\n")
|
52
85
|
end
|
53
86
|
|
54
87
|
expect(Pretentious::Generator).to receive(:generate_for).with(Fibonacci).and_call_original
|
55
|
-
#execute code
|
88
|
+
# execute code
|
56
89
|
class_that_uses_fib = TestClass5.new
|
57
90
|
result = class_that_uses_fib.test_method
|
58
91
|
expect(result).to eq(5)
|
@@ -90,7 +123,6 @@ RSpec.describe Pretentious::Generator do
|
|
90
123
|
|
91
124
|
expect(result1).to eq(5)
|
92
125
|
expect(result2).to eq(34)
|
93
|
-
|
94
126
|
end
|
95
127
|
end
|
96
128
|
end
|
@@ -19,83 +19,14 @@ class FibonacciScenario1 < FibonacciTest
|
|
19
19
|
|
20
20
|
# Fibonacci#fib when passed n = 1 should return 1
|
21
21
|
assert_equal 1, @fixture.fib(n)
|
22
|
-
|
23
|
-
# Fibonacci#fib when passed n = 2 should return 1
|
24
|
-
assert_equal 1, @fixture.fib(n_1)
|
25
|
-
|
26
|
-
# Fibonacci#fib when passed n = 3 should return 2
|
27
|
-
assert_equal 2, @fixture.fib(n_2)
|
28
|
-
|
29
|
-
# Fibonacci#fib when passed n = 4 should return 3
|
30
|
-
assert_equal 3, @fixture.fib(n_3)
|
31
|
-
|
32
|
-
# Fibonacci#fib when passed n = 5 should return 5
|
33
|
-
assert_equal 5, @fixture.fib(n_4)
|
34
|
-
|
35
|
-
|
36
|
-
# Fibonacci#fib when passed n = 1 should return 1
|
37
|
-
assert_equal 1, @fixture.fib(n)
|
38
|
-
|
39
|
-
# Fibonacci#fib when passed n = 2 should return 1
|
40
|
-
assert_equal 1, @fixture.fib(n_1)
|
41
|
-
|
42
|
-
# Fibonacci#fib when passed n = 3 should return 2
|
43
|
-
assert_equal 2, @fixture.fib(n_2)
|
44
|
-
|
45
|
-
# Fibonacci#fib when passed n = 4 should return 3
|
46
|
-
assert_equal 3, @fixture.fib(n_3)
|
47
|
-
|
48
|
-
# Fibonacci#fib when passed n = 5 should return 5
|
49
|
-
assert_equal 5, @fixture.fib(n_4)
|
50
|
-
|
51
|
-
|
52
|
-
# Fibonacci#fib when passed n = 1 should return 1
|
53
|
-
assert_equal 1, @fixture.fib(n)
|
54
|
-
|
55
|
-
# Fibonacci#fib when passed n = 2 should return 1
|
56
|
-
assert_equal 1, @fixture.fib(n_1)
|
57
|
-
|
58
|
-
# Fibonacci#fib when passed n = 3 should return 2
|
59
|
-
assert_equal 2, @fixture.fib(n_2)
|
60
|
-
|
61
|
-
# Fibonacci#fib when passed n = 4 should return 3
|
62
|
-
assert_equal 3, @fixture.fib(n_3)
|
63
|
-
|
64
|
-
# Fibonacci#fib when passed n = 5 should return 5
|
65
|
-
assert_equal 5, @fixture.fib(n_4)
|
66
|
-
|
67
|
-
|
68
|
-
# Fibonacci#fib when passed n = 1 should return 1
|
69
|
-
assert_equal 1, @fixture.fib(n)
|
70
|
-
|
71
22
|
# Fibonacci#fib when passed n = 2 should return 1
|
72
23
|
assert_equal 1, @fixture.fib(n_1)
|
73
|
-
|
74
24
|
# Fibonacci#fib when passed n = 3 should return 2
|
75
25
|
assert_equal 2, @fixture.fib(n_2)
|
76
|
-
|
77
26
|
# Fibonacci#fib when passed n = 4 should return 3
|
78
27
|
assert_equal 3, @fixture.fib(n_3)
|
79
|
-
|
80
28
|
# Fibonacci#fib when passed n = 5 should return 5
|
81
29
|
assert_equal 5, @fixture.fib(n_4)
|
82
|
-
|
83
|
-
|
84
|
-
# Fibonacci#fib when passed n = 1 should return 1
|
85
|
-
assert_equal 1, @fixture.fib(n)
|
86
|
-
|
87
|
-
# Fibonacci#fib when passed n = 2 should return 1
|
88
|
-
assert_equal 1, @fixture.fib(n_1)
|
89
|
-
|
90
|
-
# Fibonacci#fib when passed n = 3 should return 2
|
91
|
-
assert_equal 2, @fixture.fib(n_2)
|
92
|
-
|
93
|
-
# Fibonacci#fib when passed n = 4 should return 3
|
94
|
-
assert_equal 3, @fixture.fib(n_3)
|
95
|
-
|
96
|
-
# Fibonacci#fib when passed n = 5 should return 5
|
97
|
-
assert_equal 5, @fixture.fib(n_4)
|
98
|
-
|
99
30
|
end
|
100
31
|
end
|
101
32
|
|
@@ -103,7 +34,6 @@ class FibonacciScenario2 < FibonacciTest
|
|
103
34
|
def test_current_expectation
|
104
35
|
# Fibonacci::say_hello should return hello
|
105
36
|
assert_equal 'hello', Fibonacci.say_hello
|
106
|
-
|
107
37
|
end
|
108
38
|
|
109
39
|
end
|
data/test/generated/test_m_d5.rb
CHANGED
data/test/generated/test_meme.rb
CHANGED
@@ -14,10 +14,8 @@ class MemeScenario1 < MemeTest
|
|
14
14
|
# Meme#i_can_has_cheezburger? should return OHAI!
|
15
15
|
assert_equal 'OHAI!', @fixture.i_can_has_cheezburger?
|
16
16
|
|
17
|
-
|
18
17
|
# Meme#will_it_blend? should return YES!
|
19
18
|
assert_equal 'YES!', @fixture.will_it_blend?
|
20
|
-
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
@@ -13,7 +13,6 @@ class TestClass1Scenario1 < TestClass1Test
|
|
13
13
|
def test_current_expectation
|
14
14
|
# TestClass1#message should return test
|
15
15
|
assert_equal 'test', @fixture.message
|
16
|
-
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
@@ -25,45 +24,32 @@ class TestClass1Scenario2 < TestClass1Test
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def test_current_expectation
|
28
|
-
|
27
|
+
a = proc { |message|
|
29
28
|
@message
|
30
29
|
}
|
31
30
|
|
32
31
|
filewriter = nil
|
33
|
-
|
32
|
+
b = proc {
|
34
33
|
# Variable return values ... can't figure out what goes in here...
|
35
34
|
}
|
36
35
|
|
37
36
|
|
38
37
|
# TestClass1#print_message should return
|
39
38
|
assert_nil @fixture.print_message
|
40
|
-
|
41
|
-
# TestClass1#print_message should return
|
42
|
-
assert_nil @fixture.print_message
|
43
|
-
|
44
|
-
|
45
|
-
# TestClass1#print_message should return
|
46
|
-
assert_nil @fixture.print_message
|
47
|
-
|
48
39
|
# TestClass1#print_message should return
|
49
40
|
assert_nil @fixture.print_message
|
50
41
|
|
42
|
+
# TestClass1#set_block should return #<Pretentious::RecordedProc:0x000000024c54d0@example.rb:73>
|
43
|
+
assert_equal a, @fixture.set_block( &a)
|
51
44
|
|
52
|
-
# TestClass1#
|
53
|
-
assert_equal
|
54
|
-
|
55
|
-
|
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
|
-
|
45
|
+
# TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x00000002692ee8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={20224160=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x00000002692ee8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={20224160=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x00000002692ee8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={20224160=>"message"}>}}
|
46
|
+
assert_equal @message, @fixture.call_block( &b)
|
59
47
|
|
60
48
|
# TestClass1#something_is_wrong should return StandardError
|
61
49
|
assert_raises(StandardError) { @fixture.something_is_wrong }
|
62
50
|
|
63
|
-
|
64
51
|
# TestClass1#just_returns_true should return true
|
65
52
|
assert @fixture.just_returns_true
|
66
|
-
|
67
53
|
end
|
68
54
|
end
|
69
55
|
|
@@ -75,9 +61,8 @@ class TestClass1Scenario3 < TestClass1Test
|
|
75
61
|
def test_current_expectation
|
76
62
|
another_object = TestClass1.new('test')
|
77
63
|
|
78
|
-
# TestClass1#return_self when passed message = #<TestClass1:
|
64
|
+
# TestClass1#return_self when passed message = #<TestClass1:0x00000002692ee8> should return #<TestClass1:0x00000002692ee8>
|
79
65
|
assert_equal another_object, @fixture.return_self(another_object)
|
80
|
-
|
81
66
|
end
|
82
67
|
end
|
83
68
|
|
@@ -88,9 +73,8 @@ class TestClass1Scenario4 < TestClass1Test
|
|
88
73
|
end
|
89
74
|
|
90
75
|
def test_current_expectation
|
91
|
-
# TestClass1#message should return #<TestClass1:
|
76
|
+
# TestClass1#message should return #<TestClass1:0x00000002692ee8>
|
92
77
|
assert_equal @message, @fixture.message
|
93
|
-
|
94
78
|
end
|
95
79
|
end
|
96
80
|
|
@@ -13,17 +13,8 @@ class TestClass2Scenario1 < TestClass2Test
|
|
13
13
|
def test_current_expectation
|
14
14
|
# TestClass2#print_message should return
|
15
15
|
assert_nil @fixture.print_message
|
16
|
-
|
17
|
-
# TestClass2#print_message should return
|
18
|
-
assert_nil @fixture.print_message
|
19
|
-
|
20
|
-
|
21
16
|
# TestClass2#print_message should return
|
22
17
|
assert_nil @fixture.print_message
|
23
|
-
|
24
|
-
# TestClass2#print_message should return
|
25
|
-
assert_nil @fixture.print_message
|
26
|
-
|
27
18
|
end
|
28
19
|
end
|
29
20
|
|
@@ -46,7 +37,6 @@ class TestClass2Scenario3 < TestClass2Test
|
|
46
37
|
def test_current_expectation
|
47
38
|
# TestClass2#test when passed object = "This is message 3" should return This is message 3
|
48
39
|
assert_equal 'This is message 3', @fixture.test(@message2)
|
49
|
-
|
50
40
|
end
|
51
41
|
end
|
52
42
|
|
@@ -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
|
+
b = { 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(b)
|
13
13
|
testclass2 = TestClass2.new('This is message 2', nil)
|
14
14
|
@fixture = TestClass3.new(testclass1, testclass2)
|
15
15
|
end
|
@@ -17,15 +17,14 @@ class TestClass3Scenario1 < TestClass3Test
|
|
17
17
|
def test_current_expectation
|
18
18
|
# TestClass3#show_messages should return awesome!!!
|
19
19
|
assert_equal 'awesome!!!', @fixture.show_messages
|
20
|
-
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
23
|
class TestClass3Scenario2 < TestClass3Test
|
25
24
|
def setup
|
26
25
|
another_object = TestClass1.new('test')
|
27
|
-
|
28
|
-
testclass1 = TestClass1.new(
|
26
|
+
b = { hello: 'world', test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: { yes: true, obj: another_object } }
|
27
|
+
testclass1 = TestClass1.new(b)
|
29
28
|
testclass2 = TestClass2.new('This is message 2', nil)
|
30
29
|
@fixture = TestClass3.new(testclass1, testclass2)
|
31
30
|
end
|
@@ -33,7 +32,6 @@ class TestClass3Scenario2 < TestClass3Test
|
|
33
32
|
def test_current_expectation
|
34
33
|
# TestClass3#show_messages should return awesome!!!
|
35
34
|
assert_equal 'awesome!!!', @fixture.show_messages
|
36
|
-
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
@@ -7,12 +7,12 @@ end
|
|
7
7
|
|
8
8
|
class TestClass4Scenario1 < TestClass4Test
|
9
9
|
def setup
|
10
|
-
|
11
|
-
|
10
|
+
c = nil
|
11
|
+
d = 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(&d)
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_current_expectation
|
@@ -11,25 +11,21 @@ class TestClassForMocksScenario1 < TestClassForMocksTest
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_current_expectation
|
14
|
-
|
14
|
+
a = [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
|
18
18
|
# TestClassForMocks#method_with_assign= when passed params2 = "test" should return test
|
19
19
|
assert_equal 'test', @fixture.method_with_assign=('test')
|
20
20
|
|
21
|
-
|
22
21
|
# TestClassForMocks#method_with_usage should return a return string
|
23
22
|
assert_equal 'a return string', @fixture.method_with_usage
|
24
23
|
|
25
|
-
|
26
24
|
# TestClassForMocks#method_with_usage2 should return [2, 3, 4, 5]
|
27
25
|
assert_equal [2, 3, 4, 5], @fixture.method_with_usage2
|
28
26
|
|
29
|
-
|
30
27
|
# TestClassForMocks#method_with_usage4 should return a return string
|
31
28
|
assert_equal 'a return string', @fixture.method_with_usage4
|
32
|
-
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
@@ -42,12 +38,11 @@ class TestClassForMocksScenario2 < TestClassForMocksTest
|
|
42
38
|
end
|
43
39
|
|
44
40
|
def test_current_expectation
|
45
|
-
|
41
|
+
a = { val: 1, str: 'hello world', message: 'a message' }
|
46
42
|
|
47
|
-
TestMockSubClass.stub_any_instance(:return_hash,
|
43
|
+
TestMockSubClass.stub_any_instance(:return_hash, a) do
|
48
44
|
# TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
|
49
|
-
assert_equal
|
50
|
-
|
45
|
+
assert_equal a, @fixture.method_with_usage3('a message')
|
51
46
|
end
|
52
47
|
|
53
48
|
end
|
data/test_classes.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.9
|
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-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|
@@ -184,7 +184,6 @@ files:
|
|
184
184
|
- spec/deconstructor_spec.rb
|
185
185
|
- spec/generated/fibonacci_spec.rb
|
186
186
|
- spec/generated/m_d5_spec.rb
|
187
|
-
- spec/generated/spec_helper.rb
|
188
187
|
- spec/generated/test_class1_spec.rb
|
189
188
|
- spec/generated/test_class2_spec.rb
|
190
189
|
- spec/generated/test_class3_spec.rb
|
@@ -196,7 +195,6 @@ files:
|
|
196
195
|
- spec/prententious_spec.rb
|
197
196
|
- spec/spec_helper.rb
|
198
197
|
- spec/utils/filewriter_spec.rb
|
199
|
-
- test/generated/minitest_helper.rb
|
200
198
|
- test/generated/test_fibonacci.rb
|
201
199
|
- test/generated/test_m_d5.rb
|
202
200
|
- test/generated/test_meme.rb
|
@@ -228,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
226
|
version: '0'
|
229
227
|
requirements: []
|
230
228
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.
|
229
|
+
rubygems_version: 2.4.8
|
232
230
|
signing_key:
|
233
231
|
specification_version: 4
|
234
232
|
summary: Characterization Tests generator for Ruby - Generate tests from existing/legacy
|
@@ -237,7 +235,6 @@ test_files:
|
|
237
235
|
- spec/deconstructor_spec.rb
|
238
236
|
- spec/generated/fibonacci_spec.rb
|
239
237
|
- spec/generated/m_d5_spec.rb
|
240
|
-
- spec/generated/spec_helper.rb
|
241
238
|
- spec/generated/test_class1_spec.rb
|
242
239
|
- spec/generated/test_class2_spec.rb
|
243
240
|
- spec/generated/test_class3_spec.rb
|
@@ -249,7 +246,6 @@ test_files:
|
|
249
246
|
- spec/prententious_spec.rb
|
250
247
|
- spec/spec_helper.rb
|
251
248
|
- spec/utils/filewriter_spec.rb
|
252
|
-
- test/generated/minitest_helper.rb
|
253
249
|
- test/generated/test_fibonacci.rb
|
254
250
|
- test/generated/test_m_d5.rb
|
255
251
|
- test/generated/test_meme.rb
|
@@ -260,4 +256,3 @@ test_files:
|
|
260
256
|
- test/generated/test_test_class_for_mocks.rb
|
261
257
|
- test/minitest_helper.rb
|
262
258
|
- test/test_generator.rb
|
263
|
-
has_rdoc:
|
@@ -1 +0,0 @@
|
|
1
|
-
# Place your requires here
|