spec/lib/open_sesame/configuration_spec.rb in opensesame-0.0.1 vs spec/lib/open_sesame/configuration_spec.rb in opensesame-0.0.2

- old
+ new

@@ -19,10 +19,15 @@ it "mounted_at sets mount_prefix" do configuration.mounted_at "/foobar" configuration.mount_prefix.should == "/foobar" end + it "auto_access sets provider to attempt auto login" do + configuration.auto_login "github" + configuration.auto_access_provider.should == "github" + end + describe "valid?" do it "false when values not set" do configuration.organization "challengepost" configuration.should_not be_valid @@ -51,8 +56,64 @@ configuration.github "client_id", "client_secret" configuration.mounted_at "/foobar" configuration.should be_valid configuration.validate!.should be_true + end + end + + describe "enabled?" do + let(:conditional) { mock('conditional', :true? => true) } + + it { configuration.enabled?.should be_false } + + it "true if enabled!" do + configuration.enable! + configuration.should be_enabled + end + + it "false if disabled" do + configuration.disable! + configuration.should_not be_enabled + end + + it "false if enable_if clause is false" do + conditional.stub!(:true?).and_return(false) + configuration.enable_if conditional.true? + configuration.should_not be_enabled + end + + it "true if enable_if clause is true" do + conditional.stub!(:true?).and_return(true) + configuration.enable_if conditional.true? + configuration.should be_enabled + end + + it "true if enable_if clause is false but then enabled!" do + conditional.stub!(:true?).and_return(false) + configuration.enable_if conditional.true? + configuration.enable! + configuration.should be_enabled + end + + it "false if enable_if clause is true but then disabled!" do + conditional.stub!(:true?).and_return(true) + configuration.enable_if conditional.true? + configuration.disable! + configuration.should_not be_enabled + end + + it "false if enabled! then supplied with enable_if clause that is false" do + configuration.enable! + conditional.stub!(:true?).and_return(false) + configuration.enable_if conditional.true? + configuration.should_not be_enabled + end + + it "true if disabled! then supplied with enable_if clause that is true" do + configuration.disable! + conditional.stub!(:true?).and_return(true) + configuration.enable_if conditional.true? + configuration.should be_enabled end end end \ No newline at end of file