transpec 0.2.2 → 0.2.3
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/.rubocop.yml +8 -0
- data/CHANGELOG.md +4 -0
- data/lib/transpec/syntax/raise_error.rb +7 -2
- data/lib/transpec/version.rb +1 -1
- data/spec/transpec/syntax/raise_error_spec.rb +124 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51efb48bbde5bb4b866edc7919290fd09c1286ea
|
4
|
+
data.tar.gz: 0a2a2f6ad3b6310f0dd4ecb53b8ac157c3ab9642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2141b0d96bcc0e92b4fa4652010f560abbe10745172b3cf2140fecaec9c454ef9e05ab61a6a73f8df6b0a2e4d13437bdae157c4ec78b95284cd10e6d6452854d
|
7
|
+
data.tar.gz: d5a6b210ee1559ed1dc5b99f478959108f3a7a2d2b8815bd50961cca190430609266ee1cb946f859aef485f8cbac9373a8dead74605757f537a66713b3f8efe7
|
data/.rubocop.yml
CHANGED
@@ -47,3 +47,11 @@ Documentation:
|
|
47
47
|
# Currently IndentationWidth reports false positive offence around here document.
|
48
48
|
IndentationWidth:
|
49
49
|
Enabled: false
|
50
|
+
|
51
|
+
# Custom error classes require custom arguments.
|
52
|
+
RaiseArgs:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
# Currently ClassLength counts innner class' codes in a namespace class.
|
56
|
+
ClassLength:
|
57
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
+
## v0.2.3
|
6
|
+
|
7
|
+
* Fix a bug where arguments of positive error expectation with block were removed (e.g. `expect { }.to raise_error(SpecificErrorClass) { |e| ... }` was converted to `expect { }.to raise_error { |e| ... }` unintentionally)
|
8
|
+
|
5
9
|
## v0.2.2
|
6
10
|
|
7
11
|
* Fix a crash on syntax configuration with variable in `RSpec.configure` (e.g. `RSpec.configure { |config| config.expect_with { |c| c.syntax = some_syntax } }`)
|
@@ -20,8 +20,13 @@ module Transpec
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def positive?
|
23
|
-
|
24
|
-
|
23
|
+
ancestor_nodes.reverse_each do |ancestor_node|
|
24
|
+
next unless ancestor_node.type == :send
|
25
|
+
expectation_method_name = ancestor_node.children[1]
|
26
|
+
return [:should, :to].include?(expectation_method_name)
|
27
|
+
end
|
28
|
+
|
29
|
+
false
|
25
30
|
end
|
26
31
|
|
27
32
|
private
|
data/lib/transpec/version.rb
CHANGED
@@ -22,6 +22,94 @@ module Transpec
|
|
22
22
|
|
23
23
|
let(:record) { raise_error_object.report.records.first }
|
24
24
|
|
25
|
+
describe '#positive?' do
|
26
|
+
subject { raise_error_object.positive? }
|
27
|
+
|
28
|
+
context 'when it is `lambda { }.should raise_error` form' do
|
29
|
+
let(:source) do
|
30
|
+
<<-END
|
31
|
+
it 'raises error' do
|
32
|
+
lambda { do_something }.should raise_error
|
33
|
+
end
|
34
|
+
END
|
35
|
+
end
|
36
|
+
|
37
|
+
it { should be_true }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when it is `expect { }.to raise_error` form' do
|
41
|
+
let(:source) do
|
42
|
+
<<-END
|
43
|
+
it 'raises error' do
|
44
|
+
expect { do_something }.to raise_error
|
45
|
+
end
|
46
|
+
END
|
47
|
+
end
|
48
|
+
|
49
|
+
it { should be_true }
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when it is `lambda { }.should raise_error { |error| ... }` form' do
|
53
|
+
let(:source) do
|
54
|
+
<<-END
|
55
|
+
it 'raises error' do
|
56
|
+
lambda { do_something }.should raise_error { |error| do_anything }
|
57
|
+
end
|
58
|
+
END
|
59
|
+
end
|
60
|
+
|
61
|
+
it { should be_true }
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when it is `expect { }.to raise_error { |error| ... }` form' do
|
65
|
+
let(:source) do
|
66
|
+
<<-END
|
67
|
+
it 'raises error' do
|
68
|
+
expect { do_something }.to raise_error { |error| do_anything }
|
69
|
+
end
|
70
|
+
END
|
71
|
+
end
|
72
|
+
|
73
|
+
it { should be_true }
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when it is `lambda { }.should_not raise_error` form' do
|
77
|
+
let(:source) do
|
78
|
+
<<-END
|
79
|
+
it 'does not raise error' do
|
80
|
+
lambda { do_something }.should_not raise_error
|
81
|
+
end
|
82
|
+
END
|
83
|
+
end
|
84
|
+
|
85
|
+
it { should be_false }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when it is `expect { }.not_to raise_error` form' do
|
89
|
+
let(:source) do
|
90
|
+
<<-END
|
91
|
+
it 'does not raise error' do
|
92
|
+
expect { do_something }.not_to raise_error
|
93
|
+
end
|
94
|
+
END
|
95
|
+
end
|
96
|
+
|
97
|
+
it { should be_false }
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when it is `expect { }.to_not raise_error` form' do
|
101
|
+
let(:source) do
|
102
|
+
<<-END
|
103
|
+
it 'does not raise error' do
|
104
|
+
expect { do_something }.to_not raise_error
|
105
|
+
end
|
106
|
+
END
|
107
|
+
end
|
108
|
+
|
109
|
+
it { should be_false }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
25
113
|
describe '#remove_error_specification_with_negative_expectation!' do
|
26
114
|
before do
|
27
115
|
raise_error_object.remove_error_specification_with_negative_expectation!
|
@@ -63,6 +151,42 @@ module Transpec
|
|
63
151
|
end
|
64
152
|
end
|
65
153
|
|
154
|
+
context 'when it is `lambda { }.should raise_error(SpecificErrorClass) { |error| ... }` form' do
|
155
|
+
let(:source) do
|
156
|
+
<<-END
|
157
|
+
it 'raises SpecificErrorClass' do
|
158
|
+
lambda { do_something }.should raise_error(SpecificErrorClass) { |error| do_anything }
|
159
|
+
end
|
160
|
+
END
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'does nothing' do
|
164
|
+
rewritten_source.should == source
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'reports nothing' do
|
168
|
+
raise_error_object.report.records.should be_empty
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'when it is `expect { }.to raise_error(SpecificErrorClass) { |error| ... }` form' do
|
173
|
+
let(:source) do
|
174
|
+
<<-END
|
175
|
+
it 'raises SpecificErrorClass' do
|
176
|
+
expect { do_something }.to raise_error(SpecificErrorClass) { |error| do_anything }
|
177
|
+
end
|
178
|
+
END
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'does nothing' do
|
182
|
+
rewritten_source.should == source
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'reports nothing' do
|
186
|
+
raise_error_object.report.records.should be_empty
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
66
190
|
context 'when it is `lambda { }.should_not raise_error(SpecificErrorClass)` form' do
|
67
191
|
let(:source) do
|
68
192
|
<<-END
|