Skip to content

Commit

Permalink
(#59) Correctly detect cucumber file
Browse files Browse the repository at this point in the history
  • Loading branch information
moxley committed Sep 11, 2015
1 parent 397f9a5 commit 0ab0431
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## Version 0.9.14

* Correctly detect Cucumber feature file when project has .rspec file (#59)

## Version 0.9.13

* Configurable spec framework and test framework (#57)
Expand Down
2 changes: 1 addition & 1 deletion lib/source-info.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ module.exports =

testFramework: ->
@_testFramework ||= unless @_testFramework
(fs.existsSync(@projectPath() + '/.rspec') and 'rspec') or
((t = @fileType()) and @frameworkLookup[t]) or
(fs.existsSync(@projectPath() + '/.rspec') and 'rspec') or
@projectType()

fileType: ->
Expand Down
19 changes: 11 additions & 8 deletions spec/source-info-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ describe "SourceInfo", ->
for key, value of opts.config
atom.config.set(key, value)

if opts.mkdirs
if opts.mockPaths
spyOn(fs, 'existsSync').andCallFake (path) ->
path in opts.mkdirs
path in opts.mockPaths

beforeEach ->
editor = null
Expand Down Expand Up @@ -157,7 +157,10 @@ describe "SourceInfo", ->
projectPaths: ['/home/user/project_1']
testFile: '/home/user/project_1/foo/foo.feature'
currentLine: 1
mkdirs: ['/home/user/project_1/spec']
mockPaths: [
'/home/user/project_1/spec',
'/home/user/project_1/.rspec'
],
fileContent:
"""
"""
Expand All @@ -170,23 +173,23 @@ describe "SourceInfo", ->
withSetup
projectPaths: ['/home/user/my_project']
testFile: null
mkdirs: ['/home/user/my_project/test']
mockPaths: ['/home/user/my_project/test']

expect(sourceInfo.projectType()).toBe("test")

it "correctly detecs a spec directory", ->
withSetup
projectPaths: ['/home/user/my_project']
testFile: null
mkdirs: ['/home/user/my_project/spec']
mockPaths: ['/home/user/my_project/spec']

expect(sourceInfo.projectType()).toBe("rspec")

it "correctly detects a cucumber directory", ->
withSetup
projectPaths: ['/home/user/my_project']
testFile: null
mkdirs: ['/home/user/my_project/features']
mockPaths: ['/home/user/my_project/features']

expect(sourceInfo.projectType()).toBe("cucumber")

Expand All @@ -196,7 +199,7 @@ describe "SourceInfo", ->
config: "ruby-test.testAllCommand": "my_ruby -I test test"
projectPaths: ['/home/user/my_project']
testFile: null
mkdirs: ['/home/user/my_project/test']
mockPaths: ['/home/user/my_project/test']

expect(sourceInfo.testAllCommand()).toBe("my_ruby -I test test")

Expand All @@ -206,7 +209,7 @@ describe "SourceInfo", ->
config: "ruby-test.rspecAllCommand": "my_rspec spec"
projectPaths: ['/home/user/my_project']
testFile: null
mkdirs: ['/home/user/my_project/spec']
mockPaths: ['/home/user/my_project/spec']

expect(sourceInfo.testAllCommand()).toBe("my_rspec spec")

Expand Down

0 comments on commit 0ab0431

Please sign in to comment.