Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow architecture specific settings.

  • Loading branch information...
commit 486a59e248f1925e15f6a375995edfbe9051d874 1 parent 1dc9ad2
@bernd authored
Showing with 54 additions and 0 deletions.
  1. +4 −0 lib/fpm/cookery/recipe.rb
  2. +50 −0 spec/recipe_spec.rb
View
4 lib/fpm/cookery/recipe.rb
@@ -30,6 +30,10 @@ def self.platforms(valid_platforms)
Array(valid_platforms).member?(self.platform) and block_given? ? yield : false
end
+ def self.architectures(archs)
+ Array(archs).member?(FPM::Cookery::Facts.arch) and block_given? ? yield : false
+ end
+
def self.attr_rw_list(*attrs)
attrs.each do |attr|
class_eval %Q{
View
50 spec/recipe_spec.rb
@@ -228,6 +228,56 @@ def self.platform; :centos; end
end
end
+ describe ".architectures" do
+ before do
+ FPM::Cookery::Facts.class_eval do
+ def self.arch; :x86_64; end
+ end
+ end
+
+ describe "with a list of architectures" do
+ it "allows arch specific settings" do
+ klass.class_eval do
+ vendor 'a'
+
+ architectures [:i386, :x86_64] do
+ vendor 'b'
+ end
+ end
+
+ klass.new(__FILE__).vendor.must_equal 'b'
+ end
+ end
+
+ describe "with a single architecture" do
+ it "allows arch specific settings" do
+ klass.class_eval do
+ vendor 'a'
+
+ architectures :x86_64 do
+ vendor 'b'
+ end
+ end
+
+ klass.new(__FILE__).vendor.must_equal 'b'
+ end
+ end
+
+ describe "without a matching architecture" do
+ it "does not set arch specific settings" do
+ klass.class_eval do
+ vendor 'a'
+
+ architectures :i386 do
+ vendor 'b'
+ end
+ end
+
+ klass.new(__FILE__).vendor.must_equal 'a'
+ end
+ end
+ end
+
#############################################################################
# Directories
Please sign in to comment.
Something went wrong with that request. Please try again.