Skip to content

Commit

Permalink
Adds metadata check to VigilanceExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
darscan committed Jul 16, 2013
1 parent 7205594 commit 69bb9b0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/robotlegs/bender/extensions/vigilance/VigilanceExtension.as
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ package robotlegs.bender.extensions.vigilance
*/
public function extend(context:IContext):void
{
context.injector.instantiateUnmapped(MetadataChecker).check();
context.addLogTarget(this);
context.injector.addEventListener(MappingEvent.MAPPING_OVERRIDE, mappingOverrideHandler)
}
Expand All @@ -62,3 +63,24 @@ package robotlegs.bender.extensions.vigilance
}
}
}

import robotlegs.bender.extensions.vigilance.VigilantError;
import robotlegs.bender.framework.api.IContext;

class MetadataChecker
{
[Inject(optional=true)]
public var context:IContext;

public function check():void
{
if (context == null)
{
throw new VigilantError(
"It looks like custom metadata is being ignored by your compiler. " +
"If you're compiling with the Flash IDE you need to open your " +
'"Publish Settings" and select "Publish SWC". ' +
"See: https://github.com/robotlegs/robotlegs-framework/wiki/Common-Problems");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

package robotlegs.bender.extensions.vigilance
{
import org.hamcrest.assertThat;
import org.hamcrest.text.containsString;

import robotlegs.bender.framework.api.IContext;
import robotlegs.bender.framework.api.IInjector;
import robotlegs.bender.framework.api.ILogger;
Expand Down Expand Up @@ -69,6 +72,24 @@ package robotlegs.bender.extensions.vigilance
logger.fatal("");
}

[Test]
public function extension_throws_when_METADATA_is_missing():void
{
const context:IContext = new Context();
// We can't actually test for missing metadata, so we simulate it.
context.injector.unmap(IContext);
var error:VigilantError;
try
{
context.install(VigilanceExtension);
}
catch(e:VigilantError)
{
error = e;
}
assertThat(error.message, containsString("metadata"));
}

/*============================================================================*/
/* Public Functions */
/*============================================================================*/
Expand Down

0 comments on commit 69bb9b0

Please sign in to comment.