Sha256: 838a1c3d0f4afb3e428cbae929717f9aacc992840a69f6c347232987d1bd72df

Contents?: true

Size: 1.23 KB

Versions: 13

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe Fluentd::AgentsController do
  let(:log) { double('log').as_null_object }

  before do
    allow(controller).to receive(:current_user).and_return true
    allow(controller).to receive(:find_fluentd).and_return(nil)
    controller.instance_variable_set(:@fluentd, double(agent: @agent = double(:agent)))
  end

  describe "when the action succeeds" do
    it "stops" do
      expect(@agent).to receive(:stop).and_return true
      put :stop
    end

    it "starts" do
      expect(@agent).to receive(:start).and_return true
      put :start
    end

    it "restarts" do
      expect(@agent).to receive(:restart).and_return true
      put :restart
    end
  end

  describe "when the action does not succeed" do
    it "stops" do
      expect(@agent).to receive(:stop).and_return false
      put :stop
    end

    it "starts" do
      expect(@agent).to receive(:start).and_return false
      expect(@agent).to receive(:log).and_return(log)
      expect(log).to receive(:tail).with(1)
      put :start
    end

    it "restarts" do
      expect(@agent).to receive(:restart).and_return false
      expect(@agent).to receive(:log).and_return(log)
      expect(log).to receive(:tail).with(1)
      put :restart
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fluentd-ui-0.4.5 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.4.4 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.4.3 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.4.2 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.4.1 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.4.0 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.3.21 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.3.20 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.3.19 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.3.18 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.3.17 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.3.16 spec/controllers/fluentd/agents_controller_spec.rb
fluentd-ui-0.3.15 spec/controllers/fluentd/agents_controller_spec.rb