RSpec seems to not output the right size of an array, almost like it does not process everything until it is asked to output something. What might be causing this?
Here is a portion of the spec code:
puts project.documents[0].tables[0].digits[5].relationships.size
project.documents[0].tables[0].digits[5].relationships.to_yaml
puts project.documents[0].tables[0].digits[5].relationships.size
The above code outputs:
2
6
There are no threads in the program unless DocSplit is using some sort of threads that I am unaware of. I think that this is an indicator of a larger problem, but I am lost as to what it might be.
Edit: The same thing occurs if I instead (replace the code above with the following) go through and save each of the relationships:
puts project.documents[0].tables[0].digits[5].relationships.size
project.documents.each do |doc|
doc.tables[0].digits.each do |dig|
dig.relationships.each do |rel|
rel.save!
end
end
end
puts project.documents[0].tables[0].digits[5].relationships.size
Except that the results are:
1
6
Edit 2: The Relationship class also belongs to two digits and digits have many relationships. Could that be influential? Here is the code from relationship.rb
belongs_to :digit, :class_name => 'Digit', :foreign_key => 'digit_id'
belongs_to :digit_b, :class_name => 'Digit', :foreign_key => 'digit_b_id'