Sha256: 13916b7ef604080fd4d5a36c19d2821926b00bc1fbe2913c0137856265a6af48

Contents?: true

Size: 1.55 KB

Versions: 10

Compression:

Stored size: 1.55 KB

Contents

class TestShell < Test::Unit::TestCase
  
  context "A shell instance, @shell" do
    setup do
      @shell = ChronoTrigger::Shell.new
    end
    
    should "return an empty array on call to triggers" do
      assert_equal [], @shell.triggers
    end

    should "raise an exception unless a block is provided to #trigger" do
      assert_raise(ChronoTrigger::ConfigurationException) { @shell.trigger("test trigger") }
    end

    context "when provided a valid block" do
      setup do
        @trigger = @shell.trigger("name") { runs { "x" } }
      end
      
      should "create a new trigger" do
        assert_equal 1, @shell.triggers.size
      end
      
      should "create a trigger that will run x with execute" do
        assert_equal "x", @shell.triggers.first.execute
      end
      
      context "and configured to run the next time shell.execute_triggers is called" do
        setup do
          ChronoTrigger::CronEntry.any_instance.stubs(:matches?).returns(true)
        end
        
        should "execute the code block" do
          @trigger.expects(:execute)
          @shell.execute_triggers
        end
      end #and configured to run the next time shell.execute_triggers is called
    end #when provided a valid block
    
    context "calling load_context with a valid trigger file" do
      setup do
        @shell.load_triggers("test/triggers.rb")
      end
      
      should "create 2 triggers" do
        assert_equal 2, @shell.triggers.size
      end
    end #calling load_context with a valid trigger file
  end #A shell instance, @shell
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gregfitz23-chrono_trigger-0.0.2 test/test_shell.rb
gregfitz23-chrono_trigger-0.0.3 test/test_shell.rb
gregfitz23-chrono_trigger-0.0.4 test/test_shell.rb
gregfitz23-chrono_trigger-0.0.5 test/test_shell.rb
gregfitz23-chrono_trigger-0.1.0 test/test_shell.rb
gregfitz23-chrono_trigger-0.1.1 test/test_shell.rb
gregfitz23-chrono_trigger-0.1.2 test/test_shell.rb
gregfitz23-chrono_trigger-0.1.3 test/test_shell.rb
gregfitz23-chrono_trigger-0.1.4 test/test_shell.rb
gregfitz23-chrono_trigger-0.1.5 test/test_shell.rb