Last active
August 29, 2015 14:00
-
-
Save sholden/d0af614f0202d6ad815e to your computer and use it in GitHub Desktop.
failure with output
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
module Identifiable | |
extend ActiveSupport::Concern | |
$oids = Set.new | |
included do | |
after_initialize :generate_uuid | |
validates_presence_of :uuid | |
end | |
private | |
def generate_uuid | |
if self.uuid.blank? | |
self.uuid = SecureRandom.uuid | |
raise "Dupe!!!" if $oids.include?(self.object_id) | |
$oids << self.object_id | |
end | |
end | |
end | |
class Page < ActiveRecord::Base | |
include Identifiable | |
end | |
describe Page do | |
let(:text_question) { | |
Fabricate.build(:text_question) do | |
validations {[ | |
Fabricate.build(:validation, | |
message: 'Required') { | |
condition { Fabricate.build(:presence_condition) } | |
}, | |
Fabricate.build(:validation, | |
message: 'Must be equal') { | |
condition { Fabricate.build(:equality_condition, options: {'value' => 'valid'}) } | |
} | |
]} | |
end | |
} | |
describe '#uuid' do | |
subject { text_question.uuid } | |
context 'with an answer' do | |
let(:answer) { Fabricate.build(:text_answer, page_uuid: text_question.uuid) } | |
it { should eql(answer.page_uuid) } | |
end | |
end | |
end | |
#expected: "f7bafa3f-802a-4117-952c-fc8348bc0469" | |
# got: "7f3f71f2-1c76-45cb-9dcd-322e87befc60" | |
# | |
#(compared using eql?) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment