pretentious 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e6d60c4c39c880e0e4ab184b851c413f8db136a
4
- data.tar.gz: b4c690ef71ddd7b0f2ed066feebd5a918e47afac
3
+ metadata.gz: ad7ffc54896b981b06cc3c99e0bf0830bbedcd55
4
+ data.tar.gz: b97864d3c92ece3721f5dc26769ce493010f12d7
5
5
  SHA512:
6
- metadata.gz: 2c7bc395e8f3260c7b4b7cb8f1e5b8df457461279ae3816d7970d15aa34a8bc508e6f0dfb3a4e3278961b24e6a94372401c9d6f0031efe6c352cfdbba769a599
7
- data.tar.gz: 58195f4cc3b42154f6d894d5dd5fa3d0900c6ce4e4a5f991f3deda40a3682605b9388d866c3a7507bd3131e32da2a82e3b2b46dd6901e363b33bed1f340f0d29
6
+ metadata.gz: e87e16f197e827a41cb33f1c0c7490470a765fcc547c0295a66acce3fa013e98774f531f99d41791df87fd48d449d99449e4e19e192c29980e8152cfee7bd24e
7
+ data.tar.gz: 1de33c5ded9cb5c9d9456ad6e5cf01bc0a5a0a8c44c9bf3eea8d4c60ccd9ef05f481620b0e406f4e730010855987164d4b9c0221647cbe7d7a277bcb42f0ad91
data/CHANGELOG.md CHANGED
@@ -1,10 +1,20 @@
1
+ ## 0.1.11 (2015-12-12)
2
+
3
+ Bugfixes:
4
+
5
+ - fix code style
6
+
7
+ Features:
8
+
9
+ - matchers should now prefer variable references in assertions if previously declared
10
+
1
11
  ## 0.1.10 (2015-12-11)
2
12
 
3
13
  Bugfixes:
4
14
 
5
15
  - fix regression wherein method_missing is not handled properly
6
16
 
7
- Featuers:
17
+ Features:
8
18
 
9
19
  - Fix weird generated comments
10
20
 
@@ -47,16 +47,8 @@ module Pretentious
47
47
  end
48
48
 
49
49
  def pick_name(object_id, value = :no_value_passed)
50
- object_id_to_declared_names = {}
51
-
52
- if @declared_names
53
- @declared_names.each do |k, v|
54
- object_id_to_declared_names[v[:object_id]] = k if v
55
- end
56
- end
57
-
58
- # return immediately if already mapped
59
- return object_id_to_declared_names[object_id] if object_id_to_declared_names.include? object_id
50
+ var_name = map_name(object_id)
51
+ return var_name if var_name
60
52
 
61
53
  var_name = "var_#{object_id}"
62
54
 
@@ -99,6 +91,20 @@ module Pretentious
99
91
  Pretentious.value_ize(self, value)
100
92
  end
101
93
 
94
+ def map_name(object_id)
95
+ object_id_to_declared_names = {}
96
+
97
+ if @declared_names
98
+ @declared_names.each do |k, v|
99
+ object_id_to_declared_names[v[:object_id]] = k if v
100
+ end
101
+ end
102
+
103
+ # return immediately if already mapped
104
+ return object_id_to_declared_names[object_id] if object_id_to_declared_names.include? object_id
105
+ nil
106
+ end
107
+
102
108
  private
103
109
 
104
110
  def provide_name
@@ -369,19 +369,16 @@ module Pretentious
369
369
 
370
370
  generator = test_generator.new
371
371
  generator.begin_spec(klass)
372
- num = 1
373
372
 
374
- new_standin_klass._instances.each do |instance|
375
- generator.generate(instance, num)
376
- num += 1
377
- end unless new_standin_klass._instances.nil?
373
+ generator.body(new_standin_klass._instances) unless new_standin_klass._instances.nil?
378
374
 
379
375
  generator.end_spec
380
376
 
381
377
  result = all_results[klass]
382
378
  all_results[klass] = [] if result.nil?
383
379
 
