-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathsmoke_spec.rb
55 lines (52 loc) · 1.56 KB
/
smoke_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'spec_helper'
require 'logger'
# https://www.relishapp.com/rspec/rspec-core/v/2-12/docs/subject/explicit-subject
describe Array, "with some elements" do
subject { [1,2,3] }
it "should have the prescribed elements" do
expect(subject).to eq [1,2,3]
end
end
describe Enumerable, "when using #find" do
subject do
[OpenStruct.new(:a => "1 apple")]
end
it "should handle find properly one arg" do
expect(subject.find { |f| f.a == "1 apple" }.a).to eq "1 apple"
end
it "should handle find properly, two args" do
s = subject.clone
s << OpenStruct.new(:a => "2 banana")
expect(s.find { |f| f.a == "2 banana" }.a).to eq "2 banana"
expect(s.find { |f| f.a == "1 banana" }).to be_nil
expect(s.find { |f| f.a == "1 apple" }.a).to eq "1 apple"
end
end
describe 'logging methods' do
class A
include ::Albacore::Logging
def normal str ; trace str ; end
def blocky str ; trace { str } ; end
end
before do
@logout = StringIO.new
@app = ::Albacore::Application.new @logout, StringIO.new, StringIO.new
@app.logger.level = Logger::DEBUG
::Albacore.set_application @app
end
subject do
A.new
end
describe 'logging normally' do
before do
subject.normal 'my-trace-line'
subject.blocky 'trace-is-enabled with ::DEBUG'
end
it 'should contain non-block line' do
expect(@logout.string).to include('my-trace-line')
end
it 'should contain block line' do
expect(@logout.string).to include('trace-is-enabled')
end
end
end