diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-01-04 12:01:14 +0000 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-01-18 13:33:08 +0000 |
commit | 2d2fe2cfee2c5919c95f872fb5c875d787ef084f (patch) | |
tree | 56d7e3e8888ef0b5e6dcba344eb0bb694fe0d6b6 /spec | |
parent | e2f0b83061df3b19b683b67d142acea65d5df0fd (diff) | |
download | gitlab-ce-allow-shared-examples-jasmine.tar.gz |
Add first shared examples to a helper and updated teaspoon_env to allow helper specs to runallow-shared-examples-jasmine
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/.eslintrc | 4 | ||||
-rw-r--r-- | spec/javascripts/helpers/class_spec_helper.js.es6 | 9 | ||||
-rw-r--r-- | spec/javascripts/helpers/class_spec_helper_spec.js.es6 | 35 | ||||
-rw-r--r-- | spec/teaspoon_env.rb | 2 |
4 files changed, 48 insertions, 2 deletions
diff --git a/spec/javascripts/.eslintrc b/spec/javascripts/.eslintrc index dcbcd014dc3..3cd419b37c9 100644 --- a/spec/javascripts/.eslintrc +++ b/spec/javascripts/.eslintrc @@ -23,6 +23,8 @@ "plugins": ["jasmine"], "rules": { "prefer-arrow-callback": 0, - "func-names": 0 + "func-names": 0, + "jasmine/no-suite-dupes": [1, "branch"], + "jasmine/no-spec-dupes": [1, "branch"] } } diff --git a/spec/javascripts/helpers/class_spec_helper.js.es6 b/spec/javascripts/helpers/class_spec_helper.js.es6 new file mode 100644 index 00000000000..92a20687ec5 --- /dev/null +++ b/spec/javascripts/helpers/class_spec_helper.js.es6 @@ -0,0 +1,9 @@ +/* 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(); + }); + } +} diff --git a/spec/javascripts/helpers/class_spec_helper_spec.js.es6 b/spec/javascripts/helpers/class_spec_helper_spec.js.es6 new file mode 100644 index 00000000000..d1155f1bd1e --- /dev/null +++ b/spec/javascripts/helpers/class_spec_helper_spec.js.es6 @@ -0,0 +1,35 @@ +/* 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(); + }); + }); +}); diff --git a/spec/teaspoon_env.rb b/spec/teaspoon_env.rb index 5ea020f313c..643b161cdf4 100644 --- a/spec/teaspoon_env.rb +++ b/spec/teaspoon_env.rb @@ -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 # 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 # aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil. |