-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "base64" | ||
require_relative "spec_helper" | ||
|
||
describe Configuration do | ||
describe "choices" do | ||
it "removes leading and trailing whitespace" do | ||
config = Configuration.from_inputs([" a choice "]) | ||
config.choices.should == ["a choice"] | ||
end | ||
|
||
it "silences invalid UTF characters" do | ||
path = File.expand_path(File.join(File.dirname(__FILE__), | ||
"invalid_utf8.txt")) | ||
invalid_string = File.read(path) | ||
|
||
# Make sure that the string is actually invalid. | ||
expect do | ||
invalid_string.strip | ||
end.to raise_error(ArgumentError, /invalid byte sequence in UTF-8/) | ||
|
||
# We should silently fix the error | ||
expect do | ||
Configuration.from_inputs([invalid_string]) | ||
end.not_to raise_error | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
� |
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,4 @@ | ||
# We can't use `require` or `load` because of the Bash preamble on the script. | ||
source = File.read(File.expand_path("../../selecta", __FILE__)) | ||
preamble, source = source.split("#!ruby", 2) | ||
eval(source) |
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