Skip to content

Instantly share code, notes, and snippets.

@shingara
Last active December 11, 2015 21:38
Show Gist options
  • Save shingara/4663639 to your computer and use it in GitHub Desktop.
Save shingara/4663639 to your computer and use it in GitHub Desktop.
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
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