Skip to content

Commit

Permalink
Fixed tests for config _enabled options
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Morris committed Feb 16, 2016
1 parent e867613 commit 40b68fe
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions spec/lib/logstasher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,15 @@
expect(LogStasher::ActionView::LogSubscriber).to receive(:attach_to).with(:action_view)
expect(LogStasher).to receive(:require).with('logstash-event')
end

end
shared_examples 'setup' do
let(:logstasher_source) { nil }
let(:logstasher_config) { double(:enabled => true,
let(:logstasher_config) { double(:enabled => true,
:logger => logger, :log_level => 'warn', :log_controller_parameters => nil,
:source => logstasher_source, :logger_path => logger_path, :backtrace => true,
:controller_monkey_patch => true) }
:controller_monkey_patch => true, :controller_enabled => true,
:mailer_enabled => true, :record_enabled => false, :view_enabled => true) }
let(:config) { double(:logstasher => logstasher_config) }
let(:app) { double(:config => config) }
before do
Expand Down Expand Up @@ -301,7 +302,7 @@
end
end
end

describe ".enabled?" do
it "returns false if not enabled" do
expect(LogStasher).to receive(:enabled).and_return(false)
Expand All @@ -311,12 +312,12 @@
expect(LogStasher.enabled?).to be true
end
end

describe ".called_as_rake?" do
it "returns false if not called as rake" do
expect(LogStasher.called_as_rake?).to be false
end

it "returns true if called as rake" do
expect(File).to receive(:basename).with($0).and_return('rake')
expect(LogStasher.called_as_rake?).to be true
Expand All @@ -327,7 +328,7 @@
it "does not touch request_context if not called as rake" do
expect(LogStasher.request_context).to be_empty
end

it "sets request_context accordingly if called as rake" do
expect(LogStasher).to receive(:called_as_rake?).and_return(true)
expect(Rake.application).to receive(:top_level_tasks).and_return(['mytask'])
Expand All @@ -341,7 +342,7 @@
it "returns false if not called as console" do
expect(LogStasher.called_as_console?).to be false
end

it "returns true if called as rake" do
require 'rails/commands/console'
expect(LogStasher.called_as_console?).to be true
Expand All @@ -352,7 +353,7 @@
it "does not touch request_context if not called as console" do
expect(LogStasher.request_context).to be_empty
end

it "sets request_context accordingly if called as console" do
require 'rails/commands/console'
expect(LogStasher).to receive(:called_as_console?).and_return(true)
Expand Down

0 comments on commit 40b68fe

Please sign in to comment.