Sha256: 5414fac05680004aa061c062e8c0b2417b77bdd3fcf3698854c25ad996a1d770

Contents?: true

Size: 1.67 KB

Versions: 25

Compression:

Stored size: 1.67 KB

Contents

require File.join(File.dirname(__FILE__), "..", "spec_helper")

describe Redcar::Command do
  describe "a command" do
    before do
      $spec_command_env = nil
    end
    
    class MyCommand < Redcar::Command
      
      def execute
        $spec_command_env = {:win => win}
      end
    end

    it "is recordable by default" do
      MyCommand.record?.should be_true
    end
    
    it "has an environment" do
      command_instance = MyCommand.new
      command_instance.environment(:win => 123)
      command_instance.execute
      $spec_command_env.should == {:win => 123}
    end
  end
  
  describe "a non-recordable command" do
    class MyNonRecordableCommand < Redcar::Command
      norecord
    end
    
    it "is not recordable" do
      MyNonRecordableCommand.record?.should be_false
    end
  end
  
  describe "commands inherit sensitivities" do
    class SensitiveCommand < Redcar::Command
      sensitize :foo
    end
    
    class SubSensitiveCommand < SensitiveCommand
      sensitize :bar
    end
    
    it "has it's own and it's parent's sensitivities" do
      SubSensitiveCommand.sensitivity_names.should == [:foo, :bar]
    end
  end
  
  describe "a command that implements _finished" do
    class FinishableCommand < Redcar::Command
      attr_reader :stuff
      
      def initialize
        @stuff = []
      end
      
      def execute
        @stuff << :executed
      end
      
      def _finished
        @stuff << :finished
      end
    end
    
    it "should have _finished called after the command runs" do
      command_instance = FinishableCommand.new
      command_instance.run
      command_instance.stuff.should == [:executed, :finished]
    end
  end
end



Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
redcar-dev-0.12.17dev plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.16dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.15dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.14dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.13dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.12dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.11dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.10dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.9dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.8dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.7dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.6dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.4dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.3dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.1dev-java plugins/application/spec/application/command_spec.rb
redcar-dev-0.12.0dev-java plugins/application/spec/application/command_spec.rb
redcar-0.11 plugins/application/spec/application/command_spec.rb
redcar-0.11.0dev plugins/application/spec/application/command_spec.rb
redcar-0.10 plugins/application/spec/application/command_spec.rb
redcar-0.9.2 plugins/application/spec/application/command_spec.rb