Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

60 lines (50 sloc) 1.406 kb
require 'helper'
describe Flipper do
describe ".new" do
it "returns new instance of dsl" do
instance = Flipper.new(double('Adapter'))
instance.should be_instance_of(Flipper::DSL)
end
end
describe ".groups" do
it "returns a registry instance" do
Flipper.groups.should be_instance_of(Flipper::Registry)
end
end
describe ".groups=" do
it "sets groups registry" do
registry = Flipper::Registry.new
Flipper.groups = registry
Flipper.instance_variable_get("@groups").should eq(registry)
end
end
describe ".register" do
it "adds a group to the group_registry" do
registry = Flipper::Registry.new
Flipper.groups = registry
group = Flipper.register(:admins) { |actor| actor.admin? }
registry.get(:admins).should eq(group)
end
it "raises exception if group already registered" do
Flipper.register(:admins) { }
expect {
Flipper.register(:admins) { }
}.to raise_error(Flipper::DuplicateGroup)
end
end
describe ".group" do
context "for registered group" do
before do
@group = Flipper.register(:admins) { }
end
it "returns group" do
Flipper.group(:admins).should eq(@group)
end
end
context "for unregistered group" do
it "returns nil" do
Flipper.group(:cats).should be_nil
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.