pretentious 0.0.3 → 0.0.4

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: 594e3a65079d62df37a766461e810343529e990e
4
- data.tar.gz: 1f3dc437941f264eb5790e630da2da760d7e9d97
3
+ metadata.gz: 0fb899b0d269ad993d7e7d5f9b7fe61cfd6b226c
4
+ data.tar.gz: 6c3d3400c4eb0ce26f1e7dad7937673b9ee90275
5
5
  SHA512:
6
- metadata.gz: 7aa09793966b307e617c44c4776d6ca2c1176d3ce474094e5726e66c85e8026e7ac28f4066700f3eb2b1e08c2f8167f00f2cb1d713e93a0f7f5ba2ff5485b559
7
- data.tar.gz: de79f80b3aa79eaf92e0fbcc64e04c88a024abd51127d9eff50497817b48078c0c5757fe8ff5b7a7267c72e018f26e6646ebb197e332f2134ed307d7a593ad7f
6
+ metadata.gz: 5033ed7b8019458b6068043963580818e313f56b083194b22092c2f7754a9754bd5d0a1bfd89aa3c10e92025dac58b42855a62e48a62be76bd9270d26d732411
7
+ data.tar.gz: d1e12ecc2d3b839919bc1e8a0294b9d53a76e94f1ab4c7916e12944a9621bfe5634b993696efcd255189380d09b5f986a5b9c49ed96b3a4f93a4e1efa5b1097e
data/README.md CHANGED
@@ -288,6 +288,25 @@ RSpec.describe TestClass3 do
288
288
 
289
289
  Note that creating another instance of TestClass3 will result in the creation of another Scenario
290
290
 
291
+ ## Capturing Exceptions
292
+
293
+ Exceptions thrown by method calls should generate the appropriate exception test case. Just make sure
294
+ that you rescue inside your example file like below:
295
+
296
+ ```ruby
297
+ begin
298
+ test_class_one.something_is_wrong
299
+ rescue Exception=>e
300
+ end
301
+ ```
302
+
303
+ should generate the following in rspec
304
+
305
+ ```ruby
306
+ # TestClass1#something_is_wrong when passed should return StandardError
307
+ expect { @fixture.something_is_wrong }.to raise_error
308
+ ```
309
+
291
310
  ## Things to do after
292
311
 
293
312
  Since your tests are already written, and hopefully nobody notices its written by a machine, you may just leave it
@@ -300,9 +319,12 @@ a bdd'er/tdd'er.
300
319
 
301
320
  Computers are bad at mind reading (for now) and they don't really know your expectation of "correctness", as such
302
321
  it assumes your code is correct and can only use equality based matchers. It can also only reliably match
303
- primitive data types and hashs and arrays to a degree. More complex expectations are unfortunately left for the humans
322
+ primitive data types, hashes, Procs and arrays to a degree. More complex expectations are unfortunately left for the humans
304
323
  to resolve.
305
324
 
325
+ Procs that return a constant value will be resolved properly. However variable return values are currently still
326
+ not generated properly will return a stub (future versions may use sourcify to resolve Procs for ruby 1.9)
327
+
306
328
  Also do note that it tries its best to determine how your fixtures are created, as well as the types
307
329
  of your parameters and does so by figuring out (recursively) the components that your object needs. Failure can happen during this process.
308
330
 
data/example.rb CHANGED
@@ -42,6 +42,13 @@ Pretentious.spec_for(TestClass1, TestClass2, TestClass3, TestClass4) do
42
42
  class_to_test4.message
43
43
  }
44
44
 
45
+ begin
46
+ test_class_one.something_is_wrong
47
+ rescue Exception=>e
48
+ end
49
+
50
+ test_class_one.just_returns_true
51
+
45
52
  end
46
53
 
47
54
  Pretentious.spec_for(Digest::MD5) do
@@ -161,7 +161,13 @@ class Pretentious::RspecGenerator
161
161
 
162
162
  info_blocks_arr.each do |block|
163
163
 
