Sha256: f2b4e85ab7581cb651bcde12013c15165d223432b3f440ae70a7a9f14c6e6f43

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'

describe Mongoid::Shell::Commands::Mongo do
  include MopedSessionHelper
  context "local" do
    it "defaults to local" do
      Mongoid::Shell::Commands::Mongo.new.to_s.should == "mongo mongoid_shell_tests"
    end
    it "includes eval" do
      Mongoid::Shell::Commands::Mongo.new({
        eval: 'find x'
      }).to_s.should == 'mongo mongoid_shell_tests --eval "find x"'
    end
    it "overrides primary" do
      Mongoid::Shell::Commands::Mongo.new({
        eval: 'find x',
        primary: 'my_primary'
      }).to_s.should == 'mongo my_primary/mongoid_shell_tests --eval "find x"'
    end
    [ :nodb, :norc, :quiet, :ipv6 ].each do |option|
      it "includes #{option}" do
        Mongoid::Shell::Commands::Mongo.new({
          option => true
        }).to_s.should == "mongo mongoid_shell_tests --#{option}"
      end
    end

  end
  context "sessions" do
    context "default" do
      before :each do
        @session = Mongoid::Sessions.with_name(:default)
      end
      it "includes username and password" do
        Mongoid::Shell::Commands::Mongo.new({
          session: @session
        }).to_s.should == "mongo mongoid_shell_tests"
      end
    end
    context "a replica set" do
      before :each do
        @session = moped_session(:replica_set)
      end
      it "includes username and password" do
        Mongoid::Shell::Commands::Mongo.new({
          session: @session
        }).to_s.should == "mongo dedicated1.myapp.com:27017/mongoid --username user --password password"
      end
    end
    context "url" do
      before :each do
        @session = moped_session(:url)
      end
      it "includes username and password" do
        Mongoid::Shell::Commands::Mongo.new({
          session: @session
        }).to_s.should == "mongo 59.1.22.1:27017/mongoid --username user --password password"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-shell-0.2.0 spec/mongoid/commands/mongo_spec.rb