Skip to content

Instantly share code, notes, and snippets.

@scottmessinger
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottmessinger/6ba3e80dc029f021a445 to your computer and use it in GitHub Desktop.
Save scottmessinger/6ba3e80dc029f021a445 to your computer and use it in GitHub Desktop.
How I imagine the migration stuff happening
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
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
@scottmessinger
Copy link
Author

Oh! You might want to create models I haven't. E.g. a section model and a parts model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment