Sha256: cc724fa6af4166a97e2f83ba446a18256b124a4df6363c896a9ea4dc4c659dc0

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

module Maid
  describe App, '#clean' do
    before :each do
      @app = App.new
      @app.stub!(:maid_options)
      @app.stub!(:say)

      @maid = mock('Maid')
      @maid.stub!(:clean)
      @maid.stub!(:log_path)
      Maid.stub!(:new).and_return(@maid)
    end

    it 'should make a new Maid with the options' do
      opts = {:foo => 'bar'}
      @app.stub!(:maid_options).and_return(opts)
      Maid.should_receive(:new).with(opts).and_return(@maid)
      @app.clean
    end

    it 'should tell the Maid to clean' do
      @maid.should_receive(:clean)
      @app.clean
    end
  end

  describe App, '#version' do
    it 'should print out the gem version' do
      app = App.new
      app.should_receive(:say).with(VERSION)
      app.version
    end
  end

  describe App, '#maid_options' do
    before :each do
      @app = App.new
    end

    it 'should log to STDOUT for testing purposes when given noop' do
      opts = @app.maid_options('noop' => true)
      opts[:file_options][:noop].should be_true
      opts[:log_path].should == STDOUT
      opts[:log_formatter].call(nil, nil, nil, 'hello').should == "hello\n"
    end

    it 'should set the rules path when given rules' do
      opts = @app.maid_options('rules' => 'maid_rules.rb')
      opts[:rules_path].should match(/maid_rules.rb$/)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
maid-0.1.0.beta2 spec/lib/maid/app_spec.rb
maid-0.1.0.beta1 spec/lib/maid/app_spec.rb