-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves KeyError into Shared spec (#576)
* This refactors my work on KeyError features into a shared spec to reduce the duplication.
- Loading branch information
Showing
7 changed files
with
58 additions
and
163 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
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
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,25 @@ | ||
describe :key_error, shared: true do | ||
it "raises a KeyError" do | ||
-> { | ||
@method.call(@object, 'foo') | ||
}.should raise_error(KeyError) | ||
end | ||
|
||
ruby_version_is "2.5" do | ||
it "sets the Hash as the receiver of KeyError" do | ||
-> { | ||
@method.call(@object, 'foo') | ||
}.should raise_error(KeyError) { |err| | ||
err.receiver.should equal(@object) | ||
} | ||
end | ||
|
||
it "sets the unmatched key as the key of KeyError" do | ||
-> { | ||
@method.call(@object, 'foo') | ||
}.should raise_error(KeyError) { |err| | ||
err.key.to_s.should == 'foo' | ||
} | ||
end | ||
end | ||
end |