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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23e8df69cf26a5fe92e93cb0817062746ab6ceaa
4
- data.tar.gz: 615b879c9b613ff061b6e2cbc2268eb2b77f229e
3
+ metadata.gz: 51efb48bbde5bb4b866edc7919290fd09c1286ea
4
+ data.tar.gz: 0a2a2f6ad3b6310f0dd4ecb53b8ac157c3ab9642
5
5
  SHA512:
6
- metadata.gz: 3d6bd922cb89047a78a052b933dedb9aa720136603e06a2e63ee9da37b2b81807dccad7defb05d7d09b2ec42601ce01681c3d0ef633981cc64dc9c7b1475cee3
7
- data.tar.gz: d2a37cf90928208e85486b5de0b5f8d40603f0239a7591586cdeca69637ce553e2ff71aad28811d3f871ceefd69ef1201605b94a77dbe544cd2ccaed5f6308b9
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
- expectation_method_name = parent_node.children[1]
24
- [:should, :to].include?(expectation_method_name)
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
@@ -5,7 +5,7 @@ module Transpec
5
5
  module Version
6
6
  MAJOR = 0
7
7
  MINOR = 2
8
- PATCH = 2
8
+ PATCH = 3
9
9
 
10
10
  def self.to_s
11
11
  [MAJOR, MINOR, PATCH].join('.')
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transpec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Nakayama