Sha256: e23d51b865462152e951a1674a02fe25f10c492130e8801f1b1f0b4cd9799a31

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe "application" do
	before(:each) do
		Bini::Config.clear
		Bini::Options.clear
		App.current_app = nil
	end

	it "can add a application to the Config[:application] hash." do
		App.add "foo", "bar"
		Bini::Config[:applications]["foo"].should eq("bar")
	end

	it "can remove a application from the hash." do
		App.add "foo", "bar"
		App.remove "foo"
		Bini::Config[:applications]["foo"].should be_nil
	end

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

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

	describe "#current_app?" do
		it "Will return true if we have a current_app" do
			Bini::Options[:token] = 'somethingsilly'
			App.current_app.should eq 'somethingsilly'
		end
		it "Will return nil otherwise" do
			App.current_app?.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/app_spec.rb
pushover-1.0.3 spec/lib/pushover/app_spec.rb
pushover-1.0.2 spec/lib/pushover/app_spec.rb