pretentious 0.1.9 → 0.1.10

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: bd9a7227d0c9e647c762d750c2fe37336b225ac4
4
- data.tar.gz: 008e91daf0aa2e31f7c4e453909186c8e534d7f2
3
+ metadata.gz: 5e6d60c4c39c880e0e4ab184b851c413f8db136a
4
+ data.tar.gz: b4c690ef71ddd7b0f2ed066feebd5a918e47afac
5
5
  SHA512:
6
- metadata.gz: d6d24160b7215d81a453852dc9c93aadbe82c4d2927245bd7e7b71a1c38409c21ce7f640f289335659646cc29f4fde54904e3dc029336d48da40e3004a8f4ce9
7
- data.tar.gz: 7ca8f91b6ae5005718451cc2786a581bf7947132ddc71c71c413cd9ae156b209eb76501ef59668866b49ad644097ad165db49d5ef5abe57b8ac1e552e0e7f269
6
+ metadata.gz: 2c7bc395e8f3260c7b4b7cb8f1e5b8df457461279ae3816d7970d15aa34a8bc508e6f0dfb3a4e3278961b24e6a94372401c9d6f0031efe6c352cfdbba769a599
7
+ data.tar.gz: 58195f4cc3b42154f6d894d5dd5fa3d0900c6ce4e4a5f991f3deda40a3682605b9388d866c3a7507bd3131e32da2a82e3b2b46dd6901e363b33bed1f340f0d29
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.1.10 (2015-12-11)
2
+
3
+ Bugfixes:
4
+
5
+ - fix regression wherein method_missing is not handled properly
6
+
7
+ Featuers:
8
+
9
+ - Fix weird generated comments
10
+
1
11
  ## 0.1.9 (2015-12-10)
2
12
 
3
13
  Bugfixes:
@@ -7,7 +17,7 @@ Bugfixes:
7
17
  Features:
8
18
 
9
19
  - use more realistic variable names for unamed variables
10
-
20
+
11
21
  ## 0.1.8 (2015-12-07)
12
22
 
13
23
  Bugfixes:
@@ -240,8 +240,6 @@ module Pretentious
240
240
 
241
241
  info_block[:block] = recorded_proc
242
242
 
243
- info_block[:names] = @_instance.method(method_sym).parameters
244
-
245
243
  begin
246
244
 
247
245
  unless is_stub
@@ -252,6 +250,7 @@ module Pretentious
252
250
  end
253
251
 
254
252
  if @_instance.methods.include? method_sym
253
+ info_block[:names] = @_instance.method(method_sym).parameters
255
254
  result = @_instance.send(method_sym, *arguments, &recorded_proc)
256
255
  else
257
256
  result = @_instance.send(:method_missing, method_sym, *arguments, &recorded_proc)
@@ -149,7 +149,7 @@ module Pretentious
149
149
  ''
150
150
  end
151
151
 
152
- str << "#{indentation}# #{context_prefix}#{k} #{params_desc_str} should return #{block[:result]}\n"
152
+ str << "#{indentation}# #{context_prefix}#{k} #{params_desc_str} should return #{context.value_of(block[:result])}\n"
153
153
  str << "#{indentation}#{generate_expectation(context, fixture, k, block[:params], block[:block], block[:result])}\n"
154
154
  expectations << str unless expectations.include? str
155
155
  end
@@ -132,7 +132,7 @@ module Pretentious
132
132
  ''
133
133
  end
134
134
 
135
- buffer_to_string(str, "# #{context_prefix}#{k} #{params_desc_str} should return #{block[:result]}", 3)
135
+ buffer_to_string(str, "# #{context_prefix}#{k} #{params_desc_str} should return #{context.value_of(block[:result])}", 3)
136
136
  buffer_inline_to_string(str, generate_expectation(context, fixture, k, block[:params], block[:block], block[:result]))
137
137
  expectations << str unless expectations.include? str
138
138
  end
@@ -1,4 +1,4 @@
1
1
  # Pretentious - version
2
2
  module Pretentious
3
- VERSION = '0.1.9'
3
+ VERSION = '0.1.10'
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.9.gem
5
+ gem install pretentious-0.1.10.gem
6
6
  ruby test/test_generator.rb
@@ -31,7 +31,7 @@ RSpec.describe Fibonacci do
31
31
  end
32
32
 
33
33
  it 'should pass current expectations' do
34
- # Fibonacci::say_hello should return hello
34
+ # Fibonacci::say_hello should return 'hello'
35
35
  expect(Fibonacci.say_hello).to eq('hello')
36
36
  end
37
37
 
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
  RSpec.describe Digest::MD5 do
5
5
  it 'should pass current expectations' do
