pretentious 0.1.2 → 0.1.3

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: 2e52b4207be07ea0604174f928860a43de276e6d
4
- data.tar.gz: 113710e58638b64cd72ce2c6c5ed8f74171440c2
3
+ metadata.gz: 7e21f093e245689b1e0b11740feb69b07164660d
4
+ data.tar.gz: 5c214fe704474d5e4e87d1ba1535ea9dd6b5b979
5
5
  SHA512:
6
- metadata.gz: 3c3cf391ac3e937eb694d0362216a1f50d5c5603a7ee3a6f917067a7a96a26ec23a4f23a80b0f1a5492c32bf49b5962b338f41fdd8266dcb16f5fcfaeef206ad
7
- data.tar.gz: bba29d6250c4da2835b94c65742473689a89eeef29ffeca71e1003ed60ea831071a0d2906125fc91ee103807b5564a04efc5d70b2e125b98a199a59d0e1786db
6
+ metadata.gz: 1b3f5c14dbe2b9f74fc991dc52bda85941b6fe765f24a88295965014c0b604e5447d40eab429d498aafc665888df771a6ffe575d9fdba178590bb53a6e67853b
7
+ data.tar.gz: 4db89660c5be4c23ddb368db29f43d6411f6a756fc399818d188e86c6b54fcdb0bd6c930ea55983f1afda3f07d9e7a6b8321f9f05d3cfabf401283388f5305ab
data/README.md CHANGED
@@ -18,13 +18,14 @@ an Object Deconstructor which allows you, given any object, to obtain a ruby cod
18
18
  1. [Installation](#installation)
19
19
  2. [Usage](#usage)
20
20
  1. [Minitest](#minitest)
21
- 3. [Handling complex parameters and object constructors](#handling-complex-parameters-and-object-constructors)
22
- 4. [Capturing Exceptions](#capturing-exceptions)
23
- 5. [Auto Stubbing](#auto-stubbing)
24
- 6. [Object Deconstruction Utility](#object-deconstruction-utility)
21
+ 3. [Declarative generation without using example files](#declarative-generation-without-using-example-files)
22
+ 4. [Handling complex parameters and object constructors](#handling-complex-parameters-and-object-constructors)
23
+ 5. [Capturing Exceptions](#capturing-exceptions)
24
+ 6. [Auto Stubbing](#auto-stubbing)
25
+ 7. [Object Deconstruction Utility](#object-deconstruction-utility)
25
26
  1. [Using the Object deconstructor in rails](#using-the-object-deconstructor-in-rails)
26
- 7. [Things to do after](#things-to-do-after)
27
- 8. [Limitations](#limitations)
27
+ 8. [Things to do after](#things-to-do-after)
28
+ 9. [Limitations](#limitations)
28
29
 
29
30
 
30
31
  ## Installation
@@ -247,6 +248,45 @@ class Scenario1 < TestMeme
247
248
  end
248
249
  ```
249
250
 
251
+ ## Declarative generation without using example files
252
+
253
+ Instead of using Pretentious.spec_for and wrapping the target code around a block, you may declaratively define
254
+ when test generation should occur beforehand. This allows you to generate tests around code blocks without
255
+ modifying source codes. This is useful for testing code embedded inside frameworks like rails where your
256
+ "example" is already embedded inside existing code.
257
+
258
+ For example lets say you want to generate tests for UserAuthenticaion that is used inside the
259
+ login method inside the UsersController inside a rails app. You'd simply define like below:
260
+
261
+
262
+ ```ruby
263
+ # initializers/pretentious.rb
264
+
265
+ Pretentious.on(UsersController).method_called(:login).spec_for(UserAuthentication) #RSPEC
266
+ Pretentious.on(UsersController).method_called(:login, :logout, ...).minitest_for(UserAuthentication) #minitest
267
+
268
+ # spec files will be written to the project root
269
+ ```
270
+
271
+ The above code is equivalent to adding a spec_for inside the target method.
272
+
273
+ Note that you must include the setup code in a place that you know runs before the target code block is run. For
274
+ example, if you want to test a class that is used inside a controller in rails, it is best to put it in an initializer.
275
+ It is also recommended to call Pretentious.install_watcher early on to be able to generate better fixtures.
276
+
277
+ You can pass a block for manually handling for example
278
+
279
+ ```ruby
280
+ # initializers/pretentious.rb
281
+
282
+ Pretentious.on(UsersController).method_called(:login).spec_for(UserAuthentication) do |results|
283
+ puts results[UserAuthentication][:output]
284
+ end
285
+
286
+ # spec files will be written to the project root
287
+ ```
288
+
289
+
250
290
  ## Handling complex parameters and object constructors
251
291
 
252
292
  No need to do anything special, just do as what you would do normally and the pretentious gem will figure it out.
data/bin/ddtgen CHANGED
@@ -40,14 +40,6 @@ eval(example_body, binding, filename, 1)
40
40
  #collect results
41
41
 
42
42
 
43
-
44
- module DdtUtils
45
- def self.to_underscore(str)
46
- str.gsub(/(.)([A-Z])/,'\1_\2').downcase
47
- end
48
- end
49
-
50
-
51
43
  Pretentious.last_results.each { |g, result_per_generator|
52
44
  puts "#{g}:"
53
45
  result_per_generator.each { |klass, result|
data/lib/pretentious.rb CHANGED
@@ -6,6 +6,7 @@ require "pretentious/recorded_proc"
6
6
  require "pretentious/generator"
7
7
  require 'binding_of_caller'
8
8
  require 'pretentious/deconstructor'
9
+ require 'pretentious/trigger'
9
10
 
10
11
  Class.class_eval do
11
12
 
@@ -43,6 +44,13 @@ end
43
44
 
44
45
  module Pretentious
45
46
 
47
+ module DdtUtils
48
+ def self.to_underscore(str)
49
+ str.gsub(/(.)([A-Z])/,'\1_\2').downcase
50
+ end
51
+ end
52
+
53
+
46
54
  def self.spec_for(*klasses, &block)
47
55
  @spec_results ||= {}
48
56
  Pretentious::Generator.test_generator = Pretentious::RspecGenerator
@@ -95,5 +103,7 @@ module Pretentious
95
103
  result
96
104
  end
97
105
 
98
-
106
+ def self.on(target_class)
107
+ Pretentious::Trigger.new(target_class)
108
+ end
99
109
  end
@@ -12,6 +12,10 @@ module Pretentious
12
12
  def self.impostor_for(module_space, klass)
13
13
  newStandInKlass = Class.new()
14
14
  name = klass.name
15
+
16
+ #return if already an impostor
17
+ return klass if (klass.respond_to?(:test_class))
18
+
15
19
  module_space.const_set "#{name.split('::').last}Impostor", newStandInKlass
16
20
 
17
21
  newStandInKlass.class_eval("
@@ -449,29 +453,33 @@ module Pretentious
449
453
 
450
454
  end
451
455
 
452
- Class.class_eval do
453
- alias_method :_ddt_old_new, :new
456
+ #make sure it is set only once
457
+ if (!Class.instance_methods.include?(:_ddt_old_new))
458
+ Class.class_eval do
459
+ alias_method :_ddt_old_new, :new
454
460
 
455
- def new(*args, &block)
456
- instance = _ddt_old_new(*args, &block)
457
- instance._set_init_arguments(*args, &block)
458
- instance
459
- end
461
+ def new(*args, &block)
462
+ instance = _ddt_old_new(*args, &block)
463
+ instance._set_init_arguments(*args, &block)
464
+ instance
465
+ end
460
466
 
467
+ end
461
468
  end
469
+
462
470
  end
463
471
 
464
472
  def self.clean_watches
465
- Class.class_eval do
466
- remove_method :new
467
- alias_method :new, :_ddt_old_new
468
- end
473
+ unwatch_new_instances
469
474
  end
470
475
 
471
476
  def self.unwatch_new_instances
472
- Class.class_eval do
473
- remove_method :new
474
- alias_method :new, :_ddt_old_new
477
+ if (Class.respond_to?(:_ddt_old_new))
478
+ Class.class_eval do
479
+ remove_method :new
480
+ alias_method :new, :_ddt_old_new
481
+ remove_method :_ddt_old_new
482
+ end
475
483
  end
476
484
  end
477
485
 
@@ -307,7 +307,7 @@ class Pretentious::MinitestGenerator < Pretentious::GeneratorBase
307
307
  def self.naming(output_folder, klass)
308
308
  klass_name_parts = klass.name.split('::')
309
309
  last_part = klass_name_parts.pop
310
- File.join(output_folder, "test_#{DdtUtils.to_underscore(last_part)}.rb")
310
+ File.join(output_folder, "test_#{Pretentious::DdtUtils.to_underscore(last_part)}.rb")
311
311
  end
312
312
 
313
313
  def self.helper(output_folder)
@@ -284,7 +284,7 @@ class Pretentious::RspecGenerator < Pretentious::GeneratorBase
284
284
  def self.naming(output_folder, klass)
285
285
  klass_name_parts = klass.name.split('::')
286
286
  last_part = klass_name_parts.pop
287
- File.join(output_folder, "#{DdtUtils.to_underscore(last_part)}_spec.rb")
287
+ File.join(output_folder, "#{Pretentious::DdtUtils.to_underscore(last_part)}_spec.rb")
288
288
  end
289
289
 
290
290
  def self.helper(output_folder)
@@ -0,0 +1,102 @@
1
+ module Pretentious
2
+ class Trigger
3
+ class Options
4
+ attr_accessor :output_folder
5
+ end
6
+
7
+ def initialize(target_class)
8
+ @target_class = target_class
9
+ @target_class_methods = []
10
+ @target_methods = []
11
+ end
12
+
13
+ def method_called(*target_methods)
14
+ @target_methods = target_methods
15
+ self
16
+ end
17
+
18
+ def class_method_called(*target_methods)
19
+ @target_class_methods = target_methods
20
+ self
21
+ end
22
+
23
+ def spec_for(*klasses, &results_block)
24
+ @generator = Pretentious::RspecGenerator
25
+ @spec_classes = klasses
26
+ @results_block = results_block
27
+ install_trigger
28
+ end
29
+
30
+ def minitest_for(*klasses, &results_block)
31
+ @generator = Pretentious::MinitestGenerator
32
+ @spec_classes = klasses
33
+ @results_block = results_block
34
+ install_trigger
35
+ end
36
+
37
+ def self.output_file(result, klass, output_folder)
38
+ FileUtils.mkdir_p output_folder
39
+ result[:generator].helper(output_folder)
40
+ filename = result[:generator].naming(output_folder, klass)
41
+ File.open(filename, 'w') {
42
+ |f| f.write(result[:output])
43
+ }
44
+ filename
45
+ end
46
+
47
+ private
48
+
49
+ def attach_generator(generator, target, method, spec_classes, results_block, options)
50
+ target.send(:define_method, method.to_sym) do |*args, &block|
51
+ result = nil
52
+ Pretentious::Generator.test_generator = generator
53
+ generator_result = Pretentious::Generator.generate_for(*spec_classes) do
54
+ result = send(:"_pretentious_orig_#{method}", *args, &block)
55
+ end
56
+
57
+ results_block.call(generator_result, options) if results_block
58
+
59
+ result
60
+ end
61
+ end
62
+
63
+ def install_trigger
64
+ @options = Pretentious::Trigger::Options.new
65
+
66
+ default_callback = Proc.new { |result_per_generator, options|
67
+ output_files = []
68
+ result_per_generator.each { |klass, result|
69
+ output_folder = result[:generator].location(options.output_folder)
70
+ filename = Pretentious::Trigger::output_file(result, klass, output_folder)
71
+ output_files << filename
72
+ }
73
+ output_files
74
+ }
75
+
76
+ @results_block = default_callback unless @results_block
77
+
78
+ @target_methods.each { |method|
79
+ @target_class.class_exec(@target_class, method) do |klass, m|
80
+
81
+ if !klass.instance_methods.include? :"_pretentious_orig_#{m}"
82
+ alias_method :"_pretentious_orig_#{m}", :"#{m}"
83
+ end
84
+
85
+ end
86
+
87
+ attach_generator(@generator, @target_class, method, @spec_classes, @results_block, @options)
88
+ }
89
+
90
+ @target_class_methods.each { |method|
91
+ @target_class.singleton_class.class_exec(@target_class, method) do |klass, m|
92
+ if !klass.methods.include? :"_pretentious_orig_#{m}"
93
+ alias_method :"_pretentious_orig_#{m}", :"#{m}"
94
+ end
95
+ end
96
+ attach_generator(@generator, @target_class.singleton_class, method, @spec_classes, @results_block, @options)
97
+ }
98
+
99
+ @options
100
+ end
101
+ end
102
+ end
@@ -1,3 +1,3 @@
1
1
  module Pretentious
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
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.2.gem
5
+ gem install pretentious-0.1.3.gem
6
6
  ruby test/test_generator.rb
@@ -198,19 +198,48 @@ RSpec.describe Pretentious::Generator do
198
198
  Pretentious::Generator.test_generator= nil
199
199
  end
200
200
 
201
- it "removes unused variables" do
202
-
203
- call_artifacts = Pretentious::Generator.generate_for(TestClass3) do
201
+ it "inlines strings when possible" do
202
+ message = nil
203
+ object = nil
204
+ call_artifacts = Pretentious::Generator.generate_for(TestClass1) do
204
205
  message = "test"
205
- another_object = TestClass1.new(message)
206
- test_class_one = TestClass1.new({hello: "world", test: another_object, arr_1: [1,2,3,4,5, another_object],
207
- sub_hash: {yes: true, obj: another_object}})
208
- test_class_two = TestClass2.new("This is message 2", message)
209
-
210
- class_to_test = TestClass3.new(test_class_one, test_class_two)
211
- class_to_test.show_messages
212
- class_to_test.change_message(message)
206
+ object = TestClass1.new(message)
207
+ object.message
213
208
  end
209
+
210
+ expect(call_artifacts[TestClass1]).to eq({output: [
211
+ {begin: TestClass1},
212
+ {
213
+ :generate => "TestClass1Impostor",
214
+ :instance_count => 1
215
+ },
216
+ {
217
+ :id => message.object_id,
218
+ :class => String,
219
+ :value => "test",
220
+ :used_by => :inline
221
+ },
222
+ {
223
+ :id => object.object_id,
224
+ :class => TestClass1,
225
+ :params_types => [[:req, :message]],
226
+ :used_by => [],
227
+ :ref => [ {id: message.object_id, class: String, value: "test", used_by: :inline}]
228
+
229
+ },
230
+ {
231
+ :method => :message,
232
+ :params => [],
233
+ :block => nil,
234
+ :names => [],
235
+ :context => {
236
+ :calls => []
237
+ },
238
+ :result => "test"
239
+ },
240
+ :generate_end, :end],
241
+ generator: DummyGenerator2})
242
+
214
243
  end
215
244
 
216
245
  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::Generator' do
6
6
 
7
7
  before do
8
8
  @fixture = Pretentious::Generator.new
@@ -15,14 +15,72 @@ RSpec.describe Pretentious::Generator do
15
15
  end
16
16
 
17
17
  it "tracks object calls" do
18
+ klass = Fibonacci
19
+
18
20
  result = Pretentious::Generator.generate_for(Fibonacci) do
21
+ expect(klass == Fibonacci).to_not be
19
22
  Fibonacci.say_hello
20
23
  end
24
+ #should clean up after block
25
+ expect(klass == Fibonacci).to be
26
+
27
+ #should still work
28
+ fib = Fibonacci.new
29
+ expect(fib.fib(6)).to eq(8)
30
+
21
31
  expect(result).to eq({
22
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",
23
33
  generator: Pretentious::RspecGenerator}})
24
34
  end
25
-
26
35
  end
27
36
 
37
+ context "unobstrusive generator" do
38
+ it "declare watched classes beforehand and capture when certain methods are invoked" do
39
+ #declare intention
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")
42
+ end
43
+
44
+ expect(Pretentious::Generator).to receive(:generate_for).with(Fibonacci).and_call_original
45
+ #execute code
46
+ class_that_uses_fib = TestClass5.new
47
+ result = class_that_uses_fib.test_method
48
+ expect(result).to eq(5)
49
+ end
50
+
51
+ it "outputs to a file when no block is given" do
52
+ Pretentious.on(TestClass5).method_called(:test_method).spec_for(Fibonacci)
53
+
54
+ expect(Pretentious::Trigger).to receive(:output_file)
55
+
56
+ class_that_uses_fib = TestClass5.new
57
+ result = class_that_uses_fib.test_method
58
+ expect(result).to eq(5)
59
+ end
60
+
61
+ it "works on class methods" do
62
+ Pretentious.on(TestClass5).class_method_called(:class_test_method).spec_for(Fibonacci)
63
+
64
+ expect(Pretentious::Trigger).to receive(:output_file)
65
+ expect(Pretentious::Generator).to receive(:generate_for).with(Fibonacci).and_call_original
66
+ result = TestClass5.class_test_method
67
+
68
+ expect(result).to eq(8)
69
+ end
70
+
71
+ it "works on multiple methods" do
72
+ Pretentious.on(TestClass5).method_called(:test_method, :test_method2).spec_for(Fibonacci)
73
+
74
+ expect(Pretentious::Trigger).to receive(:output_file).twice
75
+ expect(Pretentious::Generator).to receive(:generate_for).twice.with(Fibonacci).and_call_original
76
+
77
+ class_that_uses_fib = TestClass5.new
78
+ result1 = class_that_uses_fib.test_method
79
+ result2 = class_that_uses_fib.test_method2
80
+
81
+ expect(result1).to eq(5)
82
+ expect(result2).to eq(34)
83
+
84
+ end
85
+ end
28
86
  end
@@ -17,20 +17,20 @@ RSpec.describe TestClass1 do
17
17
 
18
18
  context 'Scenario 2' do
19
19
  before do
20
- var_2167261360 = TestClass1.new("test")
21
- message = {hello: "world", test: var_2167261360, arr_1: [1, 2, 3, 4, 5, var_2167261360], sub_hash: {yes: true, obj: var_2167261360}}
20
+ var_2190448620 = TestClass1.new("test")
21
+ message = {hello: "world", test: var_2190448620, arr_1: [1, 2, 3, 4, 5, var_2190448620], sub_hash: {yes: true, obj: var_2190448620}}
22
22
  @fixture = TestClass1.new(message)
23
23
  end
24
24
 
25
25
  it 'should pass current expectations' do
26
26
  another_object = TestClass1.new("test")
27
- var_2167245200 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
28
- var_2167127140 = Proc.new { |message|
29
- var_2167245200
27
+ var_2190448940 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
28
+ var_2190309320 = Proc.new { |message|
29
+ var_2190448940
30
30
  }
31
31
 
32
32
  e = nil
33
- var_2167121820 = Proc.new {
33
+ var_2190303060 = Proc.new {
34
34
  # Variable return values ... can't figure out what goes in here...
35
35
  }
36
36
 
@@ -41,11 +41,11 @@ RSpec.describe TestClass1 do
41
41
  # TestClass1#print_message should return
42
42
  expect( @fixture.print_message ).to be_nil
43
43
 
44
- # TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000102575140@example.rb:73>
45
- expect( @fixture.set_block &var_2167127140 ).to eq(var_2167127140)
44
+ # TestClass1#set_block should return #<Pretentious::RecordedProc:0x000001051ac178@example.rb:73>
45
+ expect( @fixture.set_block &var_2190309320 ).to eq(var_2190309320)
46
46
 
47
- # TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x000001025b3f30 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2167261020=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x000001025b3f30 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2167261020=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x000001025b3f30 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2167261020=>"message"}>}}
48
- expect( @fixture.call_block &var_2167121820 ).to eq(var_2167245200)
47
+ # TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x000001051f2ec0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2190448660=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x000001051f2ec0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2190448660=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x000001051f2ec0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2190448660=>"message"}>}}
48
+ expect( @fixture.call_block &var_2190303060 ).to eq(var_2190448940)
49
49
 
50
50
  # TestClass1#something_is_wrong should return StandardError
51
51
  expect { @fixture.something_is_wrong }.to raise_error
@@ -5,9 +5,9 @@ RSpec.describe TestClass3 do
5
5
 
6
6
  context 'Scenario 1' do
7
7
  before do
8
- var_2167261360 = TestClass1.new("test")
9
- var_2167245200 = {hello: "world", test: var_2167261360, arr_1: [1, 2, 3, 4, 5, var_2167261360], sub_hash: {yes: true, obj: var_2167261360}}
10
- testclass1 = TestClass1.new(var_2167245200)
8
+ var_2190448620 = TestClass1.new("test")
9
+ var_2190448940 = {hello: "world", test: var_2190448620, arr_1: [1, 2, 3, 4, 5, var_2190448620], sub_hash: {yes: true, obj: var_2190448620}}
10
+ testclass1 = TestClass1.new(var_2190448940)
11
11
  testclass2 = TestClass2.new("This is message 2", nil)
12
12
  @fixture = TestClass3.new(testclass1, testclass2)
13
13
  end
@@ -21,9 +21,9 @@ RSpec.describe TestClass3 do
21
21
 
22
22
  context 'Scenario 2' do
23
23
  before do
24
- var_2167261360 = TestClass1.new("test")
25
- var_2167245200 = {hello: "world", test: var_2167261360, arr_1: [1, 2, 3, 4, 5, var_2167261360], sub_hash: {yes: true, obj: var_2167261360}}
26
- testclass1 = TestClass1.new(var_2167245200)
24
+ var_2190448620 = TestClass1.new("test")
25
+ var_2190448940 = {hello: "world", test: var_2190448620, arr_1: [1, 2, 3, 4, 5, var_2190448620], sub_hash: {yes: true, obj: var_2190448620}}
26
+ testclass1 = TestClass1.new(var_2190448940)
27
27
  testclass2 = TestClass2.new("This is message 2", nil)
28
28
  @fixture = TestClass3.new(testclass1, testclass2)
29
29
  end
@@ -6,11 +6,11 @@ RSpec.describe TestClass4 do
6
6
  context 'Scenario 1' do
7
7
  before do
8
8
  var_8 = nil
9
- var_2167163460 = Proc.new {
9
+ var_2190345740 = Proc.new {
10
10
  # Variable return values ... can't figure out what goes in here...
11
11
  }
12
12
 
13
- @fixture = TestClass4.new(&var_2167163460)
13
+ @fixture = TestClass4.new(&var_2190345740)
14
14
  end
15
15
 
16
16
  it 'should pass current expectations' do
@@ -9,7 +9,7 @@ RSpec.describe TestClassForAutoStub do
9
9
  end
10
10
 
11
11
  it 'should pass current expectations' do
12
- var_2165345620 = ["Hello Glorious world", "HI THERE!!!!"]
12
+ var_2161910460 = ["Hello Glorious world", "HI THERE!!!!"]
13
13
 
14
14
  allow_any_instance_of(ClassUsedByTestClass).to receive(:stubbed_method).and_return("Hello Glorious world")
15
15
  allow_any_instance_of(AnotherClassUsedByTestClass).to receive(:get_message).and_return("HI THERE!!!!")
@@ -9,7 +9,7 @@ RSpec.describe TestClassForMocks do
9
9
  end
10
10
 
11
11
  it 'should pass current expectations' do
12
- var_2165992020 = [2, 3, 4, 5]
12
+ var_2157696720 = [2, 3, 4, 5]
13
13
 
14
14
  allow_any_instance_of(TestMockSubClass).to receive(:test_method).and_return("a return string")
15
15
  allow_any_instance_of(TestMockSubClass).to receive(:increment_val).and_return(2, 3, 4, 5)
@@ -35,12 +35,12 @@ RSpec.describe TestClassForMocks do
35
35
  end
36
36
 
37
37
  it 'should pass current expectations' do
38
- var_2165878780 = {val: 1, str: "hello world", message: "a message"}
38
+ var_2181121160 = {val: 1, str: "hello world", message: "a message"}
39
39
 
40
- allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(var_2165878780)
40
+ allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(var_2181121160)
41
41
 
42
42
  # 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_2165878780)
43
+ expect( @fixture.method_with_usage3("a message") ).to eq(var_2181121160)
44
44
 
45
45
  end
46
46
  end
@@ -20,20 +20,20 @@ end
20
20
 
21
21
  class TestClass1Scenario2 < TestTestClass1
22
22
  def setup
23
- var_2173943420 = TestClass1.new("test")
24
- message = {hello: "world", test: var_2173943420, arr_1: [1, 2, 3, 4, 5, var_2173943420], sub_hash: {yes: true, obj: var_2173943420}}
23
+ var_2161877360 = TestClass1.new("test")
24
+ message = {hello: "world", test: var_2161877360, arr_1: [1, 2, 3, 4, 5, var_2161877360], sub_hash: {yes: true, obj: var_2161877360}}
25
25
  @fixture = TestClass1.new(message)
26
26
  end
27
27
 
28
28
  def test_current_expectation
29
29
  another_object = TestClass1.new("test")
30
- var_2172900980 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
31
- var_2166428520 = Proc.new { |message|
32
- var_2172900980
30
+ var_2157100180 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
31
+ var_2156893060 = Proc.new { |message|
32
+ var_2157100180
33
33
  }
34
34
 
35
35
  e = nil
36
- var_2166393560 = Proc.new {
36
+ var_2156861020 = Proc.new {
37
37
  # Variable return values ... can't figure out what goes in here...
38
38
  }
39
39
 
@@ -44,11 +44,11 @@ class TestClass1Scenario2 < TestTestClass1
44
44
  #TestClass1#print_message should return
45
45
  assert_nil @fixture.print_message
46
46
 
47
- #TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000102412190@example.rb:73>
48
- assert_equal var_2166428520, @fixture.set_block( &var_2166428520)
47
+ #TestClass1#set_block should return #<Pretentious::RecordedProc:0x000001011e3190@example.rb:73>
48
+ assert_equal var_2156893060, @fixture.set_block( &var_2156893060)
49
49
 
50
- #TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x00000103277af0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2173943480=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x00000103277af0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2173943480=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x00000103277af0 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2173943480=>"message"}>}}
51
- assert_equal var_2172900980, @fixture.call_block( &var_2166393560)
50
+ #TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x00000101b740d8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2161877400=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x00000101b740d8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2161877400=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x00000101b740d8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={2161877400=>"message"}>}}
51
+ assert_equal var_2157100180, @fixture.call_block( &var_2156861020)
52
52
 
53
53
  #TestClass1#something_is_wrong should return StandardError
54
54
  assert_raises(StandardError) { @fixture.something_is_wrong }
@@ -7,9 +7,9 @@ end
7
7
 
8
8
  class TestClass3Scenario1 < TestTestClass3
9
9
  def setup
10
- var_2173943420 = TestClass1.new("test")
11
- var_2172900980 = {hello: "world", test: var_2173943420, arr_1: [1, 2, 3, 4, 5, var_2173943420], sub_hash: {yes: true, obj: var_2173943420}}
12
- testclass1 = TestClass1.new(var_2172900980)
10
+ var_2161877360 = TestClass1.new("test")
11
+ var_2157100180 = {hello: "world", test: var_2161877360, arr_1: [1, 2, 3, 4, 5, var_2161877360], sub_hash: {yes: true, obj: var_2161877360}}
12
+ testclass1 = TestClass1.new(var_2157100180)
13
13
  testclass2 = TestClass2.new("This is message 2", nil)
14
14
  @fixture = TestClass3.new(testclass1, testclass2)
15
15
  end
@@ -24,9 +24,9 @@ end
24
24
 
25
25
  class TestClass3Scenario2 < TestTestClass3
26
26
  def setup
27
- var_2173943420 = TestClass1.new("test")
28
- var_2172900980 = {hello: "world", test: var_2173943420, arr_1: [1, 2, 3, 4, 5, var_2173943420], sub_hash: {yes: true, obj: var_2173943420}}
29
- testclass1 = TestClass1.new(var_2172900980)
27
+ var_2161877360 = TestClass1.new("test")
28
+ var_2157100180 = {hello: "world", test: var_2161877360, arr_1: [1, 2, 3, 4, 5, var_2161877360], sub_hash: {yes: true, obj: var_2161877360}}
29
+ testclass1 = TestClass1.new(var_2157100180)
30
30
  testclass2 = TestClass2.new("This is message 2", nil)
31
31
  @fixture = TestClass3.new(testclass1, testclass2)
32
32
  end
@@ -8,11 +8,11 @@ end
8
8
  class TestClass4Scenario1 < TestTestClass4
9
9
  def setup
10
10
  var_8 = nil
11
- var_2166489580 = Proc.new {
11
+ var_2156944080 = Proc.new {
12
12
  # Variable return values ... can't figure out what goes in here...
13
13
  }
14
14
 
15
- @fixture = TestClass4.new(&var_2166489580)
15
+ @fixture = TestClass4.new(&var_2156944080)
16
16
  end
17
17
 
18
18
  def test_current_expectation
@@ -11,7 +11,7 @@ class TestClassForMocksScenario1 < TestTestClassForMocks
11
11
  end
12
12
 
13
13
  def test_current_expectation
14
- var_2165696380 = [2, 3, 4, 5]
14
+ var_2162323640 = [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
@@ -39,11 +39,11 @@ class TestClassForMocksScenario2 < TestTestClassForMocks
39
39
  end
40
40
 
41
41
  def test_current_expectation
42
- var_2165567200 = {val: 1, str: "hello world", message: "a message"}
42
+ var_2162178880 = {val: 1, str: "hello world", message: "a message"}
43
43
 
44
- TestMockSubClass.stub_any_instance(:return_hash, var_2165567200) do
44
+ TestMockSubClass.stub_any_instance(:return_hash, var_2162178880) 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_2165567200, @fixture.method_with_usage3("a message")
46
+ assert_equal var_2162178880, @fixture.method_with_usage3("a message")
47
47
 
48
48
  end
49
49
 
data/test_classes.rb CHANGED
@@ -122,6 +122,24 @@ class TestClass4
122
122
 
123
123
  end
124
124
 
125
+ class TestClass5
126
+
127
+ def test_method
128
+ fibonacci = Fibonacci.new
129
+ fibonacci.fib(5)
130
+ end
131
+
132
+ def test_method2
133
+ fibonacci = Fibonacci.new
134
+ fibonacci.fib(9)
135
+ end
136
+
137
+ def self.class_test_method
138
+ fibonacci = Fibonacci.new
139
+ fibonacci.fib(6)
140
+ end
141
+ end
142
+
125
143
  class TestMockSubClass
126
144
 
127
145
  def initialize
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretentious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Emmanuel Dayo
@@ -131,6 +131,7 @@ files:
131
131
  - lib/pretentious/minitest_generator.rb
132
132
  - lib/pretentious/recorded_proc.rb
133
133
  - lib/pretentious/rspec_generator.rb
134
+ - lib/pretentious/trigger.rb
134
135
  - lib/pretentious/version.rb
135
136
  - pretentious.gemspec
136
137
  - run_test.sh