Last active
December 11, 2015 21:38
-
-
Save shingara/4663639 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'virtus' | |
require 'rspec' | |
require 'mongoid' | |
class User | |
include Virtus | |
attribute :active, Boolean | |
end | |
describe 'corecion' do | |
it 'should be true' do | |
User.new(:active => '1').active.should == true | |
end | |
end | |
# $ rspec coercion_failed_spec.rb [12:38:10] | |
# F | |
# Failures: | |
# 1) corecion should be true | |
# Failure/Error: User.new(:active => '1').active.should == true | |
# expected: true | |
# got: "1" (using ==) | |
# Diff: | |
# @@ -1,2 +1,2 @@ | |
# -true | |
# +"1" | |
# # ./coercion_failed_spec.rb:15:in `block (2 levels) in <top (required)>' | |
# Finished in 0.00078 seconds | |
# 1 example, 1 failure | |
# Failed examples: | |
# rspec ./coercion_failed_spec.rb:14 # corecion should be true | |
# FAIL: 1 | |
This file contains hidden or 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
require 'virtus' | |
require 'rspec' | |
class User | |
include Virtus | |
attribute :active, Boolean | |
end | |
require 'mongoid' | |
describe 'corecion' do | |
it 'should be true' do | |
User.new(:active => '1').active.should == true | |
end | |
end | |
# cyrilmougel@new-host: ~/incompatibility_mongoid_virtus | |
# $ rspec coercion_success_spec.rb [12:38:23] | |
# . | |
# | |
# Finished in 0.00054 seconds | |
# 1 example, 0 failures |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment