Created
July 3, 2015 11:21
-
-
Save erwanlr/60c3d7ceee600e88ba96 to your computer and use it in GitHub Desktop.
Revisions
-
erwanlr created this gist
Jul 3, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ require 'rspec' require 'optparse' module Test class Error < StandardError end class AnotherError < Error def to_s 'this message exactly' end end end RSpec.describe 'matching error message with string' do it 'matches the error message' do expect { raise StandardError, 'this message exactly'}. to raise_error(StandardError, 'this message exactly') end it 'matches the error message' do expect { raise Test::Error, 'this message exactly' }. to raise_error(Test::Error, 'this message exactly') end it 'matches the error message' do expect { raise Test::AnotherError }. to raise_error(Test::AnotherError, 'this message exactly') end it 'matches the error message, but does not :x' do expect { raise OptionParser::InvalidArgument, 'this message exactly'}. to raise_error(OptionParser::InvalidArgument, 'this message exactly') end end