Sha256: c492c88dc301a2470f9742bd211503a1456f538cfb4103f54d4f5d07e787efd5

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require 'taskwarrior-web/services/runner'

describe TaskwarriorWeb::Runner do
  before do
    TestCommandClass.class_eval do |class_name|
      include TaskwarriorWeb::Runner
    end
    @object = TestCommandClass.new
  end

  describe 'include' do
    it 'should make the class respond to the run command' do
      @object.should respond_to(:run)
    end

    it 'should add a TASK_VERSION constant' do
      @object.class.const_get(:TASK_BIN).should eq('task')
    end
  end

  describe '#run' do
    before do
      @object.should_receive(:`).and_return('{"new_thing" => "old_thing"}')
    end

    context 'when the command has not been built' do
      it 'should build the command' do
        @object.should_receive(:build).and_return('build command')
        @object.run
      end
    end

    context 'when the command has been built' do
      it 'should not build the command' do
        @object.instance_variable_set(:@built, 'command set manually')
        @object.should_not_receive(:build)
        @object.run
      end
    end

    it 'should return the stdout' do
      @object.should_receive(:build).and_return('build command')
      @object.run.should eq('{"new_thing" => "old_thing"}')
    end
  end

end

class TestCommandClass; end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
taskwarrior-web-1.0.14 spec/services/runner_spec.rb
taskwarrior-web-1.0.13 spec/services/runner_spec.rb
taskwarrior-web-1.0.12 spec/services/runner_spec.rb
taskwarrior-web-1.0.11 spec/services/runner_spec.rb
taskwarrior-web-1.0.10 spec/services/runner_spec.rb
taskwarrior-web-1.0.9 spec/services/runner_spec.rb