6
6
  sample = 'This is the digest'
7
- # Digest::MD5::hexdigest when passed "This is the digest" should return 9f12248dcddeda976611d192efaaf72a
7
+ # Digest::MD5::hexdigest when passed "This is the digest" should return '9f12248dcddeda976611d192efaaf72a'
8
8
  expect(Digest::MD5.hexdigest(sample)).to eq('9f12248dcddeda976611d192efaaf72a')
9
9
  end
10
10
 
@@ -8,7 +8,7 @@ RSpec.describe TestClass1 do
8
8
  end
9
9
 
10
10
  it 'should pass current expectations' do
11
- # TestClass1#message should return test
11
+ # TestClass1#message should return 'test'
12
12
  expect(@fixture.message).to eq('test')
13
13
  end
14
14
  end
@@ -30,16 +30,16 @@ RSpec.describe TestClass1 do
30
30
  # Variable return values ... can't figure out what goes in here...
31
31
  }
32
32
 
33
- # TestClass1#print_message should return
33
+ # TestClass1#print_message should return nil
34
34
  expect(@fixture.print_message).to be_nil
35
35
 
36
- # TestClass1#set_block should return #<Pretentious::RecordedProc:0x0000000279b3f8@example.rb:73>
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 {:hello=>"world", :test=>#<TestClass1:0x000000028113c8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={21007100=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x000000028113c8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={21007100=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x000000028113c8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={21007100=>"message"}>}}
39
+ # TestClass1#call_block should return @message
40
40
  expect(@fixture.call_block &b).to eq(@message)
41
41
 
42
- # TestClass1#something_is_wrong should return StandardError
42
+ # TestClass1#something_is_wrong should return e
43
43
  expect { @fixture.something_is_wrong }.to raise_error
44
44
 
45
45
  # TestClass1#just_returns_true should return true
@@ -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:0x000000028113c8> should return #<TestClass1:0x000000028113c8>
57
+ # TestClass1#return_self when passed message = #<TestClass1:0x000000025cbca8> should return another_object
58
58
  expect(@fixture.return_self(another_object)).to eq(another_object)
59
59
  end
60
60
  end
@@ -66,7 +66,7 @@ RSpec.describe TestClass1 do
66
66
  end
67
67
 
68
68
  it 'should pass current expectations' do
69
- # TestClass1#message should return #<TestClass1:0x000000028113c8>
69
+ # TestClass1#message should return @message
70
70
  expect(@fixture.message).to eq(@message)
71
71
  end
72
72
  end
@@ -8,7 +8,7 @@ RSpec.describe TestClass2 do
8
8
  end
9
9
 
10
10
  it 'should pass current expectations' do
11
- # TestClass2#print_message should return
11
+ # TestClass2#print_message should return nil
12
12
  expect(@fixture.print_message).to be_nil
13
13
  end
14
14
  end
@@ -30,7 +30,7 @@ RSpec.describe TestClass2 do
30
30
  end
31
31
 
32
32
  it 'should pass current expectations' do
33
- # TestClass2#test when passed object = "This is message 3" should return This is message 3
33
+ # TestClass2#test when passed object = "This is message 3" should return 'This is message 3'
34
34
  expect(@fixture.test(@message2)).to eq('This is message 3')
35
35
  end
36
36
  end
@@ -12,7 +12,7 @@ RSpec.describe TestClass3 do
12
12
  end
13
13
 
14
14
  it 'should pass current expectations' do
15
- # TestClass3#show_messages should return awesome!!!
15
+ # TestClass3#show_messages should return 'awesome!!!'
16
16
  expect(@fixture.show_messages).to eq('awesome!!!')
17
17
  end
18
18
  end
@@ -27,7 +27,7 @@ RSpec.describe TestClass3 do
27
27
  end
28
28
 
29
29
  it 'should pass current expectations' do
30
- # TestClass3#show_messages should return awesome!!!
30
+ # TestClass3#show_messages should return 'awesome!!!'
31
31
  expect(@fixture.show_messages).to eq('awesome!!!')
32
32
  end
33
33
  end
@@ -12,16 +12,16 @@ RSpec.describe TestClassForMocks do
12
12
  allow_any_instance_of(TestMockSubClass).to receive(:test_method).and_return('a return string')
13
13
  allow_any_instance_of(TestMockSubClass).to receive(:increment_val).and_return(2, 3, 4, 5)
14
14
 
15
- # TestClassForMocks#method_with_assign= when passed params2 = "test" should return test
15
+ # TestClassForMocks#method_with_assign= when passed params2 = "test" should return 'test'
16
16
  expect(@fixture.method_with_assign=('test')).to eq('test')
17
17
 
18
- # TestClassForMocks#method_with_usage should return a return string
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
22
  expect(@fixture.method_with_usage2).to eq([2, 3, 4, 5])
23
23
 
24
- # TestClassForMocks#method_with_usage4 should return a return string
24
+ # TestClassForMocks#method_with_usage4 should return 'a return string'
25
25
  expect(@fixture.method_with_usage4).to eq('a return string')
26
26
  end
27
27
  end
@@ -35,7 +35,7 @@ RSpec.describe TestClassForMocks do
35
35
  a = { val: 1, str: 'hello world', message: 'a message' }
36
36
  allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(a)
37
37
 
38
- # TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
38
+ # TestClassForMocks#method_with_usage3 when passed message = "a message" should return a
39
39
  expect(@fixture.method_with_usage3('a message')).to eq(a)
40
40
  end
41
41
  end
@@ -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 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\n\nend\n",
22
22
  generator: Pretentious::MinitestGenerator })
