@@ -8,6 +8,17 @@ var File = require('vinyl');
8
8
9
9
describe ( 'gulp-replace' , function ( ) {
10
10
describe ( 'replacePlugin()' , function ( ) {
11
+ var replacements ;
12
+
13
+ beforeEach ( function ( ) {
14
+ replacements = [
15
+ 'cow' ,
16
+ 'chicken' ,
17
+ 'duck' ,
18
+ 'person'
19
+ ] ;
20
+ } ) ;
21
+
11
22
describe ( 'buffered input' , function ( ) {
12
23
var file ;
13
24
@@ -66,12 +77,6 @@ describe('gulp-replace', function() {
66
77
67
78
68
79
it ( 'should call function once for each replacement when replacing a string on a buffer' , function ( done ) {
69
- var replacements = [
70
- 'cow' ,
71
- 'chicken' ,
72
- 'duck' ,
73
- 'person'
74
- ] ;
75
80
var stream = replacePlugin ( 'world' , function ( ) { return replacements . shift ( ) ; } ) ;
76
81
stream . on ( 'data' , function ( newFile ) {
77
82
String ( newFile . contents ) . should . equal ( fs . readFileSync ( 'test/expected/hellofarm.txt' , 'utf8' ) ) ;
@@ -84,12 +89,6 @@ describe('gulp-replace', function() {
84
89
85
90
86
91
it ( 'should call function once for each replacement when replacing a regex on a buffer' , function ( done ) {
87
- var replacements = [
88
- 'cow' ,
89
- 'chicken' ,
90
- 'duck' ,
91
- 'person'
92
- ] ;
93
92
var stream = replacePlugin ( / w o r l d / g, function ( ) { return replacements . shift ( ) ; } ) ;
94
93
stream . on ( 'data' , function ( newFile ) {
95
94
String ( newFile . contents ) . should . equal ( fs . readFileSync ( 'test/expected/hellofarm.txt' , 'utf8' ) ) ;
@@ -177,12 +176,6 @@ describe('gulp-replace', function() {
177
176
} ) ;
178
177
179
178
it ( 'should call function once for each replacement when replacing a string on a stream' , function ( done ) {
180
- var replacements = [
181
- 'cow' ,
182
- 'chicken' ,
183
- 'duck' ,
184
- 'person'
185
- ] ;
186
179
var stream = replacePlugin ( 'world' , function ( ) { return replacements . shift ( ) ; } ) ;
187
180
stream . on ( 'data' , function ( newFile ) {
188
181
newFile . contents . pipe ( concatStream ( { encoding : 'string' } , function ( data ) {
@@ -196,12 +189,6 @@ describe('gulp-replace', function() {
196
189
} ) ;
197
190
198
191
it ( 'should call function once for each replacement when replacing a regex on a stream' , function ( done ) {
199
- var replacements = [
200
- 'cow' ,
201
- 'chicken' ,
202
- 'duck' ,
203
- 'person'
204
- ] ;
205
192
var stream = replacePlugin ( / w o r l d / g, function ( ) { return replacements . shift ( ) ; } ) ;
206
193
stream . on ( 'data' , function ( newFile ) {
207
194
newFile . contents . pipe ( concatStream ( { encoding : 'string' } , function ( data ) {
0 commit comments