Sha256: 0057fdedaea4a4ab3a748c713bc37e4eacac8a98c71152cf72687bae9de5629a

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe LaunchAgent::Periodic do
  before do
    @plist_filename = File.expand_path('~/Library/LaunchAgents/com.buycheapviagraonlinenow.ruby__foo_rb.plist')
    @agent = LaunchAgent::Periodic.new(120, 'ruby', 'foo.rb')

    # key exists
    @agent['WorkingDirectory'] = '/foo/bar'

    # key does not exists
    @agent['XXX'] = 'YYY'
  end

  after do
    `launchctl unload -w #{@plist_filename}` if `launchctl list | grep ruby__foo_rb` =~ /ruby__foo.rb/
    File.unlink(@plist_filename) if File.exists?(@plist_filename)
  end

  it 'should load and unload' do
    @agent.should_not be_loaded

    @agent.load

    @agent.should be_loaded

    File.exists?(@plist_filename).should be_true
    open(@plist_filename).read.should eql(<<PLIST)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.buycheapviagraonlinenow.ruby__foo_rb</string>
	<key>ProgramArguments</key>
	<array>
		<string>ruby</string>
		<string>foo.rb</string>
	</array>
	<key>StartInterval</key>
	<integer>120</integer>
	<key>WorkingDirectory</key>
	<string>/foo/bar</string>
</dict>
</plist>
PLIST

    (`launchctl list | grep ruby__foo_rb` =~ /ruby__foo.rb/).should_not be_nil

    @agent.unload

    File.exists?(@plist_filename).should be_false
    (`launchctl list | grep ruby__foo_rb` =~ /ruby__foo.rb/).should be_nil
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
launch-agent-0.9.0 spec/periodic_spec.rb
launch-agent-0.8.1 spec/periodic_spec.rb
launch-agent-0.8.0 spec/periodic_spec.rb
launch-agent-0.7.0 spec/periodic_spec.rb
launch-agent-0.6.1 spec/periodic_spec.rb
launch-agent-0.6.0 spec/periodic_spec.rb
launch-agent-0.5.0 spec/periodic_spec.rb
launch-agent-0.4.1 spec/periodic_spec.rb
launch-agent-0.4.0 spec/periodic_spec.rb
launch-agent-0.3.0 spec/periodic_spec.rb