Sha256: 8dc17e36c7da7f820b2c49d5e913f037303fa8f6a7b2c1317550861b158b3896

Contents?: true

Size: 1.72 KB

Versions: 3

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'
require 'rake_context'

require 'rubygems/tasks/console'

describe Gem::Tasks::Console do
  describe "#console" do
    include_context "rake"

    let(:command) { 'ripl'             }
    let(:options) { %w[-Ivendor -rfoo] }

    context "defaults" do
      it "should run `irb`" do
        subject.should_receive(:run).with('irb','-Ilib')

        subject.console
      end

      context "when project.bundler? == true" do
        it "should use `bundle console`" do
          subject.project.stub!(:bundler?).and_return(true)
          subject.should_receive(:run).with('bundle', 'console')

          subject.console
        end
      end
    end

    context "with custom command" do
      subject { described_class.new(:command => command) }

      it "should run the custom console" do
        subject.should_receive(:run).with(command, '-Ilib')

        subject.console
      end

      context "when project.bundler? == true" do
        it "should use `bundle exec`" do
          subject.project.stub!(:bundler?).and_return(true)
          subject.should_receive(:run).with('bundle', 'exec', command, '-Ilib')

          subject.console
        end
      end
    end

    context "with custom options" do
      subject { described_class.new(:options => options) }

      it "should pass custom options to `irb`" do
        subject.should_receive(:run).with('irb', '-Ilib', *options)

        subject.console
      end

      context "when project.bundler? == true" do
        it "should use `bundle exec ...`" do
          subject.project.stub!(:bundler?).and_return(true)
          subject.should_receive(:run).with('bundle', 'exec', 'irb', '-Ilib', *options)

          subject.console
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubygems-tasks-0.1.0 spec/console_spec.rb
rubygems-tasks-0.1.0.pre3 spec/console_spec.rb
rubygems-tasks-0.1.0.pre2 spec/console_spec.rb