Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c1fe76f1
Commit
c1fe76f1
authored
Jul 10, 2019
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the `abort_execution` matcher
parent
6769aab0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
spec/support/matchers/abort_matcher.rb
spec/support/matchers/abort_matcher.rb
+46
-0
No files found.
spec/support/matchers/abort_matcher.rb
0 → 100644
View file @
c1fe76f1
RSpec
::
Matchers
.
define
:abort_execution
do
match
do
|
code_block
|
@captured_stderr
=
StringIO
.
new
original_stderr
=
$stderr
$stderr
=
@captured_stderr
code_block
.
call
false
rescue
SystemExit
=>
e
captured
=
@captured_stderr
.
string
.
chomp
@actual_exit_code
=
e
.
status
break
false
unless
e
.
status
==
1
if
@message
if
@message
.
is_a?
String
@message
==
captured
elsif
@message
.
is_a?
Regexp
@message
.
match?
(
captured
)
else
raise
ArgumentError
,
'with_message must be either a String or a Regular Expression'
end
end
ensure
$stderr
=
original_stderr
end
chain
:with_message
do
|
message
|
@message
=
message
end
failure_message
do
|
block
|
unless
@actual_exit_code
break
"expected
#{
block
}
to abort with '
#{
@message
}
' but didnt call abort."
end
if
@actual_exit_code
!=
1
break
"expected
#{
block
}
to abort with: '
#{
@message
}
' but exited with success instead."
end
"expected
#{
block
}
to abort with: '
#{
@message
}
'
\n
but received: '
#{
@captured_stderr
.
string
.
chomp
}
' instead."
end
supports_block_expectations
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment