Sha256: 6e14950c396a65b0709df1a47963d355bc41c5d458655f4bfaa9f3b122e94575

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'grog/options'

describe Grog::Options do
  describe "number of commits to show" do
    it "should be set by the -n argument" do
      options = Grog::Options.parse(%w{-n 34})
      options.number_of_commits_to_show.should == 34
    end

    it "should be 10 by default" do
      Grog::Options.new([]).number_of_commits_to_show.should == 10
    end
  end

  describe "show datetimes" do
    it "should be set if the -d flag is passed" do
      options = Grog::Options.parse(%w{-d})
      options.show_datetimes.should be_true
    end

    it "should be false by default" do
      Grog::Options.new([]).show_datetimes.should be_false
    end
  end

  describe "help" do
    it "should print help info if the --help flag is passed" do
      pending "how to ignore exception thrown by exit?"
      options = Grog::Options.new([])
      $stdout.should_receive(:write).with(options.instance_variable_get('@opts').to_s)
      Grog::Options.new(%w{--help})
    end

    it "should print help info if the -h flag is passed" do
      pending "how to ignore exception thrown by exit?"
      options = Grog::Options.new([])
      $stdout.should_receive(:write).with(options.instance_variable_get('@opts').to_s)
      Grog::Options.new(%w{-h})
    end

    it "should exit" do
      $stdout.stub!(:write)
      lambda { Grog::Options.new(%w{--help}) }.should raise_error(SystemExit)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grog-0.0.2 spec/grog/options_spec.rb
grog-0.0.1 spec/grog/options_spec.rb
grog-0.0.0 spec/grog/options_spec.rb