Sha256: 74de9ef6e5981228c259d162c79fd60552b04c8cf1fc920a3a2969d975f99055

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Bastet::Base do
  before do
    @redis = Redis.new
    @bastet = Bastet::Base.new(@redis)
  end

  describe "initialization" do
    it "should configure the Redis instance" do
      Bastet::Base.new(@redis).redis.should == @redis
    end
  end

  describe "activate" do
    it "should activate the :banana for the user" do
      user = mock('user')
      user.expects(:id).at_least(2).returns(100)

      @bastet.activate(:banana, user)
      @bastet.active?(:banana, user).should be_true
    end

    it "should activate the :banana for the group" do
      @bastet.activate(:banana, :admins)
      @bastet.active?(:banana, :admins).should be_true
    end
  end

  describe "deactivate" do
    it "should deactivate the :banana for the user" do
      user = mock('user')
      user.expects(:id).at_least(2).returns(100)

      @bastet.activate(:banana, user)
      @bastet.active?(:banana, user).should be_true

      @bastet.deactivate(:banana, user)
      @bastet.inactive?(:banana, user).should be_true
    end

    it "should deactivate the :banana for the group" do
      @bastet.activate(:banana, :admins)
      @bastet.active?(:banana, :admins).should be_true

      @bastet.deactivate(:banana, :admins)
      @bastet.inactive?(:banana, :admins).should be_true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bastet-0.0.2 spec/bastet/base_spec.rb
bastet-0.0.1 spec/bastet/base_spec.rb