Sha256: a359d1a8416e027638e95334842d4a8855d65503ac288a7f3f8b69b337e26b5c

Contents?: true

Size: 1.56 KB

Versions: 31

Compression:

Stored size: 1.56 KB

Contents

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

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
albacore-2.5.10 spec/smoke_spec.rb
albacore-2.5.9 spec/smoke_spec.rb
albacore-2.5.8 spec/smoke_spec.rb
albacore-2.5.6 spec/smoke_spec.rb
albacore-2.5.5 spec/smoke_spec.rb
albacore-2.5.4 spec/smoke_spec.rb
albacore-2.5.3 spec/smoke_spec.rb
albacore-2.5.2 spec/smoke_spec.rb
albacore-2.5.1 spec/smoke_spec.rb
albacore-2.5.0 spec/smoke_spec.rb
albacore-2.4.3 spec/smoke_spec.rb