fire_and_forget 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fire_and_forget}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Garry Hill"]
@@ -20,6 +20,10 @@ module FireAndForget
20
20
  @task.binary
21
21
  end
22
22
 
23
+ def binary_file
24
+ @task.binary.split(" ").first
25
+ end
26
+
23
27
  def cmd
24
28
  %(#{binary} #{FireAndForget.to_arguments(@params)})
25
29
  end
@@ -29,12 +33,12 @@ module FireAndForget
29
33
  end
30
34
 
31
35
  def permitted?
32
- raise PermissionsError, "'#{binary}' does not belong to user '#{ENV["USER"]}'" unless File.stat(binary).uid == task_uid
36
+ raise PermissionsError, "'#{binary_file}' does not belong to user '#{ENV["USER"]}'" unless File.stat(binary_file).uid == task_uid
33
37
  true
34
38
  end
35
39
 
36
40
  def exists?
37
- raise FileNotFoundError, "'#{binary}'" unless File.exists?(binary)
41
+ raise FileNotFoundError, "'#{binary_file}'" unless File.exists?(binary_file)
38
42
  true
39
43
  end
40
44
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module FireAndForget
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
@@ -77,7 +77,7 @@ class TestFireAndForget < Test::Unit::TestCase
77
77
  stub(stat).uid { Process.uid + 1 }
78
78
  stub(File).stat("/publish") { stat }
79
79
  cmd = FAF::Command::Fire.new(@task)
80
- lambda { cmd.run }.should raise_error(FAF::PermissionsError)
80
+ lambda { cmd.run }.should raise_error
81
81
  end
82
82
 
83
83
  should "not raise an error if the binary belongs to this process" do
@@ -85,7 +85,7 @@ class TestFireAndForget < Test::Unit::TestCase
85
85
  stub(stat).uid { Process.uid }
86
86
  stub(File).stat("/publish") { stat }
87
87
  cmd = FAF::Command::Fire.new(@task)
88
- lambda { cmd.permitted? }.should_not raise_error(FAF::PermissionsError)
88
+ lambda { cmd.permitted? }.should_not raise_error
89
89
  end
90
90
 
91
91
  should "raise an error if the binary belongs to this process" do
@@ -111,6 +111,17 @@ class TestFireAndForget < Test::Unit::TestCase
111
111
  mock(cmd).run.times(0)
112
112
  lambda { FAF::Server.run(cmd) }.should raise_error(FAF::PermissionsError)
113
113
  end
114
+
115
+ should "work with binaries involving a command" do
116
+ task = FAF::TaskDescription.new(:publish, "/publish all")
117
+ stat = Object.new
118
+ stub(stat).uid { Process.uid }
119
+ stub(File).stat("/publish") { stat }
120
+ stub(File).exist?("/publish") { true }
121
+ stub(File).exists?("/publish") { true }
122
+ cmd = FAF::Command::Fire.new(task)
123
+ lambda { cmd.valid? }.should_not raise_error
124
+ end
114
125
  end
115
126
 
116
127
  context "client" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Garry Hill