pretentious 0.0.7 → 0.0.8
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 +4 -4
- data/README.md +64 -3
- data/example.rb +21 -0
- data/lib/pretentious.rb +36 -403
- data/lib/pretentious/generator.rb +460 -0
- data/lib/pretentious/recorded_proc.rb +43 -0
- data/lib/pretentious/rspec_generator.rb +41 -2
- data/lib/pretentious/version.rb +1 -1
- data/run_test.sh +1 -1
- data/spec/fibonacci_spec.rb +0 -2
- data/spec/generator_spec.rb +148 -0
- data/spec/prententious_spec.rb +27 -0
- data/spec/test_class1_spec.rb +14 -15
- data/spec/test_class2_spec.rb +0 -1
- data/spec/test_class3_spec.rb +4 -6
- data/spec/test_class4_spec.rb +3 -4
- data/spec/test_class_for_auto_stub_spec.rb +25 -0
- data/spec/test_class_for_mocks_spec.rb +53 -0
- data/test/test_generator.rb +4 -0
- data/test_classes.rb +96 -0
- metadata +12 -2
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe TestClassForAutoStub do
|
4
|
+
|
5
|
+
context 'Scenario 1' do
|
6
|
+
before do
|
7
|
+
|
8
|
+
@fixture = TestClassForAutoStub.new
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should pass current expectations' do
|
13
|
+
|
14
|
+
var_2157894280 = ["Hello Glorious world", "HI THERE!!!!"]
|
15
|
+
|
16
|
+
allow_any_instance_of(ClassUsedByTestClass).to receive(:stubbed_method).and_return("Hello Glorious world")
|
17
|
+
allow_any_instance_of(AnotherClassUsedByTestClass).to receive(:get_message).and_return("HI THERE!!!!")
|
18
|
+
|
19
|
+
# TestClassForAutoStub#method_that_uses_the_class_to_stub should return ["Hello Glorious world", "HI THERE!!!!"]
|
20
|
+
expect( @fixture.method_that_uses_the_class_to_stub ).to eq(["Hello Glorious world", "HI THERE!!!!"])
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe TestClassForMocks do
|
4
|
+
|
5
|
+
context 'Scenario 1' do
|
6
|
+
before do
|
7
|
+
|
8
|
+
@fixture = TestClassForMocks.new
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should pass current expectations' do
|
13
|
+
|
14
|
+
var_2158090860 = [2, 3, 4, 5]
|
15
|
+
|
16
|
+
allow_any_instance_of(TestMockSubClass).to receive(:test_method).and_return("a return string")
|
17
|
+
allow_any_instance_of(TestMockSubClass).to receive(:increment_val).and_return(2, 3, 4, 5)
|
18
|
+
|
19
|
+
# TestClassForMocks#method_with_assign= when passed params2 = "test" should return test
|
20
|
+
expect( @fixture.method_with_assign=("test") ).to eq("test")
|
21
|
+
|
22
|
+
# TestClassForMocks#method_with_usage should return a return string
|
23
|
+
expect( @fixture.method_with_usage ).to eq("a return string")
|
24
|
+
|
25
|
+
# TestClassForMocks#method_with_usage2 should return [2, 3, 4, 5]
|
26
|
+
expect( @fixture.method_with_usage2 ).to eq([2, 3, 4, 5])
|
27
|
+
|
28
|
+
# TestClassForMocks#method_with_usage4 should return a return string
|
29
|
+
expect( @fixture.method_with_usage4 ).to eq("a return string")
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'Scenario 2' do
|
35
|
+
before do
|
36
|
+
|
37
|
+
@fixture = TestClassForMocks.new
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should pass current expectations' do
|
42
|
+
|
43
|
+
var_2158024660 = {val: 1, str: "hello world", message: "a message"}
|
44
|
+
|
45
|
+
allow_any_instance_of(TestMockSubClass).to receive(:return_hash).and_return(var_2158024660)
|
46
|
+
|
47
|
+
# TestClassForMocks#method_with_usage3 when passed message = "a message" should return {:val=>1, :str=>"hello world", :message=>"a message"}
|
48
|
+
expect( @fixture.method_with_usage3("a message") ).to eq(var_2158024660)
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/test/test_generator.rb
CHANGED
data/test_classes.rb
CHANGED
@@ -42,6 +42,10 @@ class TestClass1
|
|
42
42
|
puts @message
|
43
43
|
end
|
44
44
|
|
45
|
+
def invoke_class
|
46
|
+
@message.print_message
|
47
|
+
end
|
48
|
+
|
45
49
|
def something_is_wrong
|
46
50
|
raise StandardError.new
|
47
51
|
end
|
@@ -100,3 +104,95 @@ class TestClass4
|
|
100
104
|
end
|
101
105
|
|
102
106
|
end
|
107
|
+
|
108
|
+
class TestMockSubClass
|
109
|
+
|
110
|
+
def initialize
|
111
|
+
@val = 1
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_method
|
115
|
+
"a return string"
|
116
|
+
end
|
117
|
+
|
118
|
+
def increment_val
|
119
|
+
@val += 1
|
120
|
+
@val
|
121
|
+
end
|
122
|
+
|
123
|
+
def return_hash(message)
|
124
|
+
{val: @val, str: "hello world", message: message}
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class TestClassForMocks
|
129
|
+
|
130
|
+
def initialize
|
131
|
+
@test_class2 = TestMockSubClass.new
|
132
|
+
end
|
133
|
+
|
134
|
+
def message(params1)
|
135
|
+
@params1 = params1
|
136
|
+
end
|
137
|
+
|
138
|
+
def method_with_assign=(params2)
|
139
|
+
@params2 = "#{params2}!"
|
140
|
+
@params2
|
141
|
+
end
|
142
|
+
|
143
|
+
def method_with_usage
|
144
|
+
@test_class2.test_method
|
145
|
+
end
|
146
|
+
|
147
|
+
def method_with_usage2
|
148
|
+
results = []
|
149
|
+
results << @test_class2.increment_val
|
150
|
+
results << @test_class2.increment_val
|
151
|
+
results << @test_class2.increment_val
|
152
|
+
results << @test_class2.increment_val
|
153
|
+
results
|
154
|
+
end
|
155
|
+
|
156
|
+
def method_with_usage4
|
157
|
+
@test_class2.test_method
|
158
|
+
@test_class2.test_method
|
159
|
+
@test_class2.test_method
|
160
|
+
end
|
161
|
+
|
162
|
+
def method_with_usage3(message)
|
163
|
+
@test_class2.return_hash(message)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
class ClassUsedByTestClass
|
169
|
+
|
170
|
+
def stubbed_method
|
171
|
+
"Hello Glorious world"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
class AnotherClassUsedByTestClass
|
176
|
+
|
177
|
+
def get_message
|
178
|
+
"HI THERE!!!!"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
class TestClassForAutoStub
|
183
|
+
|
184
|
+
def initialize
|
185
|
+
@class_to_be_used = ClassUsedByTestClass.new
|
186
|
+
@class_to_be_used2 = AnotherClassUsedByTestClass.new
|
187
|
+
end
|
188
|
+
|
189
|
+
def method_that_uses_the_class_to_stub
|
190
|
+
@class_to_be_used
|
191
|
+
@class_to_be_used2
|
192
|
+
return_values = []
|
193
|
+
return_values << @class_to_be_used.stubbed_method
|
194
|
+
return_values << @class_to_be_used2.get_message
|
195
|
+
return_values
|
196
|
+
end
|
197
|
+
|
198
|
+
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.0.
|
4
|
+
version: 0.0.8
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|
@@ -84,18 +84,24 @@ files:
|
|
84
84
|
- example.rb
|
85
85
|
- lib/pretentious.rb
|
86
86
|
- lib/pretentious/deconstructor.rb
|
87
|
+
- lib/pretentious/generator.rb
|
88
|
+
- lib/pretentious/recorded_proc.rb
|
87
89
|
- lib/pretentious/rspec_generator.rb
|
88
90
|
- lib/pretentious/version.rb
|
89
91
|
- pretentious.gemspec
|
90
92
|
- run_test.sh
|
91
93
|
- spec/deconstructor_spec.rb
|
92
94
|
- spec/fibonacci_spec.rb
|
95
|
+
- spec/generator_spec.rb
|
93
96
|
- spec/m_d5_spec.rb
|
97
|
+
- spec/prententious_spec.rb
|
94
98
|
- spec/spec_helper.rb
|
95
99
|
- spec/test_class1_spec.rb
|
96
100
|
- spec/test_class2_spec.rb
|
97
101
|
- spec/test_class3_spec.rb
|
98
102
|
- spec/test_class4_spec.rb
|
103
|
+
- spec/test_class_for_auto_stub_spec.rb
|
104
|
+
- spec/test_class_for_mocks_spec.rb
|
99
105
|
- test/test_generator.rb
|
100
106
|
- test_classes.rb
|
101
107
|
homepage: https://github.com/jedld/pretentious
|
@@ -126,11 +132,15 @@ summary: Generate tests from existing code as well as a way to deal with pretent
|
|
126
132
|
test_files:
|
127
133
|
- spec/deconstructor_spec.rb
|
128
134
|
- spec/fibonacci_spec.rb
|
135
|
+
- spec/generator_spec.rb
|
129
136
|
- spec/m_d5_spec.rb
|
137
|
+
- spec/prententious_spec.rb
|
130
138
|
- spec/spec_helper.rb
|
131
139
|
- spec/test_class1_spec.rb
|
132
140
|
- spec/test_class2_spec.rb
|
133
141
|
- spec/test_class3_spec.rb
|
134
142
|
- spec/test_class4_spec.rb
|
143
|
+
- spec/test_class_for_auto_stub_spec.rb
|
144
|
+
- spec/test_class_for_mocks_spec.rb
|
135
145
|
- test/test_generator.rb
|
136
146
|
has_rdoc:
|