pretentious 0.2 → 0.2.1

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: f0ad59d1020d7aa1cf6df1664080617dadb649d6
4
- data.tar.gz: a1e0a3e083db31a8ddadee40312f4bc564e75bf1
3
+ metadata.gz: 5787f220ac2e658449fad7002732e5dadd51244b
4
+ data.tar.gz: 73571c6a0622e96f459de4c19de00f3d48f65d1e
5
5
  SHA512:
6
- metadata.gz: eca3b03454ca118c1b43f5812edbe06ac59ea474357dbb2c79ed5406529ccae21633270070cce17f169707ce4dc1ad7aa90143f9e9a0fea443f7df868f72cc72
7
- data.tar.gz: f791eb14e868c0c0cc181a516ce11a4898a0a92a6b99301b301844f471a5dbf1a87963f11ad306f0e8e5054ce8e7485461fa928a99aa688d90e5a33d0fc69eb9
6
+ metadata.gz: e930f042edb8400183b070447e497b3a6ce7d235cf078bcf09568a904289ba2d29da202667fe32752a52d37846a4a8cec5e7e640d555b682d47e86ac7e38658a
7
+ data.tar.gz: 7260dfdc09e5d9dc3b170c8d3a1a6f713edc930ba056aafba67707752a49a084a63498c46f586cff7dc144b154b832e75d6750bb982cb9842efa13eb56b6ad52
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 0.2.1 (2015-12-20)
2
+ Features:
3
+ - Allow regex to be used in specifying target classes
4
+
5
+ # 0.2 (2015-12-19)
6
+ Bugfixes:
7
+ - Fix constants not getting resolved
8
+
9
+ Features:
10
+ - support for pretentious.yml file
11
+ - Strings can now be passed to spec_for
12
+
1
13
  # 0.1.12 (2015-12-12)
2
14
  Bugfixes:
3
15
  - fix duplicate specs inside minitest
data/README.md CHANGED
@@ -7,18 +7,17 @@ On a serious note, this gem allows you to generate tests template used for "char
7
7
 
8
8
  ## Table of Contents