384
- all_results[klass] = { output: generator.output, generator: generator.class }
380
+ result_output = generator.output.is_a?(String) ? generator.output.chomp : generator.output
381
+ all_results[klass] = { output: result_output, generator: generator.class }
385
382
  end unless klasses.nil?
386
383
 
387
384
  all_results
@@ -35,6 +35,14 @@ module Pretentious
35
35
  [context, declarations]
36
36
  end
37
37
 
38
+ def body(instances)
39
+ specs = []
40
+ instances.each_with_index do |instance, num|
41
+ specs << generate(instance, num + 1)
42
+ end
43
+ buffer_inline(specs.join("\n"))
44
+ end
45
+
38
46
  protected
39
47
 
40
48
  def declare_dependencies(context, args, level)
@@ -90,5 +98,13 @@ module Pretentious
90
98
  def whitespace(level = 0)
91
99
  @output_buffer << "#{indentation(level)}\n"
92
100
  end
101
+
102
+ def prettify_method_name(method_name)
103
+ if method_name.to_s.end_with? '='
104
+ "#{method_name.to_s.chop} = "
105
+ else
106
+ method_name.to_s
107
+ end
108
+ end
93
109
  end
94
110
  end
@@ -5,7 +5,7 @@ module Pretentious
5
5
  @test_class = test_class
6
6
  buffer('# This file was automatically generated by the pretentious gem')
7
7
  buffer("require 'minitest_helper'")
8
- buffer('require "minitest/autorun"')
8
+ buffer("require 'minitest/autorun'")
9
9
  whitespace
10
10
  buffer("class #{test_class.name}Test < Minitest::Test")
11
11
  buffer('end')
@@ -19,21 +19,24 @@ module Pretentious
19
19
  @output_buffer
20
20
  end
21
21
 
22
+ private
23
+
22
24
  def generate(test_instance, instance_count)
25
+ output_buffer = ''
23
26
  if test_instance.is_a? Class
24
- buffer("class #{test_instance.test_class.name}Scenario#{instance_count} < #{@test_class.name}Test", 0)
27
+ buffer_to_string(output_buffer, "class #{test_instance.test_class.name}Scenario#{instance_count} < #{@test_class.name}Test", 0)
25
28
 
26
29
  # class methods
27
30
  class_method_calls = test_instance.method_calls_by_method
28
31
  context = Pretentious::Context.new(test_instance.let_variables)