164
- buffer("# #{context_prefix}#{k} when passed #{desc_params(block)} should return #{block[:result]}", 3)
164
+ params_desc_str = if block[:params].size > 0
165
+ "when passed #{desc_params(block)}"
166
+ else
167
+ ""
168
+ end
169
+
170
+ buffer("# #{context_prefix}#{k} #{params_desc_str} should return #{block[:result]}", 3)
165
171
  generate_expectation(fixture, k, let_variables, declaration, block[:params], block[:block], block[:result])
166
172
 
167
173
  whitespace
@@ -1,3 +1,3 @@
1
1
  module Pretentious
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -39,7 +39,7 @@ RSpec.describe Fibonacci do
39
39
  it 'should pass current expectations' do
40
40
 
41
41
 
42
- # Fibonacci::say_hello when passed should return hello
42
+ # Fibonacci::say_hello should return hello
43
43
  expect( Fibonacci.say_hello ).to eq("hello")
44
44
 
45
45
  end
@@ -13,7 +13,7 @@ RSpec.describe TestClass1 do
13
13
  it 'should pass current expectations' do
14
14
 
15
15
 
16
- # TestClass1#message when passed should return test
16
+ # TestClass1#message should return test
17
17
  expect( @fixture.message ).to eq("test")
18
18
 
19
19
  end
@@ -22,40 +22,46 @@ RSpec.describe TestClass1 do
22
22
  context 'Scenario 2' do
23
23
  before do
24
24
 
25
- var_2165592540 = "test"
26
- another_object = TestClass1.new(var_2165592540)
27
- var_2165586880 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
25
+ var_2161332560 = "test"
26
+ another_object = TestClass1.new(var_2161332560)
27
+ var_2161318440 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
28
28
 
29
- @fixture = TestClass1.new(var_2165586880)
29
+ @fixture = TestClass1.new(var_2161318440)
30
30
 
31
31
  end
32
32
 
33
33
  it 'should pass current expectations' do
34
34
 
35
- var_2165592540 = "test"
36
- another_object = TestClass1.new(var_2165592540)
37
- var_2165586880 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
38
- var_2159732800 = Proc.new { |message|
39
- var_2165586880
35
+ var_2161332560 = "test"
36
+ another_object = TestClass1.new(var_2161332560)
37
+ var_2161318440 = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
38
+ var_2161201340 = Proc.new { |message|
39
+ var_2161318440
40
40
  }
41
41
 
42
- var_8 = nil
43
- var_2159719320 = Proc.new {
42
+ e = nil
43
+ var_2161188420 = Proc.new {
44
44
  # Variable return values ... can't figure out what goes in here...
45
45
  }
46
46
 
47
47
 
48
- # TestClass1#print_message when passed should return
48
+ # TestClass1#print_message should return
49
49
  expect( @fixture.print_message ).to be_nil
50
50
 
51
- # TestClass1#print_message when passed should return
51
+ # TestClass1#print_message should return
52
52
  expect( @fixture.print_message ).to be_nil
53
53
 
54
- # TestClass1#set_block when passed should return #<Pretentious::RecordedProc:0x000001017568c0@example.rb:73>
55
- expect( @fixture.set_block &var_2159732800 ).to eq(var_2159732800)
54
+ # TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000101a23eb8@example.rb:73>
55
+ expect( @fixture.set_block &var_2161201340 ).to eq(var_2161201340)
56
56
 
57
- # TestClass1#call_block when passed should return {:hello=>"world", :test=>#<TestClass1:0x0000010228a1d8 @message="test", @_init_arguments={:params=>["test"]}, @_variable_names={2165592540=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x0000010228a1d8 @message="test", @_init_arguments={:params=>["test"]}, @_variable_names={2165592540=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x0000010228a1d8 @message="test", @_init_arguments={:params=>["test"]}, @_variable_names={2165592540=>"message"}>}}
58
- expect( @fixture.call_block &var_2159719320 ).to eq(var_2165586880)
57
+ # TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:0x00000101a6a110 @message="test", @_init_arguments={:params=>["test"]}, @_variable_names={2161332560=>"message"}>, :arr_1=>[1, 2, 3, 4, 5, #<TestClass1:0x00000101a6a110 @message="test", @_init_arguments={:params=>["test"]}, @_variable_names={2161332560=>"message"}>], :sub_hash=>{:yes=>true, :obj=>#<TestClass1:0x00000101a6a110 @message="test", @_init_arguments={:params=>["test"]}, @_variable_names={2161332560=>"message"}>}}
58
+ expect( @fixture.call_block &var_2161188420 ).to eq(var_2161318440)
59
+
60
+ # TestClass1#something_is_wrong should return StandardError
61
+ expect { @fixture.something_is_wrong }.to raise_error
62
+
63
+ # TestClass1#just_returns_true should return true
64
+ expect( @fixture.just_returns_true ).to be true
59
65
 
60
66
  end
61
67
  end
@@ -13,10 +13,10 @@ RSpec.describe TestClass2 do
13
13
  it 'should pass current expectations' do
14
14
 
15
15
 
16
- # TestClass2#print_message when passed should return
16
+ # TestClass2#print_message should return
17
17
  expect( @fixture.print_message ).to be_nil
18
18
 
19
- # TestClass2#print_message when passed should return
19
+ # TestClass2#print_message should return
20
20
  expect( @fixture.print_message ).to be_nil
21
21
 
22
22
  end
@@ -5,8 +5,8 @@ RSpec.describe TestClass3 do
5
5
  context 'Scenario 1' do
6
6
  before do
7
7
 
8
- var_2165592540 = "test"
9
- another_object = TestClass1.new(var_2165592540)
8
+ var_2161332560 = "test"
9
+ another_object = TestClass1.new(var_2161332560)
10
10
  args = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
11
11
  test_class_one = TestClass1.new(args)
12
12
  args_1 = "This is message 2"
@@ -19,7 +19,7 @@ RSpec.describe TestClass3 do
19
19
  it 'should pass current expectations' do
20
20
 
21
21
 
22
- # TestClass3#show_messages when passed should return awesome!!!
22
+ # TestClass3#show_messages should return awesome!!!
23
23
  expect( @fixture.show_messages ).to eq("awesome!!!")
24
24
 
25
25
  end
@@ -28,8 +28,8 @@ RSpec.describe TestClass3 do
28
28
  context 'Scenario 2' do
29
29
  before do
30
30
 
31
- var_2165592540 = "test"
32
- another_object = TestClass1.new(var_2165592540)
31
+ var_2161332560 = "test"
32
+ another_object = TestClass1.new(var_2161332560)
33
33
  args = {hello: "world", test: another_object, arr_1: [1, 2, 3, 4, 5, another_object], sub_hash: {yes: true, obj: another_object}}
34
34
  test_class_one = TestClass1.new(args)
35
35
  args_1 = "This is message 2"
@@ -42,7 +42,7 @@ RSpec.describe TestClass3 do
42
42
  it 'should pass current expectations' do
43
43
 
44
44
 
45
- # TestClass3#show_messages when passed should return awesome!!!
45
+ # TestClass3#show_messages should return awesome!!!
46
46
  expect( @fixture.show_messages ).to eq("awesome!!!")
47
47
 
48
48
  end
@@ -5,13 +5,13 @@ RSpec.describe TestClass4 do
5
5
  context 'Scenario 1' do
6
6
  before do
7
7
 
8
- var_2165592540 = "test"
9
- var_2159747700 = Proc.new {
8
+ var_2161332560 = "test"
9
+ var_2161220900 = Proc.new {
10
10
  "test"
11
11
  }
12
12
 
13
13
 
14
- @fixture = TestClass4.new &var_2159747700
14
+ @fixture = TestClass4.new &var_2161220900
15
15
 
16
16
  end
17
17
 
data/test_classes.rb CHANGED
@@ -34,6 +34,10 @@ class TestClass1
34
34
  @message
35
35
  end
36
36
 
37
+ def just_returns_true
38
+ true
39
+ end
40
+
37
41
  def print_message
38
42
  puts @message
39
43
  end
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.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Emmanuel Dayo