-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* method for listing codes by type * specify type * include type description * optimize slow code * refactor methods with high branch size * add regex to throw error if type entered is wrong * fix bug in grouping * separate code type constant into file * refactor tests for system exits * remove redundant code * add more test coverage * add rspec matchers to test for actual status code * bump version
- Loading branch information
Yusuf Daniju
authored and
Austin Kabiru
committed
Mar 5, 2017
1 parent
e4b78bb
commit 9be5d74
Showing
9 changed files
with
148 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
/tmp/ | ||
/config/env.yaml | ||
/*.gem | ||
test.log |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Hscode | ||
STATUS_CODE_TYPES = { | ||
'1xx' => 'Informational', | ||
'2xx' => 'Sucess', | ||
'3xx' => 'Redirection', | ||
'4xx' => 'Client Error', | ||
'5xx' => 'Server Error' | ||
}.freeze | ||
end |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Hscode | ||
VERSION = '0.1.1'.freeze | ||
VERSION = '0.1.2'.freeze | ||
end |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
RSpec::Matchers.define :terminate do |_code| | ||
actual = nil | ||
|
||
def supports_block_expectations? | ||
true | ||
end | ||
|
||
match do |block| | ||
begin | ||
block.call | ||
rescue SystemExit => e | ||
actual = e.status | ||
end | ||
actual && (actual == status_code) | ||
end | ||
|
||
chain :with_code do |status_code| | ||
@status_code = status_code | ||
end | ||
|
||
failure_message do |_block| | ||
"expected block to call exit(#{status_code}) but exit" + | ||
(actual.nil? ? ' not called' : "(#{actual}) was called") | ||
end | ||
|
||
failure_message_when_negated do |_block| | ||
"expected block not to call exit(#{status_code})" | ||
end | ||
|
||
description do | ||
"expect block to call exit(#{status_code})" | ||
end | ||
|
||
def status_code | ||
@status_code ||= 0 | ||
end | ||
end |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters