Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transpec treats expect { }.should raise_error(Foo) as negative #64

Closed
jkingdon opened this issue May 22, 2014 · 1 comment
Closed

transpec treats expect { }.should raise_error(Foo) as negative #64

jkingdon opened this issue May 22, 2014 · 1 comment
Labels

Comments

@jkingdon
Copy link

Here is a test case for the transpec testsuite which should illustrate the bug. When I run it, it fails, specifically it converts raise_error(SpecificErrorClass) to raise_error (which is incorrect because that conversion is supposed to only be for negative assertions). I didn't even know expect { }.should was possible, but I found it in our production app when transpec converted it this way.

diff --git a/spec/transpec/syntax/raise_error_spec.rb b/spec/transpec/syntax/raise_error_spec.rb
index 2fd06f8..b578f6d 100644
--- a/spec/transpec/syntax/raise_error_spec.rb
+++ b/spec/transpec/syntax/raise_error_spec.rb
@@ -63,6 +63,28 @@ module Transpec
           end
         end

+        context 'with expression `expect { }.should raise_error(SpecificErrorClass)`' do
+          let(:source) do
+            <<-END
+              describe 'example' do
+                it 'raises SpecificErrorClass' do
+                  expect { do_something }.should raise_error(SpecificErrorClass)
+                end
+              end
+            END
+          end
+
+          let(:raise_error_object) { expect_object.raise_error_matcher }
+
+          it 'does nothing' do
+            rewritten_source.should == source
+          end
+
+          it 'reports nothing' do
+            raise_error_object.report.records.should be_empty
+          end
+        end
+
         context 'with expression `lambda { }.should raise_error(SpecificErrorClass) { |error| ... }`' do
           let(:source) do
             <<-END
@yujinakayama
Copy link
Owner

Thanks for the report. I'll take a look later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants