Sha256: 34bcbb54129247ac1d82e9fd727adb8c364e53b9c5deff6bcd5f3433d6306b27

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

require 'observed/application/oneshot'

describe Observed::Application::Oneshot do
  let(:bar) {
    Class.new(Observed::Observer) do
      def observe
        sleep rand
        'Bar'
      end

      plugin_name 'oneshot_spec_bar'
    end
  }
  before {
    bar
  }
  #context 'with Hash objects' do
  #  subject {
  #    Observed::Application::Oneshot.create(:config => config)
  #  }
  #  let(:config) {
  #    {
  #        'observers' => {
  #          'test' => {
  #              plugin: 'oneshot_spec_bar',
  #              method: 'get',
  #              url: 'http://localhost:3000'
  #          }
  #        },
  #        'reporters' => {
  #          'test.*' => {
  #              plugin: 'stdout'
  #          }
  #        }
  #    }
  #  }
  #  it 'initializes' do
  #    expect(subject.run.size).not_to eq(0)
  #  end
  #end
  context 'with configuration files' do
    context 'with the correct plugins directory' do
      subject {
        Observed::Application::Oneshot.create(
            config_file: 'spec/fixtures/configure_by_conf/observed.conf'
        )
      }
      it 'initializes' do
        expect(subject.run.size).not_to eq(0)
      end
    end
  end
  describe '#parse_argv!' do
    it 'parses ARGV like arrays and extracts Hash objects containing initialization parameters' do
      argv = %w| -l logfile -d observed.rb foo1 |
      params = Observed::Application::Oneshot.parse_argv! argv
      expect(params).to eq({log_file: Pathname.new('logfile'), debug: true, config_file: 'observed.rb'})
      expect(argv).to eq(%w| foo1 |)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
observed-0.2.0 spec/oneshot_spec.rb
observed-0.2.0.rc2 spec/oneshot_spec.rb
observed-0.2.0.rc1 spec/oneshot_spec.rb