Last active
August 29, 2015 14:06
-
-
Save scottmessinger/6ba3e80dc029f021a445 to your computer and use it in GitHub Desktop.
How I imagine the migration stuff happening
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
class OldNode | |
def lesson | |
@lesson ||= Lesson.find(id) | |
end | |
def verify_migration | |
self.verify_field_names | |
self.verify_sections | |
end | |
private | |
def verify_field_names | |
raise unless lesson.title == self.title | |
raise unless lesson.sections == self.sections | |
end | |
def verify_sections | |
lesson.sections.each_with_index do |section, index| | |
raise unless section[:title] == self.sections[index][:title] | |
end | |
end | |
end |
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
describe OldNode | |
before(:each) do | |
# somewhere you generate an oldNode. Either form a factory, | |
# inline (a la OldNode.new(...) or from an import. | |
@old_node = TommyMagic.generate(:node) | |
end | |
it "should verify the field names" do | |
old_node.migrate | |
expect{old_node.verify_migration}.to_not raise_error | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh! You might want to create models I haven't. E.g. a section model and a parts model.