pretentious 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cb9f74b26ae3f015b82651f96310897cfeba69f
4
- data.tar.gz: 19e78abb1da16f1963bf9a4e5a16d6f96f2450b3
3
+ metadata.gz: df840911bcf0942d55b16a3d9ea80370ad48eca6
4
+ data.tar.gz: a284d31fb92dff010cb9b2a6459c26d34999caad
5
5
  SHA512:
6
- metadata.gz: 2022904496f859df817cf11355e7601a736d4d019cb56341e4c9d3273544dc0d442dc3b25badabd46d935157620376432856a092ed9fb0238e2d5fb8479846bd
7
- data.tar.gz: e02a0108fa7d9ae7c23c920d98d5f5da32adcf2a3ebce679804c3900496b0aeb701e97070baf9522cea3a8706e78c5035e04b6887df433c7aa522237c28480a5
6
+ metadata.gz: 50dce499f2f088060d5e402c5c17b77be27c7ff8a5c0c5eaba60d735a91ea82459638a17a4fa2a2b55668d3520ffeeba31b716e8a986e38fb8b248a3233c7236
7
+ data.tar.gz: c94a2fffcb644a0ccc4c83a77e923ceb11f96c3fc01fa9ceedfe5a1d43c33f12590db719d5eaf96767249c4030165d2ec57fc709223c7b20d9162f0f4645b460
data/Rakefile CHANGED
@@ -7,7 +7,8 @@ RSpec::Core::RakeTask.new('spec')
7
7
  task :default => :spec
8
8
  task :test => :spec
9
9
 
10
+ desc "Runs the minitest suite"
10
11
  task :minitest do
11
12
  $: << './test'
12
13
  Dir.glob('./test/test_*.rb').each { |file| require file}
13
- end
14
+ end
data/example.rb CHANGED
@@ -57,6 +57,9 @@ end
57
57
 
58
58
  test_class_object_return = TestClass1.new("Hello")
59
59
  test_class_object_return.return_self(another_object)
60
+
61
+ test_class1 = TestClass1.new(another_object)
62
+ test_class1.message
60
63
  end
61
64
  end
62
65
 
@@ -193,7 +193,14 @@ class Pretentious::Deconstructor
193
193
  {declaration: @declaration_order, dependency: @dependencies}
194
194
  end
195
195
 
196
- def deconstruct_to_ruby(indentation_level = 0, variable_map = {}, declared_names = {}, method_call_collection = [], *target_objects)
196
+ def generate_declarations(variable_map = {}, previous_declarations = {}, method_call_collection = [], *target_objects)
197
+ target_objects.each { |target_object|
198
+ variable_map.merge!(target_object._variable_map) if target_object.methods.include?(:_variable_map) && !target_object._variable_map.nil?
199
+ }
200
+ deconstruct method_call_collection, *target_objects
201
+ end
202
+
203
+ def build_output(indentation_level, variable_map, declarations, declared_names, previous_declarations)
197
204
  output_buffer = ""
198
205
  indentation = ""
199
206
 
@@ -201,21 +208,22 @@ class Pretentious::Deconstructor
201
208
  indentation << ' '
202
209
  }
203
210
 
204
- target_objects.each { |target_object|
205
- variable_map.merge!(target_object._variable_map) if target_object.methods.include?(:_variable_map) && !target_object._variable_map.nil?
206
- }
207
- declarations, dependencies = deconstruct method_call_collection, *target_objects
208
-
209
211
  declarations[:declaration].each do |d|
210
- unless d[:used_by] == :inline
212
+ if (d[:used_by] != :inline) && !previous_declarations.has_key?(d[:id])
211
213
  var_name = Pretentious::Deconstructor.pick_name(variable_map, d[:id], declared_names)
212
214
  output_buffer << "#{indentation}#{var_name} = #{construct(d, variable_map, declared_names, indentation)}\n"
215
+ elsif (d[:used_by]!=:inline) && previous_declarations[d[:id]]
216
+ variable_map[d[:id]] = "@#{previous_declarations[d[:id]]}" if previous_declarations[d[:id]][0]!='@'
213
217
  end
214
218
  end
215
-
216
219
  output_buffer
217
220
  end
218
221
 
222
+ def deconstruct_to_ruby(indentation_level = 0, variable_map = {}, declared_names = {}, previous_declarations = {}, method_call_collection = [], *target_objects)
223
+ declarations, dependencies = generate_declarations variable_map, previous_declarations, method_call_collection, *target_objects
224
+ build_output(indentation_level, variable_map, declarations, declared_names, previous_declarations)
225
+ end
226
+
219
227
  def self.is_primitive?(value)
220
228
  value.is_a?(String) || value.is_a?(Fixnum) || value.is_a?(TrueClass) || value.is_a?(FalseClass) ||
221
229
  value.is_a?(NilClass) || value.is_a?(Symbol) || value.is_a?(Class)
@@ -103,7 +103,7 @@ module Pretentious
103
103
  end
104
104
 
105
105
  def init_let_variables
106
- @_init_let_variables
106
+ @_init_let_variables.dup
107
107
  end
108
108
 
109
109
  def method_calls_by_method
@@ -179,7 +179,7 @@ module Pretentious
179
179
  end
180
180
 
181
181
  def let_variables
182
- @_let_variables
182
+ @_let_variables.dup
183
183
  end
184
184
 
185
185
  def method_calls_by_method
@@ -441,7 +441,7 @@ module Pretentious
441
441
  end
442
442
 
443
443
  def _variable_map
444
- @_variable_names || {}
444
+ (@_variable_names || {}).dup
445
445
  end
446
446
 
447
447
  def _deconstruct
@@ -462,7 +462,7 @@ module Pretentious
462
462
  }
463
463
 
464
464
  variable_names = _variable_map.merge({self.object_id => var_name}) unless var_name.nil?
465
- Pretentious::Deconstructor.new().deconstruct_to_ruby(indentation, variable_names, {}, [], self)
465
+ Pretentious::Deconstructor.new().deconstruct_to_ruby(indentation, variable_names, {}, {}, [], self)
466
466
  end
467
467
 
468
468
  end
@@ -5,9 +5,29 @@ module Pretentious
5
5
  @output_buffer << "#{indentation(level)}#{line}\n"
6
6
  end
7
7
 
8
+ def buffer_to_string(buffer, line, level = 0)
9
+ buffer << "#{indentation(level)}#{line}\n"
10
+ end
11
+
8
12
  def buffer_inline(line, level = 0)
9
13
  @output_buffer << "#{indentation(level)}#{line}"
10
14
  end
11
15
 
16
+ def setup_fixture(fixture)
17
+ variable_map = fixture.let_variables.merge({ fixture.object_id => '@fixture'})
18
+ top_declarations = {}
19
+ global_declared_names = {}
20
+
21
+ declarations, dependencies = @deconstructor.generate_declarations(variable_map, {}, [], fixture)
22
+
23
+ declarations[:declaration].each do |d|
24
+ if (d[:used_by] != :inline)
25
+ top_declarations[d[:id]] = Pretentious::Deconstructor.pick_name(variable_map, d[:id], global_declared_names)
26
+ end
27
+ end
28
+
29
+ [top_declarations, declarations, variable_map, global_declared_names]
30
+ end
31
+
12
32
  end
13
33
  end
@@ -41,21 +41,28 @@ class Pretentious::MinitestGenerator < Pretentious::GeneratorBase
41
41
  end
42
42
 
43
43
  def generate(test_instance, instance_count)
44
+ global_variable_declaration = {}
44
45
  if (test_instance.is_a? Class)
45
46
  #class methods
46
47
  class_method_calls = test_instance.method_calls_by_method
47
- generate_specs("#{test_instance.test_class.name}::",test_instance.test_class.name, class_method_calls, test_instance.let_variables)
48
+ buffer(generate_specs("#{test_instance.test_class.name}::",test_instance.test_class.name, class_method_calls, test_instance.let_variables,
49
+ global_variable_declaration, {}))
48
50
  else
49
51
  buffer("class #{test_instance.test_class.name}Scenario#{instance_count} < Test#{@test_class.name}",0)
50
52
 
51
53
  buffer("def setup",1)
52
- buffer_inline(test_instance._deconstruct_to_ruby('@fixture', 2 * @_indentation.length))
53
- buffer("end", 1)
54
- whitespace
54
+
55
+
56
+ top_declarations, declarations, variable_map, global_declared_names = setup_fixture(test_instance)
55
57
 
56
58
  method_calls = test_instance.method_calls_by_method
59
+ specs_buffer = generate_specs("#{test_instance.test_class.name}#", "@fixture", method_calls, variable_map,
60
+ global_variable_declaration, top_declarations)
61
+ buffer_inline(@deconstructor.build_output(3 * @_indentation.length, variable_map, declarations, global_variable_declaration, {}))
62
+ buffer("end", 1)
63
+ whitespace
57
64
 
58
- generate_specs("#{test_instance.test_class.name}#","@fixture",method_calls, test_instance.let_variables)
65
+ buffer_inline(specs_buffer)
59
66
 
60
67
  buffer('end',0)
61
68
  whitespace
@@ -106,9 +113,9 @@ class Pretentious::MinitestGenerator < Pretentious::GeneratorBase
106
113
  str
107
114
  end
108
115
 
109
- def generate_specs(context_prefix, fixture, method_calls, let_variables)
110
- buffer("def test_current_expectation",1)
111
- declaration = {}
116
+ def generate_specs(context_prefix, fixture, method_calls, let_variables, declaration, previous_declaration)
117
+ output = ""
118
+ buffer_to_string(output, "def test_current_expectation", 1)
112
119
  #collect all params
113
120
  params_collection = []
114
121
  mocks_collection = {}
@@ -143,18 +150,20 @@ class Pretentious::MinitestGenerator < Pretentious::GeneratorBase
143
150
  end
144
151
 
145
152
  if (params_collection.size > 0)
146
- buffer(declare_dependencies(params_collection, let_variables, 2, declaration))
153
+ deps = declare_dependencies(params_collection, let_variables, 2, declaration, previous_declaration)
154
+ buffer_to_string(output, deps) if deps.strip!=''
147
155
  end
148
156
 
149
157
  if (mocks_collection.keys.size > 0)
150
- buffer(generate_minitest_stub(mocks_collection, let_variables, 2, declaration) { |indentation|
158
+ buffer_to_string(output, generate_minitest_stub(mocks_collection, let_variables, 2, declaration) { |indentation|
151
159
  generate_test_scenarios(fixture, method_calls, context_prefix, let_variables, declaration, indentation)
152
- },0)
160
+ }, 0)
153
161
  else
154
- buffer(generate_test_scenarios(fixture, method_calls, context_prefix, let_variables, declaration, 2), 0)
162
+ buffer_to_string(output, generate_test_scenarios(fixture, method_calls, context_prefix, let_variables, declaration, 2), 0)
155
163
  end
156
164
 
157
- buffer("end", 1)
165
+ buffer_to_string(output, "end", 1)
166
+ output
158
167
  end
159
168
 
160
169
  def generate_test_scenarios(fixture, method_calls, context_prefix, let_variables, declaration, indentation_level)
@@ -278,11 +287,11 @@ class Pretentious::MinitestGenerator < Pretentious::GeneratorBase
278
287
  params.join(" ,")
279
288
  end
280
289
 
281
- def declare_dependencies(args, variable_map, level, declarations)
290
+ def declare_dependencies(args, variable_map, level, declarations, previous_declaration)
282
291
  deconstructor = Pretentious::Deconstructor.new
283
292
 
284
293
  args = remove_primitives(args, variable_map)
285
- deconstructor.deconstruct_to_ruby(level * @_indentation.length, variable_map, declarations, [], *args)
294
+ deconstructor.deconstruct_to_ruby(level * @_indentation.length, variable_map, declarations, previous_declaration, [], *args)
286
295
  end
287
296
 
288
297
  def remove_primitives(args, let_lookup)
@@ -40,23 +40,25 @@ class Pretentious::RspecGenerator < Pretentious::GeneratorBase
40
40
  end
41
41
 
42
42
  def generate(test_instance, instance_count)
43
+ global_variable_declaration = {}
43
44
  if (test_instance.is_a? Class)
44
45
  #class methods
45
46
  class_method_calls = test_instance.method_calls_by_method
46
- generate_specs("#{test_instance.test_class.name}::", test_instance.test_class.name,
47
- class_method_calls, test_instance.let_variables)
47
+ buffer(generate_specs("#{test_instance.test_class.name}::", test_instance.test_class.name,
48
+ class_method_calls, test_instance.let_variables, global_variable_declaration, {}))
48
49
  else
49
50
  buffer("context 'Scenario #{instance_count}' do",1)
50
51
 
51
52
  buffer("before do",2)
52
- buffer_inline(test_instance._deconstruct_to_ruby('@fixture', 3 * @_indentation.length))
53
- buffer("end",2)
54
- whitespace
55
53
 
54
+ top_declarations, declarations, variable_map, global_declared_names = setup_fixture(test_instance)
56
55
  method_calls = test_instance.method_calls_by_method
57
-
58
- generate_specs("#{test_instance.test_class.name}#","@fixture",method_calls, test_instance.let_variables)
59
-
56
+ specs_buffer = generate_specs("#{test_instance.test_class.name}#", "@fixture", method_calls, variable_map,
57
+ global_variable_declaration, top_declarations)
58
+ buffer_inline(@deconstructor.build_output(3 * @_indentation.length, variable_map, declarations, global_variable_declaration, {}))
59
+ buffer("end",2)
60
+ whitespace
61
+ buffer(specs_buffer)
60
62
  buffer('end',1)
61
63
  whitespace
62
64
  end
@@ -81,6 +83,7 @@ class Pretentious::RspecGenerator < Pretentious::GeneratorBase
81
83
  end
82
84
 
83
85
  def generate_expectation(fixture, method, let_variables, declarations, params, block, result)
86
+ output = ""
84
87
  block_source = if !block.nil? && block.is_a?(Pretentious::RecordedProc)
85
88
  get_block_source(block, let_variables, declarations, @_indentation * 3)
86
89
  else
@@ -97,15 +100,16 @@ class Pretentious::RspecGenerator < Pretentious::GeneratorBase
97
100
  end
98
101
 
99
102
  if (result.kind_of? Exception)
100
- buffer("expect { #{statement} }.to #{pick_matcher(result, let_variables, declarations)}",3)
103
+ buffer_to_string(output, "expect { #{statement} }.to #{pick_matcher(result, let_variables, declarations)}",3)
101
104
  else
102
- buffer("expect( #{statement} ).to #{pick_matcher(result, let_variables, declarations)}",3)
105
+ buffer_to_string(output, "expect( #{statement} ).to #{pick_matcher(result, let_variables, declarations)}",3)
103
106
  end
107
+ output
104
108
  end
105
109
 
106
- def generate_specs(context_prefix, fixture, method_calls, let_variables)
107
- buffer("it 'should pass current expectations' do",2)
108
- declaration = {}
110
+ def generate_specs(context_prefix, fixture, method_calls, let_variables, declaration, previous_declaration)
111
+ output = ""
112
+ buffer_to_string(output, "it 'should pass current expectations' do\n", 2)
109
113
  #collect all params
110
114
  params_collection = []
111
115
  mocks_collection = {}
@@ -142,11 +146,13 @@ class Pretentious::RspecGenerator < Pretentious::GeneratorBase
142
146
  end
143
147
 
144
148
  if (params_collection.size > 0)
145
- buffer(declare_dependencies(params_collection, let_variables, 3 * @_indentation.length, declaration, []))
149
+ deps = declare_dependencies(params_collection, let_variables, 3 * @_indentation.length, declaration,
150
+ [], previous_declaration)
151
+ buffer_to_string(output, deps) if deps!=''
146
152
  end
147
153
 
148
154
  if (mocks_collection.keys.size > 0)
