Skip to content

Commit

Permalink
CHORE: Updates specs a little for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
rudionrails committed Jun 20, 2013
1 parent 20c9aba commit 4f382c9
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 43 deletions.
2 changes: 1 addition & 1 deletion spec/yell/adapters/base_spec.rb
Expand Up @@ -20,7 +20,7 @@
end
end

context ":write" do
context "#write" do
let(:logger) { Yell::Logger.new }
subject { Yell::Adapters::Base.new(:level => 1) }

Expand Down
8 changes: 4 additions & 4 deletions spec/yell/adapters/datefile_spec.rb
Expand Up @@ -20,7 +20,7 @@

it { should be_kind_of Yell::Adapters::File }

describe ":write" do
describe "#write" do
let(:today_lines) { File.readlines(today_filename) }

before do
Expand Down Expand Up @@ -63,7 +63,7 @@
end
end

describe ":keep" do
describe "#keep" do
before do
adapter.symlink = false # to not taint the Dir
adapter.keep = 2
Expand All @@ -82,7 +82,7 @@
end
end

describe ":symlink" do
describe "#symlink" do
context "when true (default)" do
before do
adapter.write(event)
Expand Down Expand Up @@ -114,7 +114,7 @@
end
end

describe ":header" do
describe "#header" do
let(:header) { File.open(today_filename, &:readline) }

context "when true (default)" do
Expand Down
6 changes: 3 additions & 3 deletions spec/yell/adapters/file_spec.rb
Expand Up @@ -9,13 +9,13 @@

it { should be_kind_of(Yell::Adapters::Io) }

context ":stream" do
context "#stream" do
subject { Yell::Adapters::File.new.send(:stream) }

it { should be_kind_of(File) }
end

context ":write" do
context "#write" do
let(:logger) { Yell::Logger.new }
let(:event) { Yell::Event.new(logger, 1, "Hello World") }

Expand Down Expand Up @@ -52,7 +52,7 @@
end
end

context ":sync" do
context "#sync" do
let(:adapter) { Yell::Adapters::File.new }

it "should sync by default" do
Expand Down
2 changes: 1 addition & 1 deletion spec/yell/adapters/io_spec.rb
Expand Up @@ -44,7 +44,7 @@
end
end

context ":write" do
context "#write" do
let(:logger) { Yell::Logger.new }
let(:event) { Yell::Event.new(logger, 1, "Hello World") }
let(:adapter) { Yell::Adapters::Io.new }
Expand Down
4 changes: 2 additions & 2 deletions spec/yell/adapters/streams_spec.rb
Expand Up @@ -4,7 +4,7 @@

it { should be_kind_of(Yell::Adapters::Io) }

context ":stream" do
context "#stream" do
subject { Yell::Adapters::Stdout.new.send :stream }

it { should be_kind_of(IO) }
Expand All @@ -16,7 +16,7 @@

it { should be_kind_of(Yell::Adapters::Io) }

context ":stream" do
context "#stream" do
subject { Yell::Adapters::Stderr.new.send(:stream) }

it { should be_kind_of(IO) }
Expand Down
4 changes: 2 additions & 2 deletions spec/yell/adapters_spec.rb
Expand Up @@ -2,7 +2,7 @@

describe Yell::Adapters do

context ":new" do
context ".new" do
it "should accept an adapter instance" do
stdout = Yell::Adapters::Stdout.new
adapter = Yell::Adapters.new(stdout)
Expand All @@ -29,7 +29,7 @@
end
end

context ":register" do
context ".register" do
let(:name) { :test }
let(:klass) { mock }

Expand Down
2 changes: 1 addition & 1 deletion spec/yell/configuration_spec.rb
Expand Up @@ -2,7 +2,7 @@

describe Yell::Configuration do

describe ":load!" do
describe ".load!" do
let(:file) { fixture_path + '/yell.yml' }
let(:config) { Yell::Configuration.load!(file) }

Expand Down
14 changes: 7 additions & 7 deletions spec/yell/event_spec.rb
Expand Up @@ -20,17 +20,17 @@ def self._event(logger, level, message)
let(:logger) { Yell::Logger.new(:trace => true) }
let(:event) { Yell::Event.new(logger, 1, 'Hello World!') }

context ":level" do
context "#level" do
subject { event.level }
it { should eq(1) }
end

context ":messages" do
context "#messages" do
subject { event.messages }
it { should eq(['Hello World!']) }
end

context ":time" do
context "#time" do
let(:time) { Time.now }
subject { event.time.to_s }

Expand All @@ -39,17 +39,17 @@ def self._event(logger, level, message)
it { should eq(time.to_s) }
end

context ":hostname" do
context "#hostname" do
subject { event.hostname }
it { should eq(Socket.gethostname) }
end

context ":pid" do
context "#pid" do
subject { event.pid }
it { should eq(Process.pid) }
end

context "pid when forked", :pending => RUBY_PLATFORM == 'java' ? "No forking with jruby" : false do
context "#id when forked", :pending => RUBY_PLATFORM == 'java' ? "No forking with jruby" : false do
subject { @pid }

before do
Expand All @@ -70,7 +70,7 @@ def self._event(logger, level, message)
it { should eq(@child_pid) }
end