9
9
  1. [Installation](#installation)
10
- - [Usage](#usage)
11
- 1. [Using the pretentious.yml file](#using-pretentious.yml)
12
- 2. [Declarative generation without using example files](#declarative-generation-without-using-example-files)
13
- 3. [Minitest](#minitest)
14
-
15
- - [Handling complex parameters and object constructors](#handling-complex-parameters-and-object-constructors)
16
- 2. [Capturing Exceptions](#capturing-exceptions)
17
- 3. [Auto Stubbing](#auto-stubbing)
18
- 4. [Object Deconstruction Utility](#object-deconstruction-utility)
19
- 5. [Using the Object deconstructor in rails](#using-the-object-deconstructor-in-rails)
20
- 6. [Things to do after](#things-to-do-after)
21
- 7. [Limitations](#limitations)
10
+ 2. [Usage](#usage)
11
+ 3. [Using the pretentious.yml file](#using-pretentious.yml)
12
+ 4. [Declarative generation without using example files](#declarative-generation-without-using-example-files)
13
+ 5. [Minitest](#minitest)
14
+ 6. [Handling complex parameters and object constructors](#handling-complex-parameters-and-object-constructors)
15
+ 7. [Capturing Exceptions](#capturing-exceptions)
16
+ 8. [Auto Stubbing](#auto-stubbing)
17
+ 9. [Object Deconstruction Utility](#object-deconstruction-utility)
18
+ 10. [Using the Object deconstructor in rails](#using-the-object-deconstructor-in-rails)
19
+ 11. [Things to do after](#things-to-do-after)
20
+ 12. [Limitations](#limitations)
22
21
 
23
22
  ## Installation
24
23
  Add this line to your application's Gemfile:
@@ -165,7 +164,7 @@ end
165
164
 
166
165
  awesome!
167
166
 
168
- You can also try this out with built-in libraries like MD5 for example ...
167
+ You can also try this out with libraries like MD5 for example ...
169
168
 
170
169
  ```ruby
171
170
  #example.rb
@@ -198,8 +197,10 @@ If you run pretentious without passing an example file, it will look for pretent
198
197
 
199
198
  ```YAML
200
199
  # Sample pretentious targets file
200
+ # use $ to pass a regex or a ruby code that evals to a string
201
201
  targets:
202
202
  - class: Meme
203
+ - class: $/^TestClass/
203
204
  generators:
204
205
  - rspec
205
206
  - minitest
@@ -262,6 +263,20 @@ end
262
263
 
263
264
  IMPORTANT: If using rails or if it is part of a larger app, make sure to enable this only when you intend to generate specs! delete the initializer or comment the code out when it is not needed.
264
265
 
266
+ If the class is still to be defined, you may pass the name of the class as a string instead. However, calls to class methods can't be reliably captured in this manner:
267
+
268
+ ```ruby
269
+ Pretentious.on(UsersController).method_called(:login).spec_for("UserAuthentication")
270
+ ```
271
+
272
+ Of course, you call also pass a regex if you want to auto generate classes via some name convention:
273
+
274
+ ```ruby
275
+ Pretentious.on(UsersController).method_called(:login).spec_for(/^User/)
276
+ ```
277
+
278
+ Classes starting with User will now be watched (e.g. UserController, UserProfile etc.)
279
+
265
280
  ## Minitest
266
281
  The minitest test framework is also supported, simply use Pretentious.minitest_for instead
267
282
 
data/bin/pretentious CHANGED
@@ -56,7 +56,12 @@ if filename.nil?
56
56
  targets_file = YAML.load_file('pretentious.yml')
57
57
  targets_file['targets'].each do |target|
58
58
  puts "generate for #{target['class']}"
59
- Pretentious::LazyTrigger.new(target['class'], {})
59
+ if target['class'].start_with?('$')
60
+ target['class'][0] = ''
61
+ Pretentious::LazyTrigger.new(eval(target['class']), {})
62
+ else
63
+ Pretentious::LazyTrigger.new(target['class'], {})
64
+ end
60
65
  end
61
66
 
62
67
  Pretentious.watch {
data/lib/pretentious.rb CHANGED
@@ -13,12 +13,34 @@ require 'pretentious/utils/file_writer'
13
13
 
14
14
  Class.class_eval do
15
15
  def _stub(*classes)
16
- @classes = classes
16
+ @stub_classes = classes
17
17
  self
18
18
  end
19
19
 
20
- def _get_mock_classes
21
- @classes
20
+ def _get_stub_classes
21
+ @stub_classes
22
+ end
23
+ end
24
+
25
+ Regexp.class_eval do
26
+ def _stub(*classes)
27
+ @stub_classes = classes
28
+ self
29
+ end
30
+
31
+ def _get_stub_classes
32
+ @stub_classes
33
+ end
34
+ end
35
+
36
+ String.class_eval do
37
+ def _stub(*classes)
38
+ @stub_classes = classes
39
+ self
40
+ end
41
+
42
+ def _get_stub_classes
43
+ @stub_classes
22
44
  end
23
45
  end
24
46
 
@@ -384,17 +384,17 @@ module Pretentious
384
384
  mock_dict = {}
385
385
 
386
386
  klasses_or_instances.each do |klass_or_instance|
387
- if klass_or_instance.is_a? String
388
- Pretentious::LazyTrigger.new(klass_or_instance, {})
387
+ if klass_or_instance.is_a?(String) || klass_or_instance.is_a?(Regexp)
388
+ Pretentious::LazyTrigger.new(klass_or_instance, stubs: klass_or_instance._get_stub_classes)
389
389
  else
390
390
  klass = klass_or_instance.class == Class ? klass_or_instance : klass_or_instance.class
391
391
  klasses << replace_class(klass)
392
392
 
393
393
  mock_klasses = []
394
394
 
395
- klass._get_mock_classes.each do |mock_klass|
395
+ klass._get_stub_classes.each do |mock_klass|
396
396
  mock_klasses << replace_class(mock_klass, true)
397
- end unless klass._get_mock_classes.nil?
397
+ end unless klass._get_stub_classes.nil?
398
398
 
399
399
  mock_dict[klass] = mock_klasses
400
400
  end
@@ -39,11 +39,21 @@ module Pretentious
39
39
  @targets[target.stand_in_klass] = target unless @targets.include? target.stand_in_klass
40
40
  end
41
41
 
42
+ def match(value)
43
+ if @target_class.is_a? Regexp
44
+ @target_class.match(value)
45
+ elsif @target_class.is_a? String
46
+ @target_class == value
47
+ else
48
+ @target_class.to_s == value
49
+ end
50
+ end
51
+
42
52
  class << self
43
53
  def lookup(class_name)
44
54
  @instances ||= []
45
55
  @instances.each do |instance|
46
- return instance if instance.target_class == class_name
56
+ return instance if instance.match(class_name)
47
57
  end
48
58
  nil
49
59
  end
@@ -119,7 +119,7 @@ module Pretentious
119
119
  params_collection << mock_block[:result]
120
120
  end if block[:context]
121
121
  end
122
- end
122
+ end if method_calls
123
123
 
124
124
  if params_collection.size > 0
125
125
  deps = declare_dependencies(context, params_collection, 2)
@@ -144,7 +144,6 @@ module Pretentious
144
144
  indentation = ''
145
145
  indentation_level.times { indentation << @_indentation }
146
146
  method_calls.each_key do |k|
147
-
148
147
  info_blocks_arr = method_calls[k]
149
148
 
150
149
  info_blocks_arr.each do |block|
@@ -159,7 +158,7 @@ module Pretentious
159
158
  str << "#{indentation}#{generate_expectation(context, fixture, k, block[:params], block[:block], block[:result])}\n"
160
159
  expectations << str unless expectations.include? str
161
160
  end
162
- end
161
+ end if method_calls
163
162
  expectations.join("\n")
164
163
  end
165
164
 
@@ -1,4 +1,4 @@
1
1
  # Pretentious - version
2
2
  module Pretentious
3
- VERSION = '0.2'
3
+ VERSION = '0.2.1'
4
4
  end
data/pretentious.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  # Sample pretentious targets file
2
+ # use $ to pass a regex or a ruby code that evals to a string
2
3
  targets:
3
4
  - class: Meme
5
+ - class: $/^TestClass/
4
6
  generators:
5
7
  - rspec
6
8
  - minitest
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.2.gem
5
+ gem install pretentious-0.2.1.gem
6
6
  ruby test/test_generator.rb
data/sample.rb CHANGED
@@ -11,3 +11,27 @@ end
11
11
  meme = Meme.new
12
12
  meme.i_can_has_cheezburger?
13
13
  meme.will_it_blend?
14
+
15
+ class TestClassR1
16
+ SOME_CONSTANT = "CONST"
17
+
18
+ def hello
19
+ end
20
+ end
21
+
22
+ class TestClassR2
23
+ def hello_again
24
+ "hi"
25
+ end
26
+
27
+ def pass_message(message)
28
+ "#{message} #{TestClassR1::SOME_CONSTANT}"
29
+ end
30
+ end
31
+
32
+ test_class1 = TestClassR1.new
33
+ test_class1.hello
34
+
35
+ test_class2 = TestClassR2.new
36
+ test_class2.hello_again
37
+ test_class2.pass_message("a message")
@@ -16,16 +16,16 @@ RSpec.describe TestClass1 do
16
16
  context 'Scenario 2' do
17
17
  before do
18
18
  @another_object = TestClass1.new('test')
19
- @message = { hello: 'world', test: @another_object, arr_1: [1, 2, 3, 4, 5, @another_object], sub_hash: { yes: true, obj: @another_object } }
20
- @fixture = TestClass1.new(@message)
19
+ @a = { hello: 'world', test: @another_object, arr_1: [1, 2, 3, 4, 5, @another_object], sub_hash: { yes: true, obj: @another_object } }
20
+ @fixture = TestClass1.new(@a)
21
21
  end
22
22
 
23
23
  it 'should pass current expectations' do
24
24
  a = proc { |message|
25
- @message
25
+ @a
26
26
  }
27
27
 
28
- filewriter = nil
28
+ test_class1 = nil
29
29
  b = proc {
30
30
  # Variable return values ... can't figure out what goes in here...
31
31
  }
@@ -36,8 +36,8 @@ RSpec.describe TestClass1 do
36
36
  # TestClass1#set_block should return a
37
37
  expect(@fixture.set_block &a).to eq(a)
38
38
 
39
- # TestClass1#call_block should return @message
40
- expect(@fixture.call_block &b).to eq(@message)
39
+ # TestClass1#call_block should return @a
40
+ expect(@fixture.call_block &b).to eq(@a)
41
41
 
42
42
  # TestClass1#something_is_wrong should return e
43
43
  expect { @fixture.something_is_wrong }.to raise_error
@@ -54,20 +54,20 @@ RSpec.describe TestClass1 do
54
54
 
55
55
  it 'should pass current expectations' do
56
56
  another_object = TestClass1.new('test')
57
- # TestClass1#return_self when passed message = #<TestClass1:0x000000012b4098> should return another_object
57
+ # TestClass1#return_self when passed message = #<TestClass1:0x0000000119e0c8> should return another_object
58
58
  expect(@fixture.return_self(another_object)).to eq(another_object)
59
59
  end
60
60
  end
61
61
 
62
62
  context 'Scenario 4' do
63
63
  before do
64
- @message = TestClass1.new('test')
65
- @fixture = TestClass1.new(@message)
64
+ @another_object = TestClass1.new('test')
65
+ @fixture = TestClass1.new(@another_object)
66
66
  end
67
67
 
68
68
  it 'should pass current expectations' do
69
- # TestClass1#message should return @message
70
- expect(@fixture.message).to eq(@message)
69
+ # TestClass1#message should return @another_object
70
+ expect(@fixture.message).to eq(@another_object)
71
71
  end
72
72
  end
73
73
  end
@@ -24,14 +24,14 @@ RSpec.describe TestClass2 do
24
24
 
25
25
  context 'Scenario 3' do
26
26
  before do
27
- @message2 = 'This is message 3'
28
- message = TestClass2.new(@message2, nil)
29
- @fixture = TestClass2.new(message, @message2)
27
+ @message3 = 'This is message 3'
28
+ t = TestClass2.new(@message3, nil)
29
+ @fixture = TestClass2.new(t, @message3)
30
30
  end
31
31
 
32
32
  it 'should pass current expectations' do
33
33
  # TestClass2#test when passed object = "This is message 3" should return 'This is message 3'
34
- expect(@fixture.test(@message2)).to eq(@message2)
34
+ expect(@fixture.test(@message3)).to eq(@message3)
35
35
  end
36
36
  end
37
37
  end
@@ -6,9 +6,9 @@ RSpec.describe TestClass3 do
6
6
  before do
7
7
  another_object = TestClass1.new('test')
8
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
- testclass2 = TestClass2.new('This is message 2', nil)
11
- @fixture = TestClass3.new(testclass1, testclass2)
9
+ test_class_one = TestClass1.new(b)
10
+ test_class_two = TestClass2.new('This is message 2', nil)
11
+ @fixture = TestClass3.new(test_class_one, test_class_two)
12
12
  end
13
13
 
14
14
  it 'should pass current expectations' do
@@ -21,9 +21,9 @@ RSpec.describe TestClass3 do
21
21
  before do
22
22
  another_object = TestClass1.new('test')
23
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
- testclass2 = TestClass2.new('This is message 2', nil)
26
- @fixture = TestClass3.new(testclass1, testclass2)
24
+ test_class_one = TestClass1.new(b)
25
+ test_class_two = TestClass2.new('This is message 2', nil)
26
+ @fixture = TestClass3.new(test_class_one, test_class_two)
27
27
  end
28
28
 
29
29
  it 'should pass current expectations' do
@@ -4,12 +4,11 @@ require 'spec_helper'
4
4
  RSpec.describe TestClass4 do
5
5
  context 'Scenario 1' do
6
6
  before do
7
- c = nil
8
- d = proc {
9
- # Variable return values ... can't figure out what goes in here...
7
+ b = proc {
8
+ 'test'
10
9
  }
11
10
 
12
- @fixture = TestClass4.new(&d)
11
+ @fixture = TestClass4.new(&b)
13
12
  end
14
13
 
15
14
  it 'should pass current expectations' do
@@ -0,0 +1,16 @@
1
+ # This file was automatically generated by the pretentious gem
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe TestClassR1 do
5
+ context 'Scenario 1' do
6
+ before do
7
+ @fixture = TestClassR1.new
8
+ end
9
+
10
+ it 'should pass current expectations' do
11
+ # TestClassR1#hello should return nil
12
+ expect(@fixture.hello).to be_nil
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,18 @@
1
+ # This file was automatically generated by the pretentious gem
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe TestClassR2 do
5
+ context 'Scenario 1' do
6
+ before do
7
+ @fixture = TestClassR2.new
8
+ end
9
+
10
+ it 'should pass current expectations' do
11
+ # TestClassR2#hello_again should return 'hi'
12
+ expect(@fixture.hello_again).to eq('hi')
13
+
14
+ # TestClassR2#pass_message when passed message = "a message" should return 'a message CONST'
15
+ expect(@fixture.pass_message('a message')).to eq('a message CONST')
16
+ end
17
+ end
18
+ end
@@ -32,4 +32,26 @@ RSpec.describe Pretentious::LazyTrigger do
32
32
  end
33
33
  expect(call_artifacts).to eq({TestLazyClass2=>{:output=>"# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe TestLazyClass2 do\n context 'Scenario 1' do\n before do\n @fixture = TestLazyClass2.new\n end\n\n it 'should pass current expectations' do\n # TestLazyClass2#test_method should return nil\n expect(@fixture.test_method).to be_nil\n end\n end\nend", :generator=>Pretentious::RspecGenerator}})
34
34
  end
35
+
36
+ it "can use regex to perform a match on the class name" do
37
+ call_artifacts = Pretentious::Generator.generate_for(/^TestLazyClassR/) do
38
+ class TestLazyClassR1
39
+ def test_method
40
+ end
41
+ end
42
+
43
+ class TestLazyClassR2
44
+ def test_method
45
+ end
46
+ end
47
+
48
+ lazy_class1 = TestLazyClassR1.new
49
+ lazy_class1.test_method
50
+
51
+ lazy_class2 = TestLazyClassR2.new
52
+ lazy_class2.test_method
53
+ end
54
+
55
+ expect(call_artifacts).to eq({ TestLazyClassR1 => { :output => "# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe TestLazyClassR1 do\n context 'Scenario 1' do\n before do\n @fixture = TestLazyClassR1.new\n end\n\n it 'should pass current expectations' do\n # TestLazyClassR1#test_method should return nil\n expect(@fixture.test_method).to be_nil\n end\n end\nend", :generator=>Pretentious::RspecGenerator}, TestLazyClassR2=>{:output=>"# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe TestLazyClassR2 do\n context 'Scenario 1' do\n before do\n @fixture = TestLazyClassR2.new\n end\n\n it 'should pass current expectations' do\n # TestLazyClassR2#test_method should return nil\n expect(@fixture.test_method).to be_nil\n end\n end\nend", :generator=>Pretentious::RspecGenerator}})
56
+ end
35
57
  end
@@ -11,7 +11,7 @@ RSpec.describe Pretentious::Generator do
11
11
 
12
12
  it "classes should have a stub class section" do
13
13
  Fibonacci._stub(String)
14
- expect(Fibonacci._get_mock_classes).to eq([String])
14
+ expect(Fibonacci._get_stub_classes).to eq([String])
15
15
  end
16
16
 
17
17
  it "tracks object calls" do
@@ -18,7 +18,7 @@ RSpec.describe Pretentious::Generator do
18
18
 
19
19
  it "classes should have a stub class section" do
20
20
  Fibonacci._stub(String)
21
- expect(Fibonacci._get_mock_classes).to eq([String])
21
+ expect(Fibonacci._get_stub_classes).to eq([String])
22
22
  end
23
23
 
24
24
  it "tracks object calls" do
@@ -19,16 +19,16 @@ end
19
19
  class TestClass1Scenario2 < TestClass1Test
20
20
  def setup
21
21
  @another_object = TestClass1.new('test')
22
- @message = { hello: 'world', test: @another_object, arr_1: [1, 2, 3, 4, 5, @another_object], sub_hash: { yes: true, obj: @another_object } }
23
- @fixture = TestClass1.new(@message)
22
+ @a = { hello: 'world', test: @another_object, arr_1: [1, 2, 3, 4, 5, @another_object], sub_hash: { yes: true, obj: @another_object } }
23
+ @fixture = TestClass1.new(@a)
24
24
  end
25
25
 
26
26
  def test_current_expectation
27
27
  a = proc { |message|
28
- @message
28
+ @a
29
29
  }
30
30
 
31
- filewriter = nil
31
+ test_class1 = nil
32
32
  b = proc {
33
33
  # Variable return values ... can't figure out what goes in here...
34
34
  }
@@ -40,8 +40,8 @@ class TestClass1Scenario2 < TestClass1Test
40
40
  # TestClass1#set_block should return a
41
41
  assert_equal a, @fixture.set_block( &a)
42
42
 
43
- # TestClass1#call_block should return @message
44
- assert_equal @message, @fixture.call_block( &b)
43
+ # TestClass1#call_block should return @a
44
+ assert_equal @a, @fixture.call_block( &b)
45
45
 
46
46
  # TestClass1#something_is_wrong should return e
47
47
  assert_raises(StandardError) { @fixture.something_is_wrong }
@@ -59,19 +59,19 @@ class TestClass1Scenario3 < TestClass1Test
59
59
  def test_current_expectation
60
60
  another_object = TestClass1.new('test')
61
61
 
62
- # TestClass1#return_self when passed message = #<TestClass1:0x0000000214e978> should return another_object
62
+ # TestClass1#return_self when passed message = #<TestClass1:0x00000001174fe8> should return another_object
63
63
  assert_equal another_object, @fixture.return_self(another_object)
64
64
  end
65
65
  end
66
66
 
67
67
  class TestClass1Scenario4 < TestClass1Test
68
68
  def setup
69
- @message = TestClass1.new('test')
70
- @fixture = TestClass1.new(@message)
69
+ @another_object = TestClass1.new('test')
70
+ @fixture = TestClass1.new(@another_object)
71
71
  end
72
72
 
73
73
  def test_current_expectation
74
- # TestClass1#message should return @message
75
- assert_equal @message, @fixture.message
74
+ # TestClass1#message should return @another_object
75
+ assert_equal @another_object, @fixture.message
76
76
  end
77
77
  end
@@ -27,13 +27,13 @@ end
27
27
 
28
28
  class TestClass2Scenario3 < TestClass2Test
29
29
  def setup
30
- @message2 = 'This is message 3'
31
- message = TestClass2.new(@message2, nil)
32
- @fixture = TestClass2.new(message, @message2)
30
+ @message3 = 'This is message 3'
31
+ t = TestClass2.new(@message3, nil)
32
+ @fixture = TestClass2.new(t, @message3)
33
33
  end
34
34
 
35
35
  def test_current_expectation
36
36
  # TestClass2#test when passed object = "This is message 3" should return 'This is message 3'
37
- assert_equal 'This is message 3', @fixture.test(@message2)
37
+ assert_equal 'This is message 3', @fixture.test(@message3)
38
38
  end
39
39
  end
@@ -9,9 +9,9 @@ class TestClass3Scenario1 < TestClass3Test
9
9
  def setup
10
10
  another_object = TestClass1.new('test')
11
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
- testclass2 = TestClass2.new('This is message 2', nil)
14
- @fixture = TestClass3.new(testclass1, testclass2)
12
+ test_class_one = TestClass1.new(b)
13
+ test_class_two = TestClass2.new('This is message 2', nil)
14
+ @fixture = TestClass3.new(test_class_one, test_class_two)
15
15
  end
16
16
 
17
17
  def test_current_expectation
@@ -24,9 +24,9 @@ class TestClass3Scenario2 < TestClass3Test
24
24
  def setup
25
25
  another_object = TestClass1.new('test')
26
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)
28
- testclass2 = TestClass2.new('This is message 2', nil)
29
- @fixture = TestClass3.new(testclass1, testclass2)
27
+ test_class_one = TestClass1.new(b)
28
+ test_class_two = TestClass2.new('This is message 2', nil)
29
+ @fixture = TestClass3.new(test_class_one, test_class_two)
30
30
  end
31
31
 
32
32
  def test_current_expectation
@@ -7,12 +7,11 @@ end
7
7
 
8
8
  class TestClass4Scenario1 < TestClass4Test
9
9
  def setup
10
- c = nil
11
- d = proc {
12
- # Variable return values ... can't figure out what goes in here...
10
+ b = proc {
11
+ 'test'
13
12
  }
14
13
 
15
- @fixture = TestClass4.new(&d)
14
+ @fixture = TestClass4.new(&b)
16
15
  end
17
16
 
18
17
  def test_current_expectation
@@ -0,0 +1,22 @@
1
+ # This file was automatically generated by the pretentious gem
2
+ require 'minitest_helper'
3
+ require 'minitest/autorun'
4
+
5
+ class TestClassR1Test < Minitest::Test
6
+ end
7
+
8
+ class TestClassR1Scenario1 < TestClassR1Test
9
+ def setup
10
+ @fixture = TestClassR1.new
11
+ end
12
+
13
+ def test_current_expectation
14
+ # TestClassR1#hello should return nil
15
+ assert_nil @fixture.hello
16
+ end
17
+ end
18
+
19
+ class TestClassR1ImpostorScenario2 < TestClassR1Test
20
+ def test_current_expectation
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ # This file was automatically generated by the pretentious gem
2
+ require 'minitest_helper'
3
+ require 'minitest/autorun'
4
+
5
+ class TestClassR2Test < Minitest::Test
6
+ end
7
+
8
+ class TestClassR2Scenario1 < TestClassR2Test
9
+ def setup
10
+ @fixture = TestClassR2.new
11
+ end
12
+
13
+ def test_current_expectation
14
+ # TestClassR2#hello_again should return 'hi'
15
+ assert_equal 'hi', @fixture.hello_again
16
+
17
+ # TestClassR2#pass_message when passed message = "a message" should return 'a message CONST'
18
+ assert_equal 'a message CONST', @fixture.pass_message('a message')
19
+ end
20
+ end
data/test_classes.rb CHANGED
@@ -244,5 +244,21 @@ class TestClassForAutoStub
244
244
  return_values << @class_to_be_used2.get_message
245
245
  return_values
246
246
  end
247
+ end
248
+
249
+ class TestClassR1
250
+ SOME_CONSTANT = "CONST"
251
+
252
+ def hello
253
+ end
254
+ end
255
+
256
+ class TestClassR2
257
+ def hello_again
258
+ "hi"
259
+ end
247
260
 
261
+ def pass_message(message)
262
+ "#{message} #{TestClassR1::SOME_CONSTANT}"
263
+ end
248
264
  end
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.2'
4
+ version: 0.2.1
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-19 00:00:00.000000000 Z
11
+ date: 2015-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller
@@ -195,6 +195,8 @@ files:
195
195
  - spec/generated/test_class4_spec.rb
196
196
  - spec/generated/test_class_for_auto_stub_spec.rb
197
197
  - spec/generated/test_class_for_mocks_spec.rb
198
+ - spec/generated/test_class_r1_spec.rb
199
+ - spec/generated/test_class_r2_spec.rb
198
200
  - spec/generator_spec.rb
199
201
  - spec/lazy_trigger_spec.rb
200
202
  - spec/minitest_generator_spec.rb
@@ -209,6 +211,8 @@ files:
209
211
  - test/generated/test_test_class3.rb
210
212
  - test/generated/test_test_class4.rb
211
213
  - test/generated/test_test_class_for_mocks.rb
214
+ - test/generated/test_test_class_r1.rb
215
+ - test/generated/test_test_class_r2.rb
212
216
  - test/minitest_helper.rb
213
217
  - test/test_generator.rb
214
218
  - test_classes.rb
@@ -248,6 +252,8 @@ test_files:
248
252
  - spec/generated/test_class4_spec.rb
249
253
  - spec/generated/test_class_for_auto_stub_spec.rb
250
254
  - spec/generated/test_class_for_mocks_spec.rb
255
+ - spec/generated/test_class_r1_spec.rb
256
+ - spec/generated/test_class_r2_spec.rb
251
257
  - spec/generator_spec.rb
252
258
  - spec/lazy_trigger_spec.rb
253
259
  - spec/minitest_generator_spec.rb
@@ -262,5 +268,7 @@ test_files:
262
268
  - test/generated/test_test_class3.rb
263
269
  - test/generated/test_test_class4.rb
264
270
  - test/generated/test_test_class_for_mocks.rb
271
+ - test/generated/test_test_class_r1.rb
272
+ - test/generated/test_test_class_r2.rb
265
273
  - test/minitest_helper.rb
266
274
  - test/test_generator.rb