149
- buffer(generate_rspec_stub(mocks_collection, let_variables, 3 * @_indentation.length, declaration))
155
+ buffer_to_string(output, generate_rspec_stub(mocks_collection, let_variables, 3 * @_indentation.length, declaration))
150
156
  end
151
157
 
152
158
  method_calls.each_key do |k|
@@ -160,15 +166,14 @@ class Pretentious::RspecGenerator < Pretentious::GeneratorBase
160
166
  ""
161
167
  end
162
168
 
163
- buffer("# #{context_prefix}#{k} #{params_desc_str} should return #{block[:result]}", 3)
164
- generate_expectation(fixture, k, let_variables, declaration, block[:params], block[:block], block[:result])
169
+ buffer_to_string(output, "# #{context_prefix}#{k} #{params_desc_str} should return #{block[:result]}", 3)
165
170
 
166
- whitespace
171
+ buffer_to_string(output, generate_expectation(fixture, k, let_variables, declaration, block[:params], block[:block], block[:result]))
167
172
  end
168
-
169
-
170
173
  end
171
- buffer("end",2)
174
+
175
+ buffer_to_string(output, "end", 2)
176
+ output
172
177
  end
173
178
 
174
179
  def generate_rspec_stub(mocks_collection, let_variables, indentation_level , declaration)
@@ -255,11 +260,11 @@ class Pretentious::RspecGenerator < Pretentious::GeneratorBase
255
260
  params.join(" ,")
256
261
  end
257
262
 
258
- def declare_dependencies(args, variable_map, level, declarations, method_call_collection)
263
+ def declare_dependencies(args, variable_map, level, declarations, method_call_collection, top_level_declaration = {})
259
264
  deconstructor = Pretentious::Deconstructor.new
260
265
 
261
266
  args = remove_primitives(args, variable_map)
262
- deconstructor.deconstruct_to_ruby(level, variable_map, declarations, method_call_collection, *args)
267
+ deconstructor.deconstruct_to_ruby(level, variable_map, declarations, top_level_declaration, method_call_collection, *args)
263
268
  end
264
269
 
265
270
  def remove_primitives(args, let_lookup)
@@ -1,3 +1,3 @@
1
1
  module Pretentious
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/run_test.sh CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  git add .
4
4
  gem build pretentious.gemspec
5
- gem install pretentious-0.1.4.gem
5
+ gem install pretentious-0.1.5.gem
6
6
  ruby test/test_generator.rb
@@ -9,6 +9,7 @@ RSpec.describe Fibonacci do
9
9
  end
10
10
 
11
11
  it 'should pass current expectations' do
12
+
12
13
  n = 1
13
14
  n_1 = 2
14
15
  n_2 = 3
@@ -31,11 +32,14 @@ RSpec.describe Fibonacci do
31
32
  expect( @fixture.fib(n_4) ).to eq(5)
32
33
 
33
34
  end
35
+
34
36
  end
35
37
 
36
38
  it 'should pass current expectations' do
39
+
37
40
  # Fibonacci::say_hello should return hello
38
41
  expect( Fibonacci.say_hello ).to eq("hello")
39
42
 
40
43
  end
44
+
41
45
  end
data/spec/m_d5_spec.rb CHANGED
@@ -4,10 +4,12 @@ require 'spec_helper'
4
4
  RSpec.describe Digest::MD5 do
5
5
 
6
6
  it 'should pass current expectations' do
7
+
7
8
  sample = "This is the digest"
8
9
 
9
10
  # Digest::MD5::hexdigest when passed "This is the digest" should return 9f12248dcddeda976611d192efaaf72a
10
11
  expect( Digest::MD5.hexdigest(sample) ).to eq("9f12248dcddeda976611d192efaaf72a")
11
12
 
12
13
  end
14
+
13
15
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Pretentious::Generator do
4
4
 
5
- context 'Pretentious::Deconstructor#build_tree' do
5
+ context 'Pretentious::MinitestGenerator' do
6
6
 
7
7
  before do
8
8
  @fixture = Pretentious::Generator.new
@@ -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: "#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 #Fibonacci::say_hello should return hello\n assert_equal \"hello\", Fibonacci.say_hello\n\n\n end\n",
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 #Fibonacci::say_hello should return hello\n assert_equal \"hello\", Fibonacci.say_hello\n\n\n end\n\n",
22
22
  generator: Pretentious::MinitestGenerator }})
23
23
  end
24
24
 
@@ -29,7 +29,7 @@ RSpec.describe Pretentious::Generator do
29
29
  expect(fib.fib(6)).to eq(8)
30
30
 
31
31
  expect(result).to eq({
32
- 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 # Fibonacci::say_hello should return hello\n expect( Fibonacci.say_hello ).to eq(\"hello\")\n\n end\nend\n",
32
+ 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\n\nend\n",
33
33
  generator: Pretentious::RspecGenerator}})
34
34
  end
35
35
  end
@@ -38,7 +38,7 @@ RSpec.describe Pretentious::Generator do
38
38
  it "declare watched classes beforehand and capture when certain methods are invoked" do
39
39
  #declare intention
40
40
  Pretentious.on(TestClass5).method_called(:test_method).spec_for(Fibonacci) do |results|
