Sha256: 8fa47dc05ebdbbfa22c4ae77139dddc5d02b1d2ad06906e45d45a89aa43650be

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

require 'spec/spec_helper'

describe Deputy do
  it "has a VERSION" do
    Deputy::VERSION.should =~ /^\d+\.\d+\.\d+$/
  end

  def klass(name, options={})
    "class TEMP_#{options[:rand]||rand(11111)};def self.interval;60;end;class #{name} < Scout::Plugin; def build_report; #{options[:code]}; end; end; end"
  end

  describe Scout do
    it "finds plugins" do
      Scout.plugins(klass('A', :rand => 1111)).inspect.should == '[[60, TEMP_1111::A]]'
    end

    it "does not show non-plugins" do
      Scout.plugins(klass('B').sub('build_report','foo')).inspect.should == '[]'
    end
  end

  describe :run_plugins do
    it "executes all plugins" do
      $notify = 0
      Deputy.stub!(:sheriff_url).and_return 'http://sheri.ff'
      FakeWeb.register_uri(:get, "http://sheri.ff/plugins.rb", :body => klass('C', :code => '$notify=1'))
      Deputy.run_plugins
      $notify.should == 1
    end
  end

  describe :send_report do
    it "sends a report" do
      Deputy.stub!(:sheriff_url).and_return 'http://sheri.ff'
      FakeWeb.register_uri(:get, "http://sheri.ff/report/Xxx.yyy/123", :body => 'OK')
      Deputy.send_report('Xxx.yyy', '123').should == 'OK'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
deputy-0.1.6 spec/deputy_spec.rb
deputy-0.1.5 spec/deputy_spec.rb
deputy-0.1.4 spec/deputy_spec.rb