forked from yamldb/yaml_db
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
verify the database encoding is utf8 or unicode
- Loading branch information
1 parent
ecfe469
commit 1917392
Showing
4 changed files
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require File.dirname(__FILE__) + '/base' | ||
|
||
describe YamlDb do | ||
before do | ||
ActiveRecord::Base = mock('ActiveRecord::Base', :null_object => true) | ||
ActiveRecord::Base.stub!(:configurations).and_return(mock('configurations')) | ||
RAILS_ENV = "test" unless defined?(RAILS_ENV) | ||
end | ||
|
||
it "verifies that the connection is encoded with unicode or utf8" do | ||
@config = { 'encoding' => 'utf8' } | ||
ActiveRecord::Base.configurations.stub!(:[]).with('test').and_return(@config) | ||
lambda { YamlDb.verify_utf8 }.should_not raise_error(YamlDb::EncodingException) | ||
end | ||
|
||
it "raises an exception if encoding is not set" do | ||
@config = { } | ||
ActiveRecord::Base.configurations.stub!(:[]).with('test').and_return(@config) | ||
lambda { YamlDb.verify_utf8 }.should raise_error(YamlDb::EncodingException) | ||
end | ||
|
||
it "raises an exception if encoding is not utf8 or unicode" do | ||
@config = { 'encoding' => 'latin1' } | ||
ActiveRecord::Base.configurations.stub!(:[]).with('test').and_return(@config) | ||
lambda { YamlDb.verify_utf8 }.should raise_error(YamlDb::EncodingException) | ||
end | ||
end |