29
- buffer(generate_specs(context, "#{test_instance.test_class.name}::",
32
+ buffer_inline_to_string(output_buffer, generate_specs(context, "#{test_instance.test_class.name}::",
30
33
  test_instance.test_class.name, class_method_calls))
31
34
 
32
- buffer('end', 0)
35
+ buffer_to_string(output_buffer, 'end', 0)
33
36
  else
34
- buffer("class #{test_instance.test_class.name}Scenario#{instance_count} < #{@test_class.name}Test", 0)
37
+ buffer_to_string(output_buffer, "class #{test_instance.test_class.name}Scenario#{instance_count} < #{@test_class.name}Test", 0)
35
38
 
36
- buffer('def setup', 1)
39
+ buffer_to_string(output_buffer, 'def setup', 1)
37
40
 
38
41
  context, declarations = setup_fixture(test_instance)
39
42
 
@@ -41,19 +44,17 @@ module Pretentious
41
44
  specs_buffer = generate_specs(context.subcontext(declarations[:declaration]), "#{test_instance.test_class.name}#",
42
45
  '@fixture', method_calls)
43
46
  context.declared_names = {}
44
- buffer_inline(@deconstructor.build_output(context, 2 * @_indentation.length, declarations))
45
- buffer('end', 1)
46
- whitespace
47
+ buffer_inline_to_string(output_buffer, @deconstructor.build_output(context, 2 * @_indentation.length, declarations))
48
+ buffer_to_string(output_buffer, 'end', 1)
49
+ buffer_to_string(output_buffer, '')
47
50
 
48
- buffer_inline(specs_buffer)
51
+ buffer_inline_to_string(output_buffer, specs_buffer)
49
52
 
50
- buffer('end', 0)
51
- whitespace
53
+ buffer_to_string(output_buffer, 'end', 0)
52
54
  end
55
+ output_buffer
53
56
  end
54
57
 
55
- private
56
-
57
58
  def proc_function_generator(block, method)
58
59
  "func_#{method}(#{Pretentious::Deconstructor.block_params_generator(block)})"
59
60
  end
@@ -71,7 +72,7 @@ module Pretentious
71
72
  end
72
73
 
73
74
  statement = if params.size > 0
74
- "#{fixture}.#{method}(#{params_generator(context, params)})#{block_source}"
75
+ "#{fixture}.#{prettify_method_name method}(#{params_generator(context, params)})#{block_source}"
75
76
  else
76
77
  stmt = []
77
78
  m_stmt = "#{fixture}.#{method}"
@@ -16,36 +16,37 @@ module Pretentious
16
16
  @output_buffer
17
17
  end
18
18
 
19
+ private
20
+
19
21
  def generate(test_instance, instance_count)
22
+ output_buffer = ''
20
23
  if test_instance.is_a? Class
21
24
  context = Pretentious::Context.new(test_instance.let_variables)
22
25
  # class methods
23
26
  class_method_calls = test_instance.method_calls_by_method
24
- buffer(generate_specs(context, "#{test_instance.test_class.name}::", test_instance.test_class.name,
27
+ buffer_inline_to_string(output_buffer, generate_specs(0, context, "#{test_instance.test_class.name}::", test_instance.test_class.name,
25
28
  class_method_calls))
26
29
  else
27
- buffer("context 'Scenario #{instance_count}' do", 1)
30
+ buffer_to_string(output_buffer, "context 'Scenario #{instance_count}' do", 1)
28
31
 
29
- buffer('before do', 2)
32
+ buffer_to_string(output_buffer, 'before do', 2)
30
33
 
31
34
  context, declarations = setup_fixture(test_instance)
32
35
  method_calls = test_instance.method_calls_by_method
33
36
  spec_context = context.subcontext(declarations[:declaration])
34
- specs_buffer = generate_specs(spec_context, "#{test_instance.test_class.name}#", "@fixture", method_calls)
37
+ specs_buffer = generate_specs(1, spec_context, "#{test_instance.test_class.name}#", "@fixture", method_calls)
35
38
  context.declared_names = {}
36
39
  deconstruct_output = @deconstructor.build_output(context, 3 * @_indentation.length, declarations)
37
40
 
38
- buffer_inline(deconstruct_output)
39
- buffer('end', 2)
40
- whitespace
41
- buffer_inline(specs_buffer)
42
- buffer('end', 1)
43
- whitespace
41
+ buffer_inline_to_string(output_buffer, deconstruct_output)
42
+ buffer_to_string(output_buffer, 'end', 2)
43
+ buffer_to_string(output_buffer, '')
44
+ buffer_inline_to_string(output_buffer, specs_buffer)
45
+ buffer_to_string(output_buffer, 'end', 1)
44
46
  end
47
+ output_buffer
45
48
  end
46
49
 
47
- private
48
-
49
50
  def proc_function_generator(block, method)
50
51
  "func_#{method}(#{Pretentious::Deconstructor.block_params_generator(block)})"
51
52
  end
@@ -54,7 +55,7 @@ module Pretentious
54
55
  " &#{context.pick_name(block.target_proc.object_id)}"
55
56
  end
56
57
 
57
- def generate_expectation(context, fixture, method, params, block, result)
58
+ def generate_expectation(indentation_level, context, fixture, method, params, block, result)
58
59
  output = ''
59
60
  block_source = if !block.nil? && block.is_a?(Pretentious::RecordedProc)
60
61
  get_block_source(context, block)
@@ -63,7 +64,7 @@ module Pretentious
63
64
  end
64
65
 
65
66
  statement = if params.size > 0
66
- "#{fixture}.#{method}(#{params_generator(context, params)})#{block_source}"
67
+ "#{fixture}.#{prettify_method_name(method)}(#{params_generator(context, params)})#{block_source}"
67
68
  else
68
69
  stmt = []
69
70
  stmt << "#{fixture}.#{method}"
@@ -72,16 +73,16 @@ module Pretentious
72
73
  end
73
74
 
74
75
  if result.is_a? Exception
75
- buffer_to_string(output, "expect { #{statement} }.to #{pick_matcher(context, result)}",3)
76
+ buffer_to_string(output, "expect { #{statement} }.to #{pick_matcher(context, result)}", indentation_level + 2)
76
77
  else
77
- buffer_to_string(output, "expect(#{statement}).to #{pick_matcher(context, result)}",3)
78
+ buffer_to_string(output, "expect(#{statement}).to #{pick_matcher(context, result)}", indentation_level + 2)
78
79
  end
79
80
  output
80
81
  end
81
82
 
82
- def generate_specs(context, context_prefix, fixture, method_calls)
83
+ def generate_specs(indentation_level, context, context_prefix, fixture, method_calls)
83
84
  output = ''
84
- buffer_to_string(output, "it 'should pass current expectations' do", 2)
85
+ buffer_to_string(output, "it 'should pass current expectations' do", indentation_level + 1)
85
86
  # collect all params
86
87
  params_collection = []
87
88
  mocks_collection = {}
@@ -111,13 +112,13 @@ module Pretentious
111
112
  end
112
113
 
113
114
  if params_collection.size > 0
114
- deps = declare_dependencies(context, params_collection, 3)
115
+ deps = declare_dependencies(context, params_collection, indentation_level + 2)
115
116
  buffer_inline_to_string(output, deps) if deps != ''
116
117
  end
117
118
 
118
119
  if mocks_collection.keys.size > 0
119
120
  buffer_to_string(output, generate_rspec_stub(context, mocks_collection,
120
- 3 * @_indentation.length))
121
+ (indentation_level + 2) * @_indentation.length))
121
122
  end
122
123
 
123
124
  expectations = []
@@ -132,13 +133,13 @@ module Pretentious
132
133
  ''
133
134
  end
134
135
 
135
- buffer_to_string(str, "# #{context_prefix}#{k} #{params_desc_str} should return #{context.value_of(block[:result])}", 3)
136
- buffer_inline_to_string(str, generate_expectation(context, fixture, k, block[:params], block[:block], block[:result]))
136
+ buffer_to_string(str, "# #{context_prefix}#{k} #{params_desc_str} should return #{context.value_of(block[:result])}", indentation_level + 2)
137
+ buffer_inline_to_string(str, generate_expectation(indentation_level, context, fixture, k, block[:params], block[:block], block[:result]))
137
138
  expectations << str unless expectations.include? str
138
139
  end
139
140
  end
140
141
  buffer_inline_to_string(output, expectations.join("\n"))
141
- buffer_to_string(output, 'end', 2)
142
+ buffer_to_string(output, 'end', indentation_level + 1)
142
143
  output
143
144
  end
144
145
 
@@ -167,8 +168,8 @@ module Pretentious
167
168
  'be_nil'
168
169
  elsif result.is_a? Exception
169
170
  'raise_error'
170
- elsif context.variable_map[result.object_id]
171
- "eq(#{context.value_of(result)})"
171
+ elsif context.map_name result.object_id
172
+ "eq(#{context.map_name(result.object_id)})"
172
173
  else
173
174
  "eq(#{Pretentious.value_ize(Pretentious::Context.new, result)})"
174
175
  end
@@ -1,4 +1,4 @@
1
1
  # Pretentious - version
2
2
  module Pretentious
3
- VERSION = '0.1.10'
3
+ VERSION = '0.1.11'
4
4
  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.10.gem
5
+ gem install pretentious-0.1.11.gem
6
6
  ruby test/test_generator.rb
@@ -14,25 +14,24 @@ RSpec.describe Fibonacci do
14
14
  n_3 = 4
15
15
  n_4 = 5
16
16
  # Fibonacci#fib when passed n = 1 should return 1
17
- expect(@fixture.fib(n)).to eq(1)
17
+ expect(@fixture.fib(n)).to eq(n)
18
18
 
19
19
  # Fibonacci#fib when passed n = 2 should return 1
20
- expect(@fixture.fib(n_1)).to eq(1)
20
+ expect(@fixture.fib(n_1)).to eq(n)
21
21
 
22
22
  # Fibonacci#fib when passed n = 3 should return 2
23
- expect(@fixture.fib(n_2)).to eq(2)
23
+ expect(@fixture.fib(n_2)).to eq(n_1)
24
24
 
25
25
  # Fibonacci#fib when passed n = 4 should return 3
26
- expect(@fixture.fib(n_3)).to eq(3)
26
+ expect(@fixture.fib(n_3)).to eq(n_2)
27
27
 
28
28
  # Fibonacci#fib when passed n = 5 should return 5
29
- expect(@fixture.fib(n_4)).to eq(5)
29
+ expect(@fixture.fib(n_4)).to eq(n_4)
30
30
  end
31
31
  end
32
32
 
33
- it 'should pass current expectations' do
34
- # Fibonacci::say_hello should return 'hello'
35
- expect(Fibonacci.say_hello).to eq('hello')
36
- end
37
-
38
- end
33
+ it 'should pass current expectations' do
34
+ # Fibonacci::say_hello should return 'hello'
35
+ expect(Fibonacci.say_hello).to eq('hello')
36
+ end
37
+ end
@@ -2,10 +2,9 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  RSpec.describe Digest::MD5 do
5
- it 'should pass current expectations' do
6
- sample = 'This is the digest'
7
- # Digest::MD5::hexdigest when passed "This is the digest" should return '9f12248dcddeda976611d192efaaf72a'
8
- expect(Digest::MD5.hexdigest(sample)).to eq('9f12248dcddeda976611d192efaaf72a')
9
- end
10
-
11
- end
5
+ it 'should pass current expectations' do
6
+ sample = 'This is the digest'
7
+ # Digest::MD5::hexdigest when passed "This is the digest" should return '9f12248dcddeda976611d192efaaf72a'
8
+ expect(Digest::MD5.hexdigest(sample)).to eq('9f12248dcddeda976611d192efaaf72a')
9
+ end
10
+ end
@@ -54,7 +54,7 @@ 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:0x000000025cbca8> should return another_object
57
+ # TestClass1#return_self when passed message = #<TestClass1:0x000000012813a0> should return another_object
58
58
  expect(@fixture.return_self(another_object)).to eq(another_object)
59
59
  end
60
60
  end
@@ -70,5 +70,4 @@ RSpec.describe TestClass1 do
70
70
  expect(@fixture.message).to eq(@message)
71
71
  end
72
72
  end
73
-
74
- end
73
+ end
@@ -31,8 +31,7 @@ RSpec.describe TestClass2 do
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('This is message 3')
34
+ expect(@fixture.test(@message2)).to eq(@message2)
35
35
  end
36
36
  end
37
-
38
- end
37
+ end
@@ -31,5 +31,4 @@ RSpec.describe TestClass3 do
31
31
  expect(@fixture.show_messages).to eq('awesome!!!')
32
32
  end
33
33
  end
34
-
35
- end
34
+ end
@@ -15,5 +15,4 @@ RSpec.describe TestClass4 do
15
15
  it 'should pass current expectations' do
16
16
  end
17
17
  end
18
-
19
- end
18
+ end
@@ -13,8 +13,7 @@ RSpec.describe TestClassForAutoStub do
13
13
  allow_any_instance_of(AnotherClassUsedByTestClass).to receive(:get_message).and_return('HI THERE!!!!')
14
14
 
15
15
  # TestClassForAutoStub#method_that_uses_the_class_to_stub should return ["Hello Glorious world", "HI THERE!!!!"]
16
- expect(@fixture.method_that_uses_the_class_to_stub).to eq(["Hello Glorious world", "HI THERE!!!!"])
16
+ expect(@fixture.method_that_uses_the_class_to_stub).to eq(a)
17
17
  end
18
18
  end
19
-
20
- end
19
+ end
@@ -13,13 +13,13 @@ RSpec.describe TestClassForMocks do
13
13
  allow_any_instance_of(TestMockSubClass).to receive(:increment_val).and_return(2, 3, 4, 5)
14
14
 
15
15
  # TestClassForMocks#method_with_assign= when passed params2 = "test" should return 'test'
16
- expect(@fixture.method_with_assign=('test')).to eq('test')
16
+ expect(@fixture.method_with_assign = ('test')).to eq('test')
17
17
 
18
18
  # TestClassForMocks#method_with_usage should return 'a return string'
19
19
  expect(@fixture.method_with_usage).to eq('a return string')
20
20
 
21
21
  # TestClassForMocks#method_with_usage2 should return [2, 3, 4, 5]
22
- expect(@fixture.method_with_usage2).to eq([2, 3, 4, 5])
22
+ expect(@fixture.method_with_usage2).to eq(a)
23
23
 
24
24
  # TestClassForMocks#method_with_usage4 should return 'a return string'
25
25
  expect(@fixture.method_with_usage4).to eq('a return string')
@@ -39,5 +39,4 @@ RSpec.describe TestClassForMocks do
39
39
  expect(@fixture.method_with_usage3('a message')).to eq(a)
40
40
  end
41
41
  end
42
-
43
- end
42
+ end
@@ -35,6 +35,12 @@ class DummyGenerator
35
35
  @data << {begin: test_class}
36
36
  end
37
37
 
38
+ def body(instances)
39
+ instances.each_with_index do |instance, num|
40
+ generate(instance, num + 1)
41
+ end
42
+ end
43
+
38
44
  def generate(test_instance, instance_count)
39
45
  @data << {instance: test_instance.class.to_s,
40
46
  instance_method_calls: test_instance.method_calls,
@@ -55,13 +61,18 @@ class DummyGenerator2
55
61
 
56
62
  def initialize
57
63
  @data = []
58
-
59
64
  end
60
65
 
61
66
  def begin_spec(test_class)
62
67
  @data << {begin: test_class}
63
68
  end
64
69
 
70
+ def body(instances)
71
+ instances.each_with_index do |instance, num|
72
+ generate(instance, num + 1)
73
+ end
74
+ end
75
+
65
76
  def generate(test_instance, instance_count)
66
77
  @data << {generate: test_instance.class.to_s, instance_count: instance_count}
67
78
 
@@ -18,10 +18,8 @@ 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 FibonacciTest < Minitest::Test\nend\n\nclass FibonacciScenario1 < FibonacciTest\n def test_current_expectation\n # Fibonacci::say_hello should return 'hello'\n assert_equal 'hello', Fibonacci.say_hello\n end\n\nend\n",
21
+ expect(result).to eq(Fibonacci => { output: "# This file was automatically generated by the pretentious gem\nrequire 'minitest_helper'\nrequire 'minitest/autorun'\n\nclass FibonacciTest < Minitest::Test\nend\n\nclass FibonacciScenario1 < FibonacciTest\n def test_current_expectation\n # Fibonacci::say_hello should return 'hello'\n assert_equal 'hello', Fibonacci.say_hello\n end\nend",
22
22
  generator: Pretentious::MinitestGenerator })
23
23
  end
24
-
25
24
  end
26
-
27
25
  end
@@ -13,7 +13,7 @@ RSpec.describe Pretentious::Generator do
13
13
  object = TestClass1.new(message)
14
14
  object.return_self(message)
15
15
  end
16
- expect(call_artifacts[TestClass1][:output]).to eq("# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe TestClass1 do\n context 'Scenario 1' do\n before do\n @message = { test: 'message' }\n @fixture = TestClass1.new(@message)\n end\n\n it 'should pass current expectations' do\n # TestClass1#return_self when passed message = {:test=>\"message\"} should return @message\n expect(@fixture.return_self(@message)).to eq(@message)\n end\n end\n\nend\n")
16
+ expect(call_artifacts[TestClass1][:output]).to eq("# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe TestClass1 do\n context 'Scenario 1' do\n before do\n @message = { test: 'message' }\n @fixture = TestClass1.new(@message)\n end\n\n it 'should pass current expectations' do\n # TestClass1#return_self when passed message = {:test=>\"message\"} should return @message\n expect(@fixture.return_self(@message)).to eq(@message)\n end\n end\nend")
17
17
  end
18
18
 
19
19
  it "classes should have a stub class section" do
@@ -36,7 +36,7 @@ RSpec.describe Pretentious::Generator do
36
36
  expect(fib.fib(6)).to eq(8)
37
37
 
38
38
  expect(result).to eq(
39
- Fibonacci => { output: "# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n it 'should pass current expectations' do\n # Fibonacci::say_hello should return 'hello'\n expect(Fibonacci.say_hello).to eq('hello')\n end\n\nend\n",
39
+ Fibonacci => { output: "# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n it 'should pass current expectations' do\n # Fibonacci::say_hello should return 'hello'\n expect(Fibonacci.say_hello).to eq('hello')\n end\nend",
40
40
  generator: Pretentious::RspecGenerator })
41
41
  end
42
42
  end
@@ -90,7 +90,7 @@ RSpec.describe Pretentious::Generator do
90
90
  it 'declare watched classes beforehand and capture when certain methods are invoked' do
91
91
  # declare intention
92
92
  Pretentious.on(TestClass5).method_called(:test_method).spec_for(Fibonacci) do |results|
93
- expect(results[Fibonacci][:output]).to eq("# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n context 'Scenario 1' do\n before do\n @fixture = Fibonacci.new\n end\n\n it 'should pass current expectations' do\n # Fibonacci#fib when passed n = 5 should return 5\n expect(@fixture.fib(5)).to eq(5)\n end\n end\n\nend\n")
93
+ expect(results[Fibonacci][:output]).to eq("# This file was automatically generated by the pretentious gem\nrequire 'spec_helper'\n\nRSpec.describe Fibonacci do\n context 'Scenario 1' do\n before do\n @fixture = Fibonacci.new\n end\n\n it 'should pass current expectations' do\n # Fibonacci#fib when passed n = 5 should return 5\n expect(@fixture.fib(5)).to eq(5)\n end\n end\nend")
94
94
  end
95
95
 
96
96
  expect(Pretentious::Generator).to receive(:generate_for).with(Fibonacci).and_call_original
@@ -1,6 +1,6 @@
1
1
  # This file was automatically generated by the pretentious gem
2
2
  require 'minitest_helper'
3
- require "minitest/autorun"
3
+ require 'minitest/autorun'
4
4
 
5
5
  class FibonacciTest < Minitest::Test
6
6
  end
@@ -35,5 +35,4 @@ class FibonacciScenario2 < FibonacciTest
35
35
  # Fibonacci::say_hello should return 'hello'
36
36
  assert_equal 'hello', Fibonacci.say_hello
37
37
  end
38
-
39
- end
38
+ end
@@ -1,6 +1,6 @@
1
1
  # This file was automatically generated by the pretentious gem
2
2
  require 'minitest_helper'
3
- require "minitest/autorun"
3
+ require 'minitest/autorun'
4
4
 
5
5
  class Digest::MD5Test < Minitest::Test
6
6
  end
@@ -12,5 +12,4 @@ class Digest::MD5Scenario1 < Digest::MD5Test
12
12
  # Digest::MD5::hexdigest when passed "This is the digest" should return '9f12248dcddeda976611d192efaaf72a'
13
13
  assert_equal '9f12248dcddeda976611d192efaaf72a', Digest::MD5.hexdigest(sample)
14
14
  end
15
-
16
- end
15
+ end
@@ -1,6 +1,6 @@
1
1
  # This file was automatically generated by the pretentious gem
2
2
  require 'minitest_helper'
3
- require "minitest/autorun"
3
+ require 'minitest/autorun'
4
4
 
5
5
  class MemeTest < Minitest::Test
6
6
  end
@@ -17,5 +17,4 @@ class MemeScenario1 < MemeTest
17
17
  # Meme#will_it_blend? should return 'YES!'
18
18
  assert_equal 'YES!', @fixture.will_it_blend?
19
19
  end
20
- end
21
-
20
+ end
@@ -1,6 +1,6 @@
1
1
  # This file was automatically generated by the pretentious gem
2
2
  require 'minitest_helper'
3
- require "minitest/autorun"
3
+ require 'minitest/autorun'
4
4
 
5
5
  class TestClass1Test < Minitest::Test
6
6
  end
@@ -61,7 +61,7 @@ class TestClass1Scenario3 < TestClass1Test
61
61
  def test_current_expectation
62
62
  another_object = TestClass1.new('test')
63
63
 
64
- # TestClass1#return_self when passed message = #<TestClass1:0x00000002440e10> should return another_object
64
+ # TestClass1#return_self when passed message = #<TestClass1:0x000000010f3808> should return another_object
65
65
  assert_equal another_object, @fixture.return_self(another_object)
66
66
  end
67
67
  end
@@ -76,5 +76,4 @@ class TestClass1Scenario4 < TestClass1Test
76
76
  # TestClass1#message should return @message
77
77
  assert_equal @message, @fixture.message
78
78
  end
79
- end
80
-
79
+ end
@@ -1,6 +1,6 @@
1
1
  # This file was automatically generated by the pretentious gem
2
2
  require 'minitest_helper'
3
- require "minitest/autorun"
3
+ require 'minitest/autorun'
4
4
 
5
5
  class TestClass2Test < Minitest::Test
6
6
  end
@@ -38,5 +38,4 @@ class TestClass2Scenario3 < TestClass2Test
38
38
  # TestClass2#test when passed object = "This is message 3" should return 'This is message 3'
39
39
  assert_equal 'This is message 3', @fixture.test(@message2)
40
40
  end
41
- end
42
-
41
+ end
@@ -1,6 +1,6 @@
1
1
  # This file was automatically generated by the pretentious gem
2
2
  require 'minitest_helper'
3
- require "minitest/autorun"
3
+ require 'minitest/autorun'
4
4
 
5
5
  class TestClass3Test < Minitest::Test
6
6
  end
@@ -33,5 +33,4 @@ class TestClass3Scenario2 < TestClass3Test
33
33
  # TestClass3#show_messages should return 'awesome!!!'
34
34
  assert_equal 'awesome!!!', @fixture.show_messages
35
35
  end
36
- end
37
-
36
+ end
@@ -1,6 +1,6 @@
1
1
  # This file was automatically generated by the pretentious gem
2
2
  require 'minitest_helper'
3
- require "minitest/autorun"
3
+ require 'minitest/autorun'
4
4
 
5
5
  class TestClass4Test < Minitest::Test
6
6
  end
@@ -17,5 +17,4 @@ class TestClass4Scenario1 < TestClass4Test
17
17
 
18
18
  def test_current_expectation
19
19
  end
20
- end
21
-
20
+ end
@@ -1,6 +1,6 @@
1
1
  # This file was automatically generated by the pretentious gem
2
2
  require 'minitest_helper'
3
- require "minitest/autorun"
3
+ require 'minitest/autorun'
4
4
 
5
5
  class TestClassForMocksTest < Minitest::Test
6
6
  end
@@ -16,7 +16,7 @@ class TestClassForMocksScenario1 < TestClassForMocksTest
16
16
  TestMockSubClass.stub_any_instance(:test_method, 'a return string') do
17
17
  TestMockSubClass.stub_any_instance(:increment_val, 2) do
18
18
  # TestClassForMocks#method_with_assign= when passed params2 = "test" should return 'test'
19
- assert_equal 'test', @fixture.method_with_assign=('test')
19
+ assert_equal 'test', @fixture.method_with_assign = ('test')
20
20
 
21
21
  # TestClassForMocks#method_with_usage should return 'a return string'
22
22
  assert_equal 'a return string', @fixture.method_with_usage
@@ -46,5 +46,4 @@ class TestClassForMocksScenario2 < TestClassForMocksTest
46
46
  end
47
47
 
48
48
  end
49
- end
50
-
49
+ 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.1.10
4
+ version: 0.1.11
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-10 00:00:00.000000000 Z
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller