pretentious 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pretentious/generator.rb +16 -4
- data/lib/pretentious/version.rb +1 -1
- data/run_test.sh +1 -1
- data/spec/deconstructor_spec.rb +21 -0
- data/spec/test_class1_spec.rb +10 -10
- data/spec/test_class3_spec.rb +6 -6
- data/spec/test_class4_spec.rb +2 -2
- data/spec/test_class_for_auto_stub_spec.rb +1 -1
- data/spec/test_class_for_mocks_spec.rb +4 -4
- data/test/test_test_class1.rb +10 -10
- data/test/test_test_class3.rb +6 -6
- data/test/test_test_class4.rb +2 -2
- data/test/test_test_class_for_mocks.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e52b4207be07ea0604174f928860a43de276e6d
|
4
|
+
data.tar.gz: 113710e58638b64cd72ce2c6c5ed8f74171440c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c3cf391ac3e937eb694d0362216a1f50d5c5603a7ee3a6f917067a7a96a26ec23a4f23a80b0f1a5492c32bf49b5962b338f41fdd8266dcb16f5fcfaeef206ad
|
7
|
+
data.tar.gz: bba29d6250c4da2835b94c65742473689a89eeef29ffeca71e1003ed60ea831071a0d2906125fc91ee103807b5564a04efc5d70b2e125b98a199a59d0e1786db
|
@@ -57,7 +57,6 @@ module Pretentious
|
|
57
57
|
|
58
58
|
setup_instance(*args, &recordedProc)
|
59
59
|
param_types = @_instance.method(:initialize).parameters
|
60
|
-
puts "#{@_instance.class.name} params -> #{param_types.inspect}"
|
61
60
|
@_instance_init[:params_types] = param_types
|
62
61
|
|
63
62
|
@_method_calls = []
|
@@ -405,7 +404,7 @@ module Pretentious
|
|
405
404
|
unless (block.nil?)
|
406
405
|
@_init_arguments[:block] = RecordedProc.new(block) {}
|
407
406
|
end
|
408
|
-
@_variable_names= {}
|
407
|
+
@_variable_names = {}
|
409
408
|
|
410
409
|
params = if (self.respond_to? :test_class )
|
411
410
|
test_class.instance_method(:initialize).parameters
|
@@ -424,7 +423,7 @@ module Pretentious
|
|
424
423
|
end
|
425
424
|
|
426
425
|
def _variable_map
|
427
|
-
@_variable_names
|
426
|
+
@_variable_names || {}
|
428
427
|
end
|
429
428
|
|
430
429
|
def _deconstruct
|
@@ -432,7 +431,20 @@ module Pretentious
|
|
432
431
|
end
|
433
432
|
|
434
433
|
def _deconstruct_to_ruby(var_name = nil, indentation = 0)
|
435
|
-
|
434
|
+
variable_names = {}
|
435
|
+
|
436
|
+
caller_context = binding.of_caller(1)
|
437
|
+
v_locals = caller_context.eval('local_variables')
|
438
|
+
|
439
|
+
v_locals.each { |v|
|
440
|
+
variable_value = caller_context.eval("#{v.to_s}")
|
441
|
+
if self.object_id == variable_value.object_id
|
442
|
+
variable_names[variable_value.object_id] = v
|
443
|
+
end
|
444
|
+
}
|
445
|
+
|
446
|
+
variable_names = _variable_map.merge({self.object_id => var_name}) unless var_name.nil?
|
447
|
+
Pretentious::Deconstructor.new().deconstruct_to_ruby(indentation, variable_names, {}, [], self)
|
436
448
|
end
|
437
449
|
|
438
450
|
end
|
data/lib/pretentious/version.rb
CHANGED
data/run_test.sh
CHANGED
data/spec/deconstructor_spec.rb
CHANGED
@@ -22,6 +22,27 @@ RSpec.describe Pretentious::Deconstructor do
|
|
22
22
|
:params_types=>[[:req, :message]]})
|
23
23
|
|
24
24
|
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "Object#_deconstruct_to_ruby" do
|
29
|
+
it "generates the ruby code to create an object" do
|
30
|
+
output = Pretentious.watch {
|
31
|
+
a = "Some type of string"
|
32
|
+
a._deconstruct_to_ruby
|
33
|
+
}
|
34
|
+
expect(output).to eq("a = \"Some type of string\"\n")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "deconstruct multiple objects" do
|
38
|
+
output = Pretentious.watch {
|
39
|
+
a = "Some type of string"
|
40
|
+
b = TestClass1.new("Hello world")
|
41
|
+
test_class = TestClass3.new(a, b)
|
42
|
+
test_class._deconstruct_to_ruby
|
43
|
+
}
|
44
|
+
expect(output).to eq("testclass2 = TestClass1.new(\"Hello world\")\ntest_class = TestClass3.new(\"Some type of string\", testclass2)\n")
|
45
|
+
end
|
25
46
|
end
|
26
47
|
|
27
48
|
describe "#deconstruct" do
|
data/spec/test_class1_spec.rb
CHANGED
@@ -17,20 +17,20 @@ RSpec.describe TestClass1 do
|
|
17
17
|
|
18
18
|
context 'Scenario 2' do
|
19
19
|
before do
|
20
|
-
|
21
|
-
message = {hello: "world", test:
|
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}}
|
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
|
-
|
28
|
-
|
29
|
-
|
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
|
30
30
|
}
|
31
31
|
|
32
32
|
e = nil
|
33
|
-
|
33
|
+
var_2167121820 = 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:
|
45
|
-
expect( @fixture.set_block &
|
44
|
+
# TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000102575140@example.rb:73>
|
45
|
+
expect( @fixture.set_block &var_2167127140 ).to eq(var_2167127140)
|
46
46
|
|
47
|
-
# TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:
|
48
|
-
expect( @fixture.call_block &
|
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)
|
49
49
|
|
50
50
|
# TestClass1#something_is_wrong should return StandardError
|
51
51
|
expect { @fixture.something_is_wrong }.to raise_error
|
data/spec/test_class3_spec.rb
CHANGED
@@ -5,9 +5,9 @@ RSpec.describe TestClass3 do
|
|
5
5
|
|
6
6
|
context 'Scenario 1' do
|
7
7
|
before do
|
8
|
-
|
9
|
-
|
10
|
-
testclass1 = TestClass1.new(
|
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)
|
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
|
-
|
25
|
-
|
26
|
-
testclass1 = TestClass1.new(
|
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)
|
27
27
|
testclass2 = TestClass2.new("This is message 2", nil)
|
28
28
|
@fixture = TestClass3.new(testclass1, testclass2)
|
29
29
|
end
|
data/spec/test_class4_spec.rb
CHANGED
@@ -6,11 +6,11 @@ RSpec.describe TestClass4 do
|
|
6
6
|
context 'Scenario 1' do
|
7
7
|
before do
|
8
8
|
var_8 = nil
|
9
|
-
|
9
|
+
var_2167163460 = Proc.new {
|
10
10
|
# Variable return values ... can't figure out what goes in here...
|
11
11
|
}
|
12
12
|
|
13
|
-
@fixture = TestClass4.new(&
|
13
|
+
@fixture = TestClass4.new(&var_2167163460)
|
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
|
-
|
12
|
+
var_2165345620 = ["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
|
-
|
12
|
+
var_2165992020 = [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
|
-
|
38
|
+
var_2165878780 = {val: 1, str: "hello world", message: "a message"}
|
39
39
|
|
40
|
-
allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(
|
40
|
+
allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(var_2165878780)
|
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(
|
43
|
+
expect( @fixture.method_with_usage3("a message") ).to eq(var_2165878780)
|
44
44
|
|
45
45
|
end
|
46
46
|
end
|
data/test/test_test_class1.rb
CHANGED
@@ -20,20 +20,20 @@ end
|
|
20
20
|
|
21
21
|
class TestClass1Scenario2 < TestTestClass1
|
22
22
|
def setup
|
23
|
-
|
24
|
-
message = {hello: "world", test:
|
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}}
|
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
|
-
|
31
|
-
|
32
|
-
|
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
|
33
33
|
}
|
34
34
|
|
35
35
|
e = nil
|
36
|
-
|
36
|
+
var_2166393560 = 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:
|
48
|
-
assert_equal
|
47
|
+
#TestClass1#set_block should return #<Pretentious::RecordedProc:0x00000102412190@example.rb:73>
|
48
|
+
assert_equal var_2166428520, @fixture.set_block( &var_2166428520)
|
49
49
|
|
50
|
-
#TestClass1#call_block should return {:hello=>"world", :test=>#<TestClass1:
|
51
|
-
assert_equal
|
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)
|
52
52
|
|
53
53
|
#TestClass1#something_is_wrong should return StandardError
|
54
54
|
assert_raises(StandardError) { @fixture.something_is_wrong }
|
data/test/test_test_class3.rb
CHANGED
@@ -7,9 +7,9 @@ end
|
|
7
7
|
|
8
8
|
class TestClass3Scenario1 < TestTestClass3
|
9
9
|
def setup
|
10
|
-
|
11
|
-
|
12
|
-
testclass1 = TestClass1.new(
|
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)
|
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
|
-
|
28
|
-
|
29
|
-
testclass1 = TestClass1.new(
|
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)
|
30
30
|
testclass2 = TestClass2.new("This is message 2", nil)
|
31
31
|
@fixture = TestClass3.new(testclass1, testclass2)
|
32
32
|
end
|
data/test/test_test_class4.rb
CHANGED
@@ -8,11 +8,11 @@ end
|
|
8
8
|
class TestClass4Scenario1 < TestTestClass4
|
9
9
|
def setup
|
10
10
|
var_8 = nil
|
11
|
-
|
11
|
+
var_2166489580 = Proc.new {
|
12
12
|
# Variable return values ... can't figure out what goes in here...
|
13
13
|
}
|
14
14
|
|
15
|
-
@fixture = TestClass4.new(&
|
15
|
+
@fixture = TestClass4.new(&var_2166489580)
|
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
|
-
|
14
|
+
var_2165696380 = [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
|
-
|
42
|
+
var_2165567200 = {val: 1, str: "hello world", message: "a message"}
|
43
43
|
|
44
|
-
TestMockSubClass.stub_any_instance(:return_hash,
|
44
|
+
TestMockSubClass.stub_any_instance(:return_hash, var_2165567200) 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
|
46
|
+
assert_equal var_2165567200, @fixture.method_with_usage3("a message")
|
47
47
|
|
48
48
|
end
|
49
49
|
|
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.
|
4
|
+
version: 0.1.2
|
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-11-
|
11
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|