Sha256: 5a90edff19a47717c217daec28029348f18e87e714aeca9417fd869028ec3dd8

Contents?: true

Size: 1.83 KB

Versions: 7

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'

describe SimpleRoles::Configuration do
  subject { SimpleRoles::Configuration }

  its(:default_strategy) { should == :one }
  its(:strategy) { should == :one }
  its(:strategy_class) { should == SimpleRoles::One }

  describe ".strategy" do
    it "should retrieve current strategy if no argument passed" do
      subject.strategy.should == :one
    end

    it "should set current strategy if strategy passed as argument" do
      subject.strategy :many
      subject.strategy.should == :many
    end
    
    it "should not allow wrong strategies" do
      expect {
        subject.strategy :wrong!
      }.to raise_error
    end
  end

  describe ".strategy=" do
    it "should set current strategy if strategy passed as argument" do
      subject.strategy = :one
      subject.strategy.should == :one

      subject.strategy = :many
      subject.strategy.should == :many
    end

    it "should not allow wrong strategies" do
      expect {
        subject.strategy = :wrong!
      }.to raise_error
    end
  end
 
  describe ".valid_roles=" do
    it "should set valid roles" do
      valid_roles_before = SimpleRoles::Configuration.valid_roles

      SimpleRoles::Configuration.valid_roles = [:user]
      SimpleRoles::Configuration.valid_roles.should == [:user]

      SimpleRoles::Configuration.valid_roles = valid_roles_before
      SimpleRoles::Configuration.valid_roles.should == valid_roles_before
    end
  end

  describe ".valid_roles" do
    it "should also set valid roles if they passed as arg" do
      valid_roles_before = SimpleRoles::Configuration.valid_roles

      SimpleRoles::Configuration.valid_roles :user
      SimpleRoles::Configuration.valid_roles.should == [:user]

      SimpleRoles::Configuration.valid_roles valid_roles_before
      SimpleRoles::Configuration.valid_roles.should == valid_roles_before
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
simple_roles-0.0.12 spec/simple_roles/configuration_spec.rb
simple_roles-0.0.11 spec/simple_roles/configuration_spec.rb
simple_roles-0.0.10 spec/simple_roles/configuration_spec.rb
simple_roles-0.0.9 spec/simple_roles/configuration_spec.rb
simple_roles-0.0.8 spec/simple_roles/configuration_spec.rb
simple_roles-0.0.7 spec/simple_roles/configuration_spec.rb
simple_roles-0.0.6 spec/simple_roles/configuration_spec.rb