Sha256: 5f2835f522069d6369a522f8813ec65a85de3885504fa45041cc184216ebeded

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe LogView::OptParser do
  let :project_name do
    "project_name1"
  end

  before do
    LogView::Config.stub(:config_file_path).and_return("spec/fixtures/config.yml")
    config.load_project project_name
  end
  
  let :config do
    LogView::Config.new
  end

  let :args do
      [project_name, '--grep', 'string', '--split-log', '-s', 'test-server1', '-f', 'test-file1']
  end
  subject do
    LogView::OptParser.new.parse(args, config.load_project(project_name))
  end

  describe "#parse" do
    
    it "grep test" do
      subject.grep_string.should eql " | grep --color=always string"
    end

    it "split-log test" do
      subject.options.split_log.should eql true
    end

    describe 'choosing existent' do
      it "file test" do
        subject.options.if_files.should eql true
        subject.options.files.should eql 'test-file1'
      end

      it "servers test" do
        subject.options.if_server.should eql true
        subject.options.server.should eql 'test-server1'
      end
    end

    describe 'choosing inexistent' do
      let :args do
        [project_name, '--grep', 'string', '--split-log', '-s', 'test-server10', '-f', 'test-file10'] 
      end   

      it 'file test' do
        subject.options.if_files.should eql true
        subject.options.files.should eql 'test-file10'
      end

      it 'server test' do
        subject.options.if_server.should eql true
        subject.options.server.should eql 'test-server10'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
log_view-0.1.0 spec/option_parser_spec.rb
log_view-0.0.1 spec/option_parser_spec.rb