23
23
  end
24
24
 
@@ -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 {:test=>\"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\n\nend\n")
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\n\nend\n",
40
40
  generator: Pretentious::RspecGenerator })
41
41
  end
42
42
  end
@@ -65,6 +65,15 @@ RSpec.describe Pretentious::Generator do
65
65
  expect(result[TestClass1][:output]).to match('expect { @fixture.something_is_wrong }.to raise_error')
66
66
  end
67
67
 
68
+ it "handles method missing" do
69
+ result = Pretentious.spec_for(TestClassMethodMissing) do
70
+ test_class = TestClassMethodMissing.new
71
+ test_class.handled_by_method_missing
72
+ end
73
+
74
+ expect(result[TestClassMethodMissing][:output]).to match("YOU GOT ME!!!!")
75
+ end
76
+
68
77
  context "proc handling" do
69
78
  it 'handles blocks passed to methods' do
70
79
  result = Pretentious.spec_for(TestClass1) do
@@ -32,7 +32,7 @@ end
32
32
 
33
33
  class FibonacciScenario2 < FibonacciTest
34
34
  def test_current_expectation
35
- # Fibonacci::say_hello should return hello
35
+ # Fibonacci::say_hello should return 'hello'
36
36
  assert_equal 'hello', Fibonacci.say_hello
37
37
  end
38
38
 
@@ -9,7 +9,7 @@ class Digest::MD5Scenario1 < Digest::MD5Test
9
9
  def test_current_expectation
10
10
  sample = 'This is the digest'
11
11
 
12
- # Digest::MD5::hexdigest when passed "This is the digest" should return 9f12248dcddeda976611d192efaaf72a
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
15
 
@@ -11,10 +11,10 @@ class MemeScenario1 < MemeTest
11
11
  end
12
12
 
13
13
  def test_current_expectation
14
- # Meme#i_can_has_cheezburger? should return OHAI!
14
+ # Meme#i_can_has_cheezburger? should return 'OHAI!'
15
15
  assert_equal 'OHAI!', @fixture.i_can_has_cheezburger?
16
16
 
17
- # Meme#will_it_blend? should return YES!
17
+ # Meme#will_it_blend? should return 'YES!'
18
18
  assert_equal 'YES!', @fixture.will_it_blend?
19
19
  end
20
20
  end
@@ -11,7 +11,7 @@ class TestClass1Scenario1 < TestClass1Test
11
11
  end
12
12
 
13
13
  def test_current_expectation
14
- # TestClass1#message should return test
14
+ # TestClass1#message should return 'test'
15
15
  assert_equal 'test', @fixture.message
16
16
  end
17
17
  end
@@ -34,18 +34,18 @@ class TestClass1Scenario2 < TestClass1Test
34
34
  }
35
35
 
36
36
 
37
- # TestClass1#print_message should return
37
+ # TestClass1#print_message should return nil
38
38
  assert_nil @fixture.print_message
39
- # TestClass1#print_message should return
39
+ # TestClass1#print_message should return nil
40
40
  assert_nil @fixture.print_message
41
41
 
42
- # TestClass1#set_block should return #<Pretentious::RecordedProc:0x000000024c54d0@example.rb:73>
42
+ # TestClass1#set_block should return a
43
43
  assert_equal a, @fixture.set_block( &a)
44
44
 
45
- # TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x00000002692ee8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={20224160=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x00000002692ee8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={20224160=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x00000002692ee8 @message="test", @_init_arguments={:params=>["test"], :params_types=>[[:req, :message]]}, @_variable_names={20224160=>"message"}>}}
45
+ # TestClass1#call_block should return @message
46
46
  assert_equal @message, @fixture.call_block( &b)
47
47
 
