Skip to content

Instantly share code, notes, and snippets.

@H1D
Last active December 17, 2015 11:09
Show Gist options
  • Save H1D/5600198 to your computer and use it in GitHub Desktop.
Save H1D/5600198 to your computer and use it in GitHub Desktop.
Ember.js autoclass for testing
#adds class '<fieldname>' or '<relatedmodel__fieldname>' based on valueBinding
Em.View.reopen
init: ->
@_super.apply(@, arguments)
if Em.testing
testing_class = this.valueBinding?._from?.match(/[\w|\d]+\.[\w|\d]+$/)?[0]
if testing_class
testing_class = testing_class.replace('context.','').replace('.','__')
classes = @get('classNames') || []
classes.push testing_class
@set('classNames', classes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment