Sha256: 3242df79f16ea381e32b25366341c9473759af4ad6f61a71320f65d0ae139bdd

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe Mongoid::Shell::Commands::Base do
  context "without a default session" do
    before :each do
      Mongoid.stub(:default_session).and_return(nil)
    end
    it "raises an exception when a session is missing" do
      expect {
        Mongoid::Shell::Commands::Base.new({})
      }.to raise_error Mongoid::Shell::Errors::MissingSessionError, /Missing session./
    end
    it "raises an exception when options are missing" do
      expect {
        Mongoid::Shell::Commands::Base.new(nil)
      }.to raise_error Mongoid::Shell::Errors::MissingSessionError, /Missing session./
    end
  end
  it "creates a command using the default session" do
    command = Mongoid::Shell::Commands::Base.new
    command.session.should eq Mongoid.default_session
  end
  it "creates a command using the session provided" do
    session = Moped::Session.new([ "127.0.0.1:27017" ])
    command = Mongoid::Shell::Commands::Base.new(session: session)
    command.session.should eq session
  end
  it "command_for" do
    command = Mongoid::Shell::Commands::Base.command_for(Mongoid.default_session)
    command.session.should eq Mongoid.default_session
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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