Sha256: 830ce66a860b056556d2aad99a9dec47879ffe1cec139e093cd3769eff531582

Contents?: true

Size: 1.11 KB

Versions: 19

Compression:

Stored size: 1.11 KB

Contents

require File.expand_path("../../../../base", __FILE__)

describe Vagrant::Action::Builtin::Confirm do
  let(:app) { lambda { |env| } }
  let(:env) { { :ui => double("ui") } }
  let(:message) { "foo" }

  ["y", "Y"].each do |valid|
    it "should set the result to true if '#{valid}' is given" do
      env[:ui].should_receive(:ask).with(message).and_return(valid)
      described_class.new(app, env, message).call(env)
      env[:result].should be
    end
  end

  it "should set the result to true if force matches" do
    force_key = :tubes
    env[force_key] = true
    described_class.new(app, env, message, force_key).call(env)
    env[:result].should be
  end

  it "should ask if force is not true" do
    force_key = :tubes
    env[force_key] = false
    env[:ui].should_receive(:ask).with(message).and_return("nope")
    described_class.new(app, env, message).call(env)
    env[:result].should_not be
  end

  it "should set result to false if anything else is given" do
    env[:ui].should_receive(:ask).with(message).and_return("nope")
    described_class.new(app, env, message).call(env)
    env[:result].should_not be
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/action/builtin/confirm_test.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/action/builtin/confirm_test.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/action/builtin/confirm_test.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/action/builtin/confirm_test.rb
tnargav-1.3.6 test/unit/vagrant/action/builtin/confirm_test.rb
tnargav-1.3.3 test/unit/vagrant/action/builtin/confirm_test.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/unit/vagrant/action/builtin/confirm_test.rb
tnargav-1.2.3 test/unit/vagrant/action/builtin/confirm_test.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/unit/vagrant/action/builtin/confirm_test.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/test/unit/vagrant/action/builtin/confirm_test.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/test/unit/vagrant/action/builtin/confirm_test.rb
tnargav-1.2.2 test/unit/vagrant/action/builtin/confirm_test.rb
vagrantup-1.1.3 test/unit/vagrant/action/builtin/confirm_test.rb
vagrantup-1.1.2 test/unit/vagrant/action/builtin/confirm_test.rb
vagrantup-1.1.1 test/unit/vagrant/action/builtin/confirm_test.rb
vagrantup-1.1.0 test/unit/vagrant/action/builtin/confirm_test.rb
vagrantup-1.1.4 test/unit/vagrant/action/builtin/confirm_test.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/test/unit/vagrant/action/builtin/confirm_test.rb
vagrant-lxc-0.0.1 vendor/vagrant/test/unit/vagrant/action/builtin/confirm_test.rb