Commit 2d2fe2cf authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Add first shared examples to a helper and updated teaspoon_env to allow helper specs to run

parent e2f0b830
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
"plugins": ["jasmine"], "plugins": ["jasmine"],
"rules": { "rules": {
"prefer-arrow-callback": 0, "prefer-arrow-callback": 0,
"func-names": 0 "func-names": 0,
"jasmine/no-suite-dupes": [1, "branch"],
"jasmine/no-spec-dupes": [1, "branch"]
} }
} }
/* eslint-disable no-unused-vars */
class ClassSpecHelper {
static itShouldBeAStaticMethod(base, method) {
return it('should be a static method', () => {
expect(Object.prototype.hasOwnProperty.call(base, method)).toBeTruthy();
});
}
}
/* global ClassSpecHelper */
//= require ./class_spec_helper
describe('ClassSpecHelper', () => {
describe('.itShouldBeAStaticMethod', function () {
beforeEach(() => {
class TestClass {
instanceMethod() { this.prop = 'val'; }
static staticMethod() {}
}
this.TestClass = TestClass;
});
ClassSpecHelper.itShouldBeAStaticMethod(ClassSpecHelper, 'itShouldBeAStaticMethod');
it('should have a defined spec', () => {
expect(ClassSpecHelper.itShouldBeAStaticMethod(this.TestClass, 'staticMethod').description).toBe('should be a static method');
});
it('should pass for a static method', () => {
const spec = ClassSpecHelper.itShouldBeAStaticMethod(this.TestClass, 'staticMethod');
expect(spec.status()).toBe('passed');
});
it('should fail for an instance method', (done) => {
const spec = ClassSpecHelper.itShouldBeAStaticMethod(this.TestClass, 'instanceMethod');
spec.resultCallback = (result) => {
expect(result.status).toBe('failed');
done();
};
spec.execute();
});
});
});
...@@ -166,7 +166,7 @@ Teaspoon.configure do |config| ...@@ -166,7 +166,7 @@ Teaspoon.configure do |config|
# Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The # Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The
# default excludes assets from vendor, gems and support libraries. # default excludes assets from vendor, gems and support libraries.
coverage.ignore = [%r{vendor/}, %r{spec/}] coverage.ignore = [%r{vendor/}, %r{spec/javascripts/(?!helpers/)}]
# Various thresholds requirements can be defined, and those thresholds will be checked at the end of a run. If any # Various thresholds requirements can be defined, and those thresholds will be checked at the end of a run. If any
# aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil. # aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment