Skip to content

Commit

Permalink
Save before run.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Bergstein and Erik Hanson committed Aug 8, 2014
1 parent 8c0e8be commit 5fb2d60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ruby-test-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ class RubyTestView extends View

testPrevious: ->
return unless @runner
atom.workspace.getActiveEditor().save()
@newTestView()
@runner.run()

runTest: (overrideParams) ->
atom.workspace.getActiveEditor().save()
@newTestView()
params = _.extend({}, @testRunnerParams(), overrideParams || {})
@runner = new TestRunner(params)
Expand Down
10 changes: 10 additions & 0 deletions spec/ruby-test-view-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ TestRunner = require '../lib/test-runner'
describe "RubyTestView", ->
beforeEach ->
atom.workspaceView = new WorkspaceView()
atom.workspaceView.openSync('/tmp/text.txt')

describe "::testFile", ->
it "instantiates TestRunner, and calls ::run on it", ->
activeEditor = atom.workspace.getActiveEditor()
spyOn(activeEditor, 'save')
spyOn(TestRunner.prototype, 'initialize').andCallThrough()
spyOn(TestRunner.prototype, 'run').andCallThrough()
spyOn(TestRunner.prototype, 'command').andReturn 'fooTestCommand'
Expand All @@ -20,9 +23,12 @@ describe "RubyTestView", ->
expect(TestRunner.prototype.run).toHaveBeenCalled()
expect(@view.setTestInfo).toHaveBeenCalled()
expect(@view.hasParent()).toBe(true)
expect(activeEditor.save).toHaveBeenCalled()

describe "::testSingle", ->
it "intantiates TestRunner and calls ::run on it with specific arguments", ->
activeEditor = atom.workspace.getActiveEditor()
spyOn(activeEditor, 'save')
spyOn(TestRunner.prototype, 'initialize').andCallThrough()
spyOn(TestRunner.prototype, 'run').andCallThrough()
spyOn(TestRunner.prototype, 'command').andReturn 'fooTestCommand'
Expand All @@ -32,9 +38,12 @@ describe "RubyTestView", ->
expect(TestRunner.prototype.initialize).toHaveBeenCalledWith(params)
expect(TestRunner.prototype.run).toHaveBeenCalled()
expect(@view.hasParent()).toBe(true)
expect(activeEditor.save).toHaveBeenCalled()

describe "::testPrevious", ->
it "intantiates TestRunner and calls ::run on it with specific arguments", ->
activeEditor = atom.workspace.getActiveEditor()
spyOn(activeEditor, 'save')
@view = new RubyTestView()
previousRunner = new TestRunner(@view.testRunnerParams())
previousRunner.command = -> "foo"
Expand All @@ -43,6 +52,7 @@ describe "RubyTestView", ->
expect(@view.output).toBe("")
expect(@view.hasParent()).toBe(true)
expect(@view.runner).toBe(previousRunner)
expect(activeEditor.save).toHaveBeenCalled()

describe "::write", ->
it "appends content to results element", ->
Expand Down

0 comments on commit 5fb2d60

Please sign in to comment.