forked from plentz/jruby_report
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separating and isolating json specs a bit
- Loading branch information
Diego Plentz
committed
Sep 20, 2011
1 parent
7986f74
commit 8c22492
Showing
4 changed files
with
28 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
# encoding: UTF-8 | ||
|
||
require 'spec_helper' | ||
require 'multi_json' | ||
|
||
describe Foo do | ||
it "should do the right interpolation for error messages" do | ||
foo = Foo.new | ||
foo.valid? | ||
lambda{I18n.t("errors.messages.record_invalid", :errors => foo.errors.full_messages)}.should_not raise_error | ||
end | ||
|
||
it "should decode json even with special chars" do | ||
MultiJson.decode({:message => "á"}.to_json)['message'].should eq "á" | ||
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,20 @@ | ||
# encoding: UTF-8 | ||
|
||
require 'spec_helper' | ||
require 'multi_json' | ||
|
||
describe "jruby json" do | ||
#fail | ||
it "should decode json even with special chars using to_json" do | ||
MultiJson.decode({:message => "á"}.to_json)['message'].should eq "á" | ||
end | ||
|
||
#works | ||
it "should decode json even with special chars using a json string directly" do | ||
MultiJson.decode("{\"message\":\"á\"}")['message'].should eq "á" | ||
end | ||
|
||
it "should generate equals jsons" do | ||
({:message => "á"}).to_json.should == "{\"message\":\"á\"}" | ||
end | ||
end |