context ":progname" do
context "#progname" do
subject { event.progname }
it { should eq($0) }
end
Expand Down
1 change: 1 addition & 0 deletions spec/yell/level_spec.rb
Expand Up @@ -195,5 +195,6 @@
expect(severities[level]).to eq("WARNING")
end
end

end

20 changes: 10 additions & 10 deletions spec/yell/logger_spec.rb
Expand Up @@ -41,29 +41,29 @@ def bar
it { should respond_to(:unknown?) }
end

context "default adapters" do
context "default #adapters" do
subject { logger.adapters }

its(:size) { should eq(1) }
its(:first) { should be_kind_of(Yell::Adapters::File) }
end

context "default :level" do
context "default #level" do
subject { logger.level }

it { should be_instance_of(Yell::Level) }
its(:severities) { should eq([true, true, true, true, true, true]) }
end

context "default :trace" do
context "default #trace" do
subject { logger.trace }

it { should be_instance_of(Yell::Level) }
its(:severities) { should eq([false, false, false, true, true, true]) } # from error onwards
end
end

describe "initialize with :name" do
describe "initialize with #name" do
let(:name) { 'test' }
let!(:logger) { Yell.new(:name => name) }

Expand All @@ -72,7 +72,7 @@ def bar
end
end

context "initialize with :level" do
context "initialize with #level" do
let(:level) { :error }
let(:logger) { Yell.new(:level => level) }
subject { logger.level }
Expand All @@ -81,7 +81,7 @@ def bar
its(:severities) { should eq([false, false, false, true, true, true]) }
end

context "initialize with :trace" do
context "initialize with #trace" do
let(:trace) { :info }
let(:logger) { Yell.new(:trace => trace) }
subject { logger.trace }
Expand All @@ -90,7 +90,7 @@ def bar
its(:severities) { should eq([false, true, true, true, true, true]) }
end

context "initialize with :silence" do
context "initialize with #silence" do
let(:silence) { "test" }
let(:logger) { Yell.new(:silence => silence) }
subject { logger.silencer }
Expand All @@ -99,15 +99,15 @@ def bar
its(:patterns) { should eq([silence]) }
end

context "initialize with a :filename" do
context "initialize with a #filename" do
it "should call adapter with :file" do
mock.proxy(Yell::Adapters::File).new(:filename => filename)

Yell::Logger.new(filename)
end
end

context "initialize with a :filename of Pathname type" do
context "initialize with a #filename of Pathname type" do
let(:pathname) { Pathname.new(filename) }

it "should call adapter with :file" do
Expand Down Expand Up @@ -167,7 +167,7 @@ def bar
end
end

context "initialize with :adapters option" do
context "initialize with #adapters option" do
let(:logger) do
Yell::Logger.new(:adapters => [:stdout, {:stderr => {:level => :error}}])
end
Expand Down
4 changes: 2 additions & 2 deletions spec/yell/repository_spec.rb
Expand Up @@ -40,14 +40,14 @@
it { should eq(logger) }
end

context "[]= with a named logger" do
context ".[]= with a named logger" do
let!(:logger) { Yell.new(:stdout, :name => name) }
before { Yell::Repository[name] = logger }

it { should eq(logger) }
end

context "[]= with a named logger of a different name" do
context ".[]= with a named logger of a different name" do
let(:other) { 'other' }
let(:logger) { Yell.new(:stdout, :name => other) }
before { Yell::Repository[name] = logger }
Expand Down
9 changes: 5 additions & 4 deletions spec/yell/silencer_spec.rb
Expand Up @@ -2,13 +2,13 @@

describe Yell::Silencer do

context "initialize with :patterns" do
context "initialize with #patterns" do
subject { Yell::Silencer.new(/this/) }

its(:patterns) { should eq([/this/]) }
end

context "add" do
context "#add" do
let(:silencer) { Yell::Silencer.new }

it "should add patterns" do
Expand All @@ -24,7 +24,7 @@
end
end

context "silence?" do
context "#silence?" do
let(:silencer) { Yell::Silencer.new }

it "should be false when no patterns present" do
Expand All @@ -38,11 +38,12 @@
end
end

context "silence" do
context "#silence" do
let(:silencer) { Yell::Silencer.new(/this/) }

it "should reject messages that match any pattern" do
expect(silencer.silence("this", "that")).to eq(["that"])
end
end

end
12 changes: 6 additions & 6 deletions spec/yell_spec.rb
Expand Up @@ -13,17 +13,17 @@
}.to raise_error(Yell::AdapterNotFound)
end

context ":level" do
context ".level" do
subject { Yell.level }
it { should be_kind_of Yell::Level }
end

context ":format" do
context ".format" do
subject { Yell.format( "%m" ) }
it { should be_kind_of Yell::Formatter }
end

context ":load!" do
context ".load!" do
subject { Yell.load!( 'yell.yml' ) }

before do
Expand All @@ -33,7 +33,7 @@
it { should be_kind_of Yell::Logger }
end

context ":[]" do
context ".[]" do
let(:name) { 'test' }

it "should delegate to the repository" do
Expand All @@ -43,7 +43,7 @@
end
end

context ":[]=" do
context ".[]=" do
let(:name) { 'test' }

it "should delegate to the repository" do
Expand All @@ -53,7 +53,7 @@
end
end

context ":env" do
context ".env" do
subject { Yell.env }

it "should default to YELL_ENV" do
Expand Down

0 comments on commit 4f382c9

Please sign in to comment.