48
- # TestClass1#something_is_wrong should return StandardError
48
+ # TestClass1#something_is_wrong should return e
49
49
  assert_raises(StandardError) { @fixture.something_is_wrong }
50
50
 
51
51
  # TestClass1#just_returns_true should return true
@@ -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:0x00000002692ee8> should return #<TestClass1:0x00000002692ee8>
64
+ # TestClass1#return_self when passed message = #<TestClass1:0x00000002440e10> should return another_object
65
65
  assert_equal another_object, @fixture.return_self(another_object)
66
66
  end
67
67
  end
@@ -73,7 +73,7 @@ class TestClass1Scenario4 < TestClass1Test
73
73
  end
74
74
 
75
75
  def test_current_expectation
76
- # TestClass1#message should return #<TestClass1:0x00000002692ee8>
76
+ # TestClass1#message should return @message
77
77
  assert_equal @message, @fixture.message
78
78
  end
79
79
  end
@@ -11,9 +11,9 @@ class TestClass2Scenario1 < TestClass2Test
11
11
  end
12
12
 
13
13
  def test_current_expectation
14
- # TestClass2#print_message should return
14
+ # TestClass2#print_message should return nil
15
15
  assert_nil @fixture.print_message
16
- # TestClass2#print_message should return
16
+ # TestClass2#print_message should return nil
17
17
  assert_nil @fixture.print_message
18
18
  end
19
19
  end
@@ -35,7 +35,7 @@ class TestClass2Scenario3 < TestClass2Test
35
35
  end
36
36
 
37
37
  def test_current_expectation
38
- # TestClass2#test when passed object = "This is message 3" should return This is message 3
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
41
  end
@@ -15,7 +15,7 @@ class TestClass3Scenario1 < TestClass3Test
15
15
  end
16
16
 
17
17
  def test_current_expectation
18
- # TestClass3#show_messages should return awesome!!!
18
+ # TestClass3#show_messages should return 'awesome!!!'
19
19
  assert_equal 'awesome!!!', @fixture.show_messages
20
20
  end
21
21
  end
@@ -30,7 +30,7 @@ class TestClass3Scenario2 < TestClass3Test
30
30
  end
31
31
 
32
32
  def test_current_expectation
33
- # TestClass3#show_messages should return awesome!!!
33
+ # TestClass3#show_messages should return 'awesome!!!'
34
34
  assert_equal 'awesome!!!', @fixture.show_messages
35
35
  end
36
36
  end
@@ -15,16 +15,16 @@ class TestClassForMocksScenario1 < TestClassForMocksTest
15
15
 
16
16
  TestMockSubClass.stub_any_instance(:test_method, 'a return string') do
17
17
  TestMockSubClass.stub_any_instance(:increment_val, 2) do
18
- # TestClassForMocks#method_with_assign= when passed params2 = "test" should return test
18
+ # TestClassForMocks#method_with_assign= when passed params2 = "test" should return 'test'
19
19
  assert_equal 'test', @fixture.method_with_assign=('test')
20
20
 
21
- # TestClassForMocks#method_with_usage should return a return string
21
+ # TestClassForMocks#method_with_usage should return 'a return string'
22
22
  assert_equal 'a return string', @fixture.method_with_usage
23
23
 
24
24
  # TestClassForMocks#method_with_usage2 should return [2, 3, 4, 5]
25
25
  assert_equal [2, 3, 4, 5], @fixture.method_with_usage2
26
26
 
27
- # TestClassForMocks#method_with_usage4 should return a return string
27
+ # TestClassForMocks#method_with_usage4 should return 'a return string'
28
28
  assert_equal 'a return string', @fixture.method_with_usage4
29
29
  end
30
30
  end
@@ -41,7 +41,7 @@ class TestClassForMocksScenario2 < TestClassForMocksTest
41
41
  a = { val: 1, str: 'hello world', message: 'a message' }
42
42
 
43
43
  TestMockSubClass.stub_any_instance(:return_hash, a) do
44
- # TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
44
+ # TestClassForMocks#method_with_usage3 when passed message = "a message" should return a
45
45
  assert_equal a, @fixture.method_with_usage3('a message')
46
46
  end
47
47
 
data/test_classes.rb CHANGED
@@ -25,6 +25,16 @@ class Meme
25
25
  end
26
26
  end
27
27
 
28
+ class TestClassMethodMissing
29
+ def method_missing(method, *args, &block)
30
+ if (method == :handled_by_method_missing)
31
+ return "YOU GOT ME!!!!"
32
+ else
33
+ super(method, *args, &block)
34
+ end
35
+ end
36
+ end
37
+
28
38
  class TestClass1
29
39
 
30
40
  def initialize(message)
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.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Emmanuel Dayo