spec/bastet/base_spec.rb in bastet-0.0.2 vs spec/bastet/base_spec.rb in bastet-0.1.0

- old
+ new

@@ -1,50 +1,30 @@ require 'spec_helper' describe Bastet::Base do before do - @redis = Redis.new - @bastet = Bastet::Base.new(@redis) + @bastet = Bastet.setup(@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) + it "should activate the :banana for the group" do + group = Bastet::Group.new("admins") { |entity| entity.admin? } + user = mock('user', admin?: true) - @bastet.activate(:banana, user) + @bastet.activate(:banana, group) @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) + it "should deactive :banana for the group" do + group = Bastet::Group.new("admins") { |entity| entity.admin? } + user = mock('user', admin?: true) - @bastet.activate(:banana, user) + @bastet.activate(:banana, group) @bastet.active?(:banana, user).should be_true - @bastet.deactivate(:banana, user) + @bastet.deactivate(:banana, group) @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