Sha256: b143e64720800ae9886425321229e389da68021a73a9410ae80ae9dc5b325872

Contents?: true

Size: 1.26 KB

Versions: 9

Compression:

Stored size: 1.26 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require 'taskwarrior-web/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

9 entries across 9 versions & 1 rubygems

Version Path
taskwarrior-web-1.0.8 spec/models/runner_spec.rb
taskwarrior-web-1.0.7 spec/models/runner_spec.rb
taskwarrior-web-1.0.6 spec/models/runner_spec.rb
taskwarrior-web-1.0.5 spec/models/runner_spec.rb
taskwarrior-web-1.0.4 spec/models/runner_spec.rb
taskwarrior-web-1.0.3 spec/models/runner_spec.rb
taskwarrior-web-1.0.2 spec/models/runner_spec.rb
taskwarrior-web-1.0.1 spec/models/runner_spec.rb
taskwarrior-web-1.0.0 spec/models/runner_spec.rb