Skip to content

Commit

Permalink
improving tests description a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Plentz committed Aug 31, 2011
1 parent 4d10c8e commit ee4c92b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
JRuby 1.6.4(1.9 mode) doesn't work the same way then MRI 1.9.2p290 with String encoding

***
### MRI
### Ruby MRI 1.9.2p290

````
~/Projects/opensource/utf8_report (master) $ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
~/Projects/opensource/utf8_report (master) $ rspec spec
No DRb server is running. Running in local process instead ...
..
...
Finished in 0.4195 seconds
2 examples, 0 failures
Finished in 0.62514 seconds
3 examples, 0 failures
````

***
### JRUBY
### JRuby 1.6.4(1.9 mode)

````
~/Projects/opensource/utf8_report (master) $ jruby --1.9 -S rspec spec
No DRb server is running. Running in local process instead ...
FF
FF.
Failures:
1) Foo fail
1) Foo should do the right interpolation for error messages
Failure/Error: lambda{foo.save!}.should raise_error ActiveRecord::RecordInvalid
expected ActiveRecord::RecordInvalid, got #<Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT>
# ./spec/models/foo_spec.rb:8:in `(root)'
# org/jruby/RubyBasicObject.java:1717:in `instance_eval'
# org/jruby/RubyArray.java:2344:in `collect'
# org/jruby/RubyArray.java:2344:in `collect'
2) Foo fail again
Failure/Error: ActiveSupport::JSON.decode({:message => "á"}.to_json)['message'].should eq ActiveSupport::JSON.decode("á".to_json)
2) Foo should decode json even with special chars
Failure/Error: ActiveSupport::JSON.decode({:message => "á"}.to_json)['message'].should eq "á"
expected "á"
got "á"
Expand All @@ -44,11 +42,12 @@ Failures:
# org/jruby/RubyArray.java:2344:in `collect'
# org/jruby/RubyArray.java:2344:in `collect'
Finished in 1.02 seconds
2 examples, 2 failures
Finished in 1.08 seconds
3 examples, 2 failures
Failed examples:
rspec ./spec/models/foo_spec.rb:6 # Foo fail
rspec ./spec/models/foo_spec.rb:11 # Foo fail again
rspec ./spec/models/foo_spec.rb:6 # Foo should do the right interpolation for error messages
rspec ./spec/models/foo_spec.rb:11 # Foo should decode json even with special chars
````
10 changes: 7 additions & 3 deletions spec/models/foo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
require 'spec_helper'

describe Foo do
it "fail" do
it "should do the right interpolation for error messages" do
foo = Foo.new
lambda{foo.save!}.should raise_error ActiveRecord::RecordInvalid
end

it "fail again" do
ActiveSupport::JSON.decode({:message => "á"}.to_json)['message'].should eq ActiveSupport::JSON.decode("á".to_json)
it "should decode json even with special chars" do
ActiveSupport::JSON.decode({:message => "á"}.to_json)['message'].should eq "á"
end

it "should decode json even with special chars - this one works" do
ActiveSupport::JSON.decode("á".to_json).should eq "á"
end
end

0 comments on commit ee4c92b

Please sign in to comment.