Sha256: 6f376bd4042b5b8ccb705a7573a6cafa4869dc73a6d6595afc43a0f69904613f

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe "user" do
	before(:each) do
		Bini::Config.clear
		Bini::Options.clear
		User.current_user = nil
	end

	it "can add a user to the Config[:users] hash." do
		User.add "foo", "bar"
		Bini::Config[:users]["foo"].should eq("bar")
	end

	it "can remove a user from the hash." do
		User.add "foo", "bar"
		User.remove "foo"
		Bini::Config[:users]["foo"].should be_nil
	end

	describe "#find" do
		it "can find the token from the name" do
			User.add "foo", "bar"
			User.find("foo").should eq("bar")
		end
		it "If it can't find the token, it will still try whatever was passed" do
			User.find("tryme").should eq "tryme"
		end
	end

	describe "#current_user" do
		it "will look on the cli first" do
			Bini::Options[:user] = 'atoken'
			User.current_user.should eq "atoken"
		end
		it "will grab the first user in the config as a last resort" do
			User.add "foo", "bar2"
			Bini::Config.save
			Bini::Options[:user] = nil
			User.current_user.should eq "bar2"
		end
	end

	describe "#current_user?" do
		it "Will return true if we have a current_user" do
			Bini::Options[:user] = 'somethingsilly'
			User.current_user?.should be_true
		end
		it "Will return nil otherwise" do
			User.current_user?.should be_nil
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pushover-1.0.4 spec/lib/pushover/user_spec.rb
pushover-1.0.3 spec/lib/pushover/user_spec.rb
pushover-1.0.2 spec/lib/pushover/user_spec.rb