Skip to content

Commit

Permalink
pickle filter: support relative paths (#962)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmuller99 authored and charlierudolph committed Oct 24, 2017
1 parent 329ae81 commit 6e23320
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/pickle_filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash'
import path from 'path'
import { TagExpressionParser } from 'cucumber-tag-expressions'

const FEATURE_LINENUM_REGEXP = /^(.*?)((?::[\d]+)+)?$/
Expand All @@ -20,7 +21,7 @@ export default class PickleFilter {
featurePaths.forEach(featurePath => {
const match = FEATURE_LINENUM_REGEXP.exec(featurePath)
if (match) {
const uri = match[1]
const uri = path.resolve(match[1])
const linesExpression = match[2]
if (linesExpression) {
if (!mapping[uri]) {
Expand All @@ -47,7 +48,7 @@ export default class PickleFilter {
}

matchesAnyLine({ pickle, uri }) {
const lines = this.featureUriToLinesMapping[uri]
const lines = this.featureUriToLinesMapping[path.resolve(uri)]
if (lines) {
return _.size(_.intersection(lines, _.map(pickle.locations, 'line'))) > 0
} else {
Expand Down
28 changes: 26 additions & 2 deletions src/pickle_filter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,32 @@ describe('PickleFilter', function() {
})
})
})

describe('scenario line using current directory path representation', function() {
beforeEach(function() {
this.input.uri = './features/b.feature'
})

describe('scenario line matches', function() {
beforeEach(function() {
this.input.pickle.locations = [{ line: 1 }]
})

it('returns true', function() {
expect(this.pickleFilter.matches(this.input)).to.be.true
})
})

describe('scenario line does not match', function() {
beforeEach(function() {
this.input.pickle.locations = [{ line: 3 }]
})

it('returns false', function() {
expect(this.pickleFilter.matches(this.input)).to.be.false
})
})
})
})

describe('name filters', function() {
Expand Down Expand Up @@ -321,7 +347,6 @@ describe('PickleFilter', function() {
tagExpressions: ['tagA']
})
this.input.pickle.locations = [{ line: 1 }]
this.input.uri = this.scenarioPath
})

it('returns false', function() {
Expand All @@ -337,7 +362,6 @@ describe('PickleFilter', function() {
tagExpression: '@tagA'
})
this.input.pickle.locations = [{ line: 1 }]
this.input.uri = this.scenarioPath
})

it('returns false', function() {
Expand Down

0 comments on commit 6e23320

Please sign in to comment.