@@ -41,68 +41,63 @@ describe('Jasmine', function() {
41
41
expect ( this . testJasmine . specFiles ) . toEqual ( [ 'some/file/path.js' ] ) ;
42
42
} ) ;
43
43
44
- describe ( 'file handler' , function ( ) {
45
- function basename ( name ) { return path . basename ( name ) ; }
46
-
47
- it ( 'add spec files with absolute glob pattern' , function ( ) {
48
- if ( ! path . isAbsolute ) { return ; }
49
- var aFile = path . join ( this . testJasmine . projectBaseDir , this . testJasmine . specDir , 'spec/command_spec.js' ) ;
50
- expect ( this . testJasmine . specFiles ) . toEqual ( [ ] ) ;
51
- this . testJasmine . addSpecFiles ( [ aFile ] ) ;
52
- expect ( this . testJasmine . specFiles ) . toEqual ( [ slash ( aFile ) ] ) ;
44
+ describe ( 'Methods that specify files via globs' , function ( ) {
45
+ describe ( '#addSpecFiles' , function ( ) {
46
+ hasCommonFileGlobBehavior ( 'addSpecFiles' , 'specFiles' ) ;
53
47
} ) ;
54
48
55
- it ( 'add spec files with glob pattern' , function ( ) {
56
- expect ( this . testJasmine . specFiles ) . toEqual ( [ ] ) ;
57
- this . testJasmine . addSpecFiles ( [ 'spec/fixtures/jasmine_spec/*.js' ] ) ;
58
- expect ( this . testJasmine . specFiles . map ( basename ) ) . toEqual ( [
59
- 'c.js' ,
60
- 'd.js' ,
61
- 'e.js' ,
62
- 'f.js' ,
63
- ] ) ;
49
+ describe ( '#addHelperFiles' , function ( ) {
50
+ hasCommonFileGlobBehavior ( 'addHelperFiles' , 'helperFiles' ) ;
64
51
} ) ;
65
52
66
- it ( 'add spec files with excluded files' , function ( ) {
67
- expect ( this . testJasmine . specFiles ) . toEqual ( [ ] ) ;
68
- this . testJasmine . addSpecFiles ( [
69
- 'spec/fixtures/jasmine_spec/*.js' ,
70
- '!spec/fixtures/jasmine_spec/c*'
71
- ] ) ;
72
- expect ( this . testJasmine . specFiles . map ( basename ) ) . toEqual ( [
73
- 'd.js' ,
74
- 'e.js' ,
75
- 'f.js' ,
76
- ] ) ;
77
- } ) ;
53
+ function hasCommonFileGlobBehavior ( method , destProp ) {
54
+ it ( 'adds a file with an absolute path' , function ( ) {
55
+ var aFile = path . join ( this . testJasmine . projectBaseDir , this . testJasmine . specDir , 'spec/command_spec.js' ) ;
56
+ expect ( this . testJasmine [ destProp ] ) . toEqual ( [ ] ) ;
57
+ this . testJasmine [ method ] ( [ aFile ] ) ;
58
+ expect ( this . testJasmine [ destProp ] ) . toEqual ( [ slash ( aFile ) ] ) ;
59
+ } ) ;
78
60
79
- it ( 'add spec files with glob pattern to existings files' , function ( ) {
80
- var aFile = path . join ( this . testJasmine . projectBaseDir , this . testJasmine . specDir , 'spec/command_spec.js' ) ;
81
- this . testJasmine . specFiles = [ aFile , 'b' ] ;
82
- this . testJasmine . addSpecFiles ( [ 'spec/fixtures/jasmine_spec/*.js' ] ) ;
83
- expect ( this . testJasmine . specFiles . map ( basename ) ) . toEqual ( [
84
- 'command_spec.js' ,
85
- 'b' ,
86
- 'c.js' ,
87
- 'd.js' ,
88
- 'e.js' ,
89
- 'f.js' ,
90
- ] ) ;
91
- } ) ;
61
+ it ( 'adds files that match a glob pattern' , function ( ) {
62
+ expect ( this . testJasmine [ destProp ] ) . toEqual ( [ ] ) ;
63
+ this . testJasmine [ method ] ( [ 'spec/fixtures/jasmine_spec/*.js' ] ) ;
64
+ expect ( this . testJasmine [ destProp ] . map ( basename ) ) . toEqual ( [
65
+ 'c.js' ,
66
+ 'd.js' ,
67
+ 'e.js' ,
68
+ 'f.js' ,
69
+ ] ) ;
70
+ } ) ;
92
71
93
- it ( 'add helper files with glob pattern to existings files' , function ( ) {
94
- var aFile = path . join ( this . testJasmine . projectBaseDir , this . testJasmine . specDir , 'spec/command_spec.js' ) ;
95
- this . testJasmine . helperFiles = [ aFile , 'b' ] ;
96
- this . testJasmine . addHelperFiles ( [ 'spec/fixtures/jasmine_spec/*.js' ] ) ;
97
- expect ( this . testJasmine . helperFiles . map ( basename ) ) . toEqual ( [
98
- 'command_spec.js' ,
99
- 'b' ,
100
- 'c.js' ,
101
- 'd.js' ,
102
- 'e.js' ,
103
- 'f.js' ,
104
- ] ) ;
105
- } ) ;
72
+ it ( 'can exclude files that match another glob' , function ( ) {
73
+ expect ( this . testJasmine [ destProp ] ) . toEqual ( [ ] ) ;
74
+ this . testJasmine [ method ] ( [
75
+ 'spec/fixtures/jasmine_spec/*.js' ,
76
+ '!spec/fixtures/jasmine_spec/c*'
77
+ ] ) ;
78
+ expect ( this . testJasmine [ destProp ] . map ( basename ) ) . toEqual ( [
79
+ 'd.js' ,
80
+ 'e.js' ,
81
+ 'f.js' ,
82
+ ] ) ;
83
+ } ) ;
84
+
85
+ it ( 'adds new files to existing files' , function ( ) {
86
+ var aFile = path . join ( this . testJasmine . projectBaseDir , this . testJasmine . specDir , 'spec/command_spec.js' ) ;
87
+ this . testJasmine [ destProp ] = [ aFile , 'b' ] ;
88
+ this . testJasmine [ method ] ( [ 'spec/fixtures/jasmine_spec/*.js' ] ) ;
89
+ expect ( this . testJasmine [ destProp ] . map ( basename ) ) . toEqual ( [
90
+ 'command_spec.js' ,
91
+ 'b' ,
92
+ 'c.js' ,
93
+ 'd.js' ,
94
+ 'e.js' ,
95
+ 'f.js' ,
96
+ ] ) ;
97
+ } ) ;
98
+ }
99
+
100
+ function basename ( name ) { return path . basename ( name ) ; }
106
101
} ) ;
107
102
108
103
it ( 'delegates #coreVersion to jasmine-core' , function ( ) {
0 commit comments