Sha256: 7af495a491f20bb59a15564491f48e4dcdf408c2418f178d7dbbe0d2f869c855

Contents?: true

Size: 1.25 KB

Versions: 20

Compression:

Stored size: 1.25 KB

Contents

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

describe Thor::Shell::Color do
  def shell
    @shell ||= Thor::Shell::Color.new
  end

  describe "#say" do
    it "set the color if specified" do
      $stdout.should_receive(:puts).with("\e[32mWow! Now we have colors!\e[0m")
      shell.say "Wow! Now we have colors!", :green
    end

    it "does not use a new line even with colors" do
      $stdout.should_receive(:print).with("\e[32mWow! Now we have colors! \e[0m")
      shell.say "Wow! Now we have colors! ", :green
    end
  end

  describe "#say_status" do
    it "uses color to say status" do
      $stdout.should_receive(:puts).with("\e[1m\e[31m    conflict\e[0m  README")
      shell.say_status :conflict, "README", :red
    end
  end

  describe "#file_collision" do
    describe "when a block is given" do
      it "invokes the diff command" do
        $stdout.stub!(:print)
        $stdin.should_receive(:gets).and_return('d')
        $stdin.should_receive(:gets).and_return('n')

        output = capture(:stdout){ shell.file_collision('spec/fixtures/doc/README'){ "README\nEND\n" } }
        output.must =~ /\e\[31m\- __start__\e\[0m/
        output.must =~ /^  README/
        output.must =~ /\e\[32m\+ END\e\[0m/
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
puppet-module-0.3.4 vendor/thor-852190ae/spec/shell/color_spec.rb
puppet-module-0.3.3 vendor/thor-852190ae/spec/shell/color_spec.rb
puppet-module-0.3.2 vendor/thor-852190ae/spec/shell/color_spec.rb
thor-0.14.4 spec/shell/color_spec.rb
thor-0.14.3 spec/shell/color_spec.rb
thor-0.14.2 spec/shell/color_spec.rb
thor-0.14.1 spec/shell/color_spec.rb
angry_mob-0.1.0 vendor/thor/spec/shell/color_spec.rb
thor-0.14.0 spec/shell/color_spec.rb
thor-0.13.8 spec/shell/color_spec.rb
thor-0.13.7 spec/shell/color_spec.rb
puppet-module-0.3.0 vendor/thor-852190ae/spec/shell/color_spec.rb
thor-0.13.6 spec/shell/color_spec.rb
thor-0.13.5 spec/shell/color_spec.rb
thor-0.13.4 spec/shell/color_spec.rb
thor-0.13.3 spec/shell/color_spec.rb
thor-0.13.2 spec/shell/color_spec.rb
thor-0.13.1 spec/shell/color_spec.rb
thor-0.13.0 spec/shell/color_spec.rb
thor-0.12.3 spec/shell/color_spec.rb