41
- expect(results[Fibonacci][:output]).to eq("#This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n\n context 'Scenario 1' do\n before do\n @fixture = Fibonacci.new\n end\n\n it 'should pass current expectations' do\n\n # Fibonacci#fib when passed n = 5 should return 5\n expect( @fixture.fib(5) ).to eq(5)\n\n end\n end\n\nend\n")
41
+ expect(results[Fibonacci][:output]).to eq("#This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n\n context 'Scenario 1' do\n before do\n @fixture = Fibonacci.new\n end\n\n it 'should pass current expectations' do\n\n # Fibonacci#fib when passed n = 5 should return 5\n expect( @fixture.fib(5) ).to eq(5)\n\n end\n\n end\n\nend\n")
42
42
  end
43
43
 
44
44
  expect(Pretentious::Generator).to receive(:generate_for).with(Fibonacci).and_call_original
@@ -9,28 +9,29 @@ RSpec.describe TestClass1 do
9
9
  end
10
10
 
11
11
  it 'should pass current expectations' do
12
+
12
13
  # TestClass1#message should return test
13
14
  expect( @fixture.message ).to eq("test")
14
15
 
15
16
  end
17
+
16
18
  end
17
19
 
18
20
  context 'Scenario 2' do
19
21
  before do
20
- var_26996240 = TestClass1.new("test")
21
- message = {hello: "world", test: var_26996240, arr_1: [1, 2, 3, 4, 5, var_26996240], sub_hash: {yes: true, obj: var_26996240}}
22
- @fixture = TestClass1.new(message)
22
+ @another_object = TestClass1.new("test")
23
+ @message = {hello: "world", test: @another_object, arr_1: [1, 2, 3, 4, 5, @another_object], sub_hash: {yes: true, obj: @another_object}}
24
+ @fixture = TestClass1.new(@message)
23
25
  end
24
26
 
25
27
  it 'should pass current expectations' do
26
- another_object = TestClass1.new("test")
27
- var_26989380 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
28
- var_26851780 = Proc.new { |message|
29
- var_26989380
28
+
29
+ var_2157293100 = Proc.new { |message|
30
+ @message
30
31
  }
31
32
 
32
- test_class_object_return = nil
33
- var_26831040 = Proc.new {
33
+ test_class1 = nil
34
+ var_2157279920 = Proc.new {
34
35
  # Variable return values ... can't figure out what goes in here...
35
36
  }
36
37
 
@@ -41,11 +42,11 @@ RSpec.describe TestClass1 do
41
42
  # TestClass1#print_message should return
42
43
  expect( @fixture.print_message ).to be_nil
43
44
 
44
- # TestClass1#set_block should return #<Pretentious::RecordedProc:0x0000000332d388@example.rb:73>
45
- expect( @fixture.set_block &var_26851780 ).to eq(var_26851780)
45
+ # TestClass1#set_block should return #<Pretentious::RecordedProc:0x000001012af7e0@example.rb:73>
46
+ expect( @fixture.set_block &var_2157293100 ).to eq(var_2157293100)
46
47
 
47
- # TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x0000000337da90 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={26996300=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x0000000337da90 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={26996300=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x0000000337da90 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={26996300=>"message"}>}}
48
- expect( @fixture.call_block &var_26831040 ).to eq(var_26989380)
48
+ # TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x00000101305078 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2157453340=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x00000101305078 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2157453340=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x00000101305078 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2157453340=>"message"}>}}
49
+ expect( @fixture.call_block &var_2157279920 ).to eq(@message)
49
50
 
50
51
  # TestClass1#something_is_wrong should return StandardError
51
52
  expect { @fixture.something_is_wrong }.to raise_error
@@ -54,6 +55,7 @@ RSpec.describe TestClass1 do
54
55
  expect( @fixture.just_returns_true ).to be true
55
56
 
56
57
  end
58
+
57
59
  end
58
60
 
59
61
  context 'Scenario 3' do
@@ -62,12 +64,29 @@ RSpec.describe TestClass1 do
62
64
  end
63
65
 
64
66
  it 'should pass current expectations' do
67
+
65
68
  another_object = TestClass1.new("test")
66
69
 
67
- # TestClass1#return_self when passed message = #<TestClass1:0x0000000337da90> should return #<TestClass1:0x0000000337da90>
70
+ # TestClass1#return_self when passed message = #<TestClass1:0x00000101305078> should return #<TestClass1:0x00000101305078>
68
71
  expect( @fixture.return_self(another_object) ).to eq(another_object)
69
72
 
70
73
  end
74
+
75
+ end
76
+
77
+ context 'Scenario 4' do
78
+ before do
79
+ @message = TestClass1.new("test")
80
+ @fixture = TestClass1.new(@message)
81
+ end
82
+
83
+ it 'should pass current expectations' do
84
+
85
+ # TestClass1#message should return #<TestClass1:0x00000101305078>
86
+ expect( @fixture.message ).to eq(@message)
87
+
88
+ end
89
+
71
90
  end
72
91
 
73
92
  end
@@ -9,6 +9,7 @@ RSpec.describe TestClass2 do
9
9
  end
10
10
 
11
11
  it 'should pass current expectations' do
12
+
12
13
  # TestClass2#print_message should return
13
14
  expect( @fixture.print_message ).to be_nil
14
15
 
@@ -16,6 +17,7 @@ RSpec.describe TestClass2 do
16
17
  expect( @fixture.print_message ).to be_nil
17
18
 
18
19
  end
20
+
19
21
  end
20
22
 
21
23
  context 'Scenario 2' do
@@ -24,23 +26,25 @@ RSpec.describe TestClass2 do
24
26
  end
25
27
 
26
28
  it 'should pass current expectations' do
29
+
27
30
  end
31
+
28
32
  end
29
33
 
30
34
  context 'Scenario 3' do
31
35
  before do
32
- message2 = "This is message 3"
33
- message = TestClass2.new(message2, nil)
34
- @fixture = TestClass2.new(message, message2)
36
+ @message2 = "This is message 3"
37
+ message = TestClass2.new(@message2, nil)
38
+ @fixture = TestClass2.new(message, @message2)
35
39
  end
36
40
 
37
41
  it 'should pass current expectations' do
38
- message3 = "This is message 3"
39
42
 
40
43
  # TestClass2#test when passed object = "This is message 3" should return This is message 3
41
- expect( @fixture.test(message3) ).to eq("This is message 3")
44
+ expect( @fixture.test(@message2) ).to eq("This is message 3")
42
45
 
43
46
  end
47
+
44
48
  end
45
49
 
46
50
  end
@@ -5,34 +5,38 @@ RSpec.describe TestClass3 do
5
5
 
6
6
  context 'Scenario 1' do
7
7
  before do
8
- var_26996240 = TestClass1.new("test")
9
- var_26989380 = {hello: "world", test: var_26996240, arr_1: [1, 2, 3, 4, 5, var_26996240], sub_hash: {yes: true, obj: var_26996240}}
10
- testclass1 = TestClass1.new(var_26989380)
8
+ another_object = TestClass1.new("test")
9
+ var_2157439420 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
10
+ testclass1 = TestClass1.new(var_2157439420)
11
11
  testclass2 = TestClass2.new("This is message 2", nil)
12
12
  @fixture = TestClass3.new(testclass1, testclass2)
13
13
  end
14
14
 
15
15
  it 'should pass current expectations' do
16
+
16
17
  # TestClass3#show_messages should return awesome!!!
17
18
  expect( @fixture.show_messages ).to eq("awesome!!!")
18
19
 
19
20
  end
21
+
20
22
  end
21
23
 
22
24
  context 'Scenario 2' do
23
25
  before do
24
- var_26996240 = TestClass1.new("test")
25
- var_26989380 = {hello: "world", test: var_26996240, arr_1: [1, 2, 3, 4, 5, var_26996240], sub_hash: {yes: true, obj: var_26996240}}
26
- testclass1 = TestClass1.new(var_26989380)
26
+ another_object = TestClass1.new("test")
27
+ var_2157439420 = {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_2157439420)
27
29
  testclass2 = TestClass2.new("This is message 2", nil)
28
30
  @fixture = TestClass3.new(testclass1, testclass2)
29
31
  end
30
32
 
31
33
  it 'should pass current expectations' do
34
+
32
35
  # TestClass3#show_messages should return awesome!!!
33
36
  expect( @fixture.show_messages ).to eq("awesome!!!")
34
37
 
35
38
  end
39
+
36
40
  end
37
41
 
38
42
  end
@@ -6,15 +6,17 @@ RSpec.describe TestClass4 do
6
6
  context 'Scenario 1' do
7
7
  before do
8
8
  var_8 = nil
9
- var_26873720 = Proc.new {
9
+ var_2157339500 = Proc.new {
10
10
  # Variable return values ... can't figure out what goes in here...
11
11
  }
12
12
 
13
- @fixture = TestClass4.new(&var_26873720)
13
+ @fixture = TestClass4.new(&var_2157339500)
14
14
  end
15
15
 
16
16
  it 'should pass current expectations' do
17
+
17
18
  end
19
+
18
20
  end
19
21
 
20
22
  end
@@ -9,7 +9,8 @@ RSpec.describe TestClassForAutoStub do
9
9
  end
10
10
 
11
11
  it 'should pass current expectations' do
12
- var_25019620 = ["Hello Glorious world", "HI THERE!!!!"]
12
+
13
+ var_2172864580 = ["Hello Glorious world", "HI THERE!!!!"]
13
14
 
14
15
  allow_any_instance_of(ClassUsedByTestClass).to receive(:stubbed_method).and_return("Hello Glorious world")
15
16
  allow_any_instance_of(AnotherClassUsedByTestClass).to receive(:get_message).and_return("HI THERE!!!!")
@@ -18,6 +19,7 @@ RSpec.describe TestClassForAutoStub do
18
19
  expect( @fixture.method_that_uses_the_class_to_stub ).to eq(["Hello Glorious world", "HI THERE!!!!"])
19
20
 
20
21
  end
22
+
21
23
  end
22
24
 
23
25
  end
@@ -9,7 +9,8 @@ RSpec.describe TestClassForMocks do
9
9
  end
10
10
 
11
11
  it 'should pass current expectations' do
12
- var_25555900 = [2, 3, 4, 5]
12
+
13
+ var_2156244200 = [2, 3, 4, 5]
13
14
 
14
15
  allow_any_instance_of(TestMockSubClass).to receive(:test_method).and_return("a return string")
15
16
  allow_any_instance_of(TestMockSubClass).to receive(:increment_val).and_return(2, 3, 4, 5)
@@ -27,6 +28,7 @@ RSpec.describe TestClassForMocks do
27
28
  expect( @fixture.method_with_usage4 ).to eq("a return string")
28
29
 
29
30
  end
31
+
30
32
  end
31
33
 
32
34
  context 'Scenario 2' do
@@ -35,14 +37,16 @@ RSpec.describe TestClassForMocks do
35
37
  end
36
38
 
37
39
  it 'should pass current expectations' do
38
- var_25477400 = {val: 1, str: "hello world", message: "a message"}
39
40
 
40
- allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(var_25477400)
41
+ var_2166356480 = {val: 1, str: "hello world", message: "a message"}
42
+
43
+ allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(var_2166356480)
41
44
 
42
45
  # TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
43
- expect( @fixture.method_with_usage3("a message") ).to eq(var_25477400)
46
+ expect( @fixture.method_with_usage3("a message") ).to eq(var_2166356480)
44
47
 
45
48
  end
49
+
46
50
  end
47
51
 
48
52
  end
data/test/test_meme.rb CHANGED
@@ -7,7 +7,7 @@ end
7
7
 
8
8
  class MemeScenario1 < TestMeme
9
9
  def setup
10
- @fixture = Meme.new
10
+ @fixture = Meme.new
11
11
  end
12
12
 
13
13
  def test_current_expectation
@@ -7,7 +7,7 @@ end
7
7
 
8
8
  class TestClass1Scenario1 < TestTestClass1
9
9
  def setup
10
- @fixture = TestClass1.new("test")
10
+ @fixture = TestClass1.new("test")
11
11
  end
12
12
 
13
13
  def test_current_expectation
@@ -20,20 +20,18 @@ end
20
20
 
21
21
  class TestClass1Scenario2 < TestTestClass1
22
22
  def setup
23
- var_26398900 = TestClass1.new("test")
24
- message = {hello: "world", test: var_26398900, arr_1: [1, 2, 3, 4, 5, var_26398900], sub_hash: {yes: true, obj: var_26398900}}
25
- @fixture = TestClass1.new(message)
23
+ @another_object = TestClass1.new("test")
24
+ @message = {hello: "world", test: @another_object, arr_1: [1, 2, 3, 4, 5, @another_object], sub_hash: {yes: true, obj: @another_object}}
25
+ @fixture = TestClass1.new(@message)
26
26
  end
27
27
 
28
28
  def test_current_expectation
29
- another_object = TestClass1.new("test")
30
- var_26392980 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
31
- var_26237280 = Proc.new { |message|
32
- var_26392980
29
+ var_2162918140 = Proc.new { |message|
30
+ @message
33
31
  }
34
32
 
35
- test_class_object_return = nil
36
- var_26216700 = Proc.new {
33
+ test_class1 = nil
34
+ var_2162887340 = Proc.new {
37
35
  # Variable return values ... can't figure out what goes in here...
38
36
  }
39
37
 
@@ -44,11 +42,11 @@ class TestClass1Scenario2 < TestTestClass1
44
42
  #TestClass1#print_message should return
45
43
  assert_nil @fixture.print_message
46
44
 
47
- #TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000003201568@example.rb:73>
48
- assert_equal var_26237280, @fixture.set_block( &var_26237280)
45
+ #TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000101d61990@example.rb:73>
46
+ assert_equal var_2162918140, @fixture.set_block( &var_2162918140)
49
47
 
50
- #TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x00000003259fd8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={26398960=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x00000003259fd8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={26398960=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x00000003259fd8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={26398960=>"message"}>}}
51
- assert_equal var_26392980, @fixture.call_block( &var_26216700)
48
+ #TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x000001025011f0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2166885020=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x000001025011f0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2166885020=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x000001025011f0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2166885020=>"message"}>}}
49
+ assert_equal @message, @fixture.call_block( &var_2162887340)
52
50
 
53
51
  #TestClass1#something_is_wrong should return StandardError
54
52
  assert_raises(StandardError) { @fixture.something_is_wrong }
@@ -62,16 +60,30 @@ end
62
60
 
63
61
  class TestClass1Scenario3 < TestTestClass1
64
62
  def setup
65
- @fixture = TestClass1.new("Hello")
63
+ @fixture = TestClass1.new("Hello")
66
64
  end
67
65
 
68
66
  def test_current_expectation
69
67
  another_object = TestClass1.new("test")
70
68
 
71
- #TestClass1#return_self when passed message = #<TestClass1:0x00000003259fd8> should return #<TestClass1:0x00000003259fd8>
69
+ #TestClass1#return_self when passed message = #<TestClass1:0x000001025011f0> should return #<TestClass1:0x000001025011f0>
72
70
  assert_equal another_object, @fixture.return_self(another_object)
73
71
 
74
72
 
75
73
  end
76
74
  end
77
75
 
76
+ class TestClass1Scenario4 < TestTestClass1
77
+ def setup
78
+ @message = TestClass1.new("test")
79
+ @fixture = TestClass1.new(@message)
80
+ end
81
+
82
+ def test_current_expectation
83
+ #TestClass1#message should return #<TestClass1:0x000001025011f0>
84
+ assert_equal @message, @fixture.message
85
+
86
+
87
+ end
88
+ end
89
+
@@ -7,7 +7,7 @@ end
7
7
 
8
8
  class TestClass2Scenario1 < TestTestClass2
9
9
  def setup
10
- @fixture = TestClass2.new("This is message 2", nil)
10
+ @fixture = TestClass2.new("This is message 2", nil)
11
11
  end
12
12
 
13
13
  def test_current_expectation
@@ -23,7 +23,7 @@ end
23
23
 
24
24
  class TestClass2Scenario2 < TestTestClass2
25
25
  def setup
26
- @fixture = TestClass2.new("This is message 3", nil)
26
+ @fixture = TestClass2.new("This is message 3", nil)
27
27
  end
28
28
 
29
29
  def test_current_expectation
@@ -33,16 +33,14 @@ end
33
33
 
34
34
  class TestClass2Scenario3 < TestTestClass2
35
35
  def setup
36
- message2 = "This is message 3"
37
- message = TestClass2.new(message2, nil)
38
- @fixture = TestClass2.new(message, message2)
36
+ @message2 = "This is message 3"
37
+ message = TestClass2.new(@message2, nil)
38
+ @fixture = TestClass2.new(message, @message2)
39
39
  end
40
40
 
41
41
  def test_current_expectation
42
- message3 = "This is message 3"
43
-
44
42
  #TestClass2#test when passed object = "This is message 3" should return This is message 3
45
- assert_equal "This is message 3", @fixture.test(message3)
43
+ assert_equal "This is message 3", @fixture.test(@message2)
46
44
 
47
45
 
48
46
  end
@@ -7,11 +7,11 @@ end
7
7
 
8
8
  class TestClass3Scenario1 < TestTestClass3
9
9
  def setup
10
- var_26398900 = TestClass1.new("test")
11
- var_26392980 = {hello: "world", test: var_26398900, arr_1: [1, 2, 3, 4, 5, var_26398900], sub_hash: {yes: true, obj: var_26398900}}
12
- testclass1 = TestClass1.new(var_26392980)
13
- testclass2 = TestClass2.new("This is message 2", nil)
14
- @fixture = TestClass3.new(testclass1, testclass2)
10
+ another_object = TestClass1.new("test")
11
+ var_2166831300 = {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_2166831300)
13
+ testclass2 = TestClass2.new("This is message 2", nil)
14
+ @fixture = TestClass3.new(testclass1, testclass2)
15
15
  end
16
16
 
17
17
  def test_current_expectation
@@ -24,11 +24,11 @@ end
24
24
 
25
25
  class TestClass3Scenario2 < TestTestClass3
26
26
  def setup
27
- var_26398900 = TestClass1.new("test")
28
- var_26392980 = {hello: "world", test: var_26398900, arr_1: [1, 2, 3, 4, 5, var_26398900], sub_hash: {yes: true, obj: var_26398900}}
29
- testclass1 = TestClass1.new(var_26392980)
30
- testclass2 = TestClass2.new("This is message 2", nil)
31
- @fixture = TestClass3.new(testclass1, testclass2)
27
+ another_object = TestClass1.new("test")
28
+ var_2166831300 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
29
+ testclass1 = TestClass1.new(var_2166831300)
30
+ testclass2 = TestClass2.new("This is message 2", nil)
31
+ @fixture = TestClass3.new(testclass1, testclass2)
32
32
  end
33
33
 
34
34
  def test_current_expectation
@@ -7,12 +7,12 @@ end
7
7
 
8
8
  class TestClass4Scenario1 < TestTestClass4
9
9
  def setup
10
- var_8 = nil
11
- var_26281680 = Proc.new {
12
- # Variable return values ... can't figure out what goes in here...
13
- }
10
+ var_8 = nil
11
+ var_2166614480 = Proc.new {
12
+ # Variable return values ... can't figure out what goes in here...
13
+ }
14
14
 
15
- @fixture = TestClass4.new(&var_26281680)
15
+ @fixture = TestClass4.new(&var_2166614480)
16
16
  end
17
17
 
18
18
  def test_current_expectation
@@ -7,11 +7,11 @@ end
7
7
 
8
8
  class TestClassForMocksScenario1 < TestTestClassForMocks
9
9
  def setup
10
- @fixture = TestClassForMocks.new
10
+ @fixture = TestClassForMocks.new
11
11
  end
12
12
 
13
13
  def test_current_expectation
14
- var_25321980 = [2, 3, 4, 5]
14
+ var_2166301840 = [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
@@ -35,15 +35,15 @@ end
35
35
 
36
36
  class TestClassForMocksScenario2 < TestTestClassForMocks
37
37
  def setup
38
- @fixture = TestClassForMocks.new
38
+ @fixture = TestClassForMocks.new
39
39
  end
40
40
 
41
41
  def test_current_expectation
42
- var_25211620 = {val: 1, str: "hello world", message: "a message"}
42
+ var_2166224460 = {val: 1, str: "hello world", message: "a message"}
43
43
 
44
- TestMockSubClass.stub_any_instance(:return_hash, var_25211620) do
44
+ TestMockSubClass.stub_any_instance(:return_hash, var_2166224460) do
45
45
  #TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
46
- assert_equal var_25211620, @fixture.method_with_usage3("a message")
46
+ assert_equal var_2166224460, @fixture.method_with_usage3("a message")
47
47
 
48
48
  end
49
49
 
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
4
+ version: 0.1.5
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-11-30 00:00:00.000000000 Z
11
+ date: 2015-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  requirements: []
179
179
  rubyforge_project:
180
- rubygems_version: 2.4.8
180
+ rubygems_version: 2.2.2
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: Generate tests from existing code as well as a way to deal with pretentious
@@ -204,3 +204,4 @@ test_files:
204
204
  - test/test_test_class3.rb
205
205
  - test/test_test_class4.rb
206
206
  - test/test_test_class_for_mocks.rb
207
+ has_rdoc: