You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2009/03/13 03:50:16 UTC
svn commit: r753096 - in /buildr/trunk/spec: core/util_spec.rb
ide/idea7x_spec.rb
Author: assaf
Date: Fri Mar 13 02:50:15 2009
New Revision: 753096
URL: http://svn.apache.org/viewvc?rev=753096&view=rev
Log:
Added new specs for BUILDR-241 and BUILDR-247 that were absent in previous commits
Added:
buildr/trunk/spec/core/util_spec.rb
buildr/trunk/spec/ide/idea7x_spec.rb
Added: buildr/trunk/spec/core/util_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/core/util_spec.rb?rev=753096&view=auto
==============================================================================
--- buildr/trunk/spec/core/util_spec.rb (added)
+++ buildr/trunk/spec/core/util_spec.rb Fri Mar 13 02:50:15 2009
@@ -0,0 +1,67 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership. The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require File.join(File.dirname(__FILE__), '../spec_helpers')
+
+describe Hash do
+ describe "#only" do
+ it "should find value for one key" do
+ {:a => 1, :b => 2, :c => 3}.only(:a).should == {:a => 1}
+ end
+
+ it "should find values for multiple keys" do
+ {:a => 1, :b => 2, :c => 3}.only(:b, :c).should == {:b => 2, :c => 3}
+ end
+ end
+end
+
+describe OpenObject do
+ before do
+ @obj = OpenObject.new({:a => 1, :b => 2, :c => 3})
+ end
+
+ it "should be kind of Hash" do
+ Hash.should === @obj
+ end
+
+ it "should accept block that supplies default value" do
+ obj = OpenObject.new { |hash, key| hash[key] = "New #{key}" }
+ obj[:foo].should == "New foo"
+ obj.keys.should == [:foo]
+ end
+
+ it "should combine initial values from hash argument and from block" do
+ obj = OpenObject.new(:a => 6, :b => 2) { |h, k| h[k] = k.to_s * 2 }
+ obj[:a].should == 6
+ obj[:c].should == 'cc'
+ end
+
+ it "should allow reading a value by calling its name method" do
+ @obj.b.should == 2
+ end
+
+ it "should allow setting a value by calling its name= method" do
+ lambda { @obj.f = 32 }.should change { @obj.f }.to(32)
+ end
+
+ it "should allow changing a value by calling its name= method" do
+ lambda { @obj.c = 17 }.should change { @obj.c }.to(17)
+ end
+
+ it "should implement only method like a hash" do
+ @obj.only(:a).should == { :a => 1 }
+ end
+end
Added: buildr/trunk/spec/ide/idea7x_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/ide/idea7x_spec.rb?rev=753096&view=auto
==============================================================================
--- buildr/trunk/spec/ide/idea7x_spec.rb (added)
+++ buildr/trunk/spec/ide/idea7x_spec.rb Fri Mar 13 02:50:15 2009
@@ -0,0 +1,84 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership. The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require File.join(File.dirname(__FILE__), '../spec_helpers')
+
+
+module Idea7xHelper
+ def ipr_xml_elements
+ task('idea7x').invoke
+ REXML::Document.new(File.read("#{@project_name}-7x.ipr")).root.elements
+ end
+
+ def ipr_module_elements
+ ipr_xml_elements.to_a("//component[@name='ProjectModuleManager']/modules/module")
+ end
+
+ def ipr_module_filepaths
+ ipr_module_elements.collect { |m| m.attributes['filepath'] }
+ end
+
+ def ipr_module_fileurls
+ ipr_module_elements.collect { |m| m.attributes['fileurl'] }
+ end
+end
+
+
+describe Idea7x do
+ include Idea7xHelper
+
+ describe "the project file" do
+ before do
+ @project_name = 'alphabet'
+ end
+
+ it "includes a module for the root project" do
+ # Current behavior is to only generate IMLs for packaged projects
+ define(@project_name) { project.version = '0.0.0'; package(:jar) }
+ ipr_module_elements.should have(1).element
+ ipr_module_filepaths.should == ["$PROJECT_DIR$/alphabet-7x.iml"]
+ ipr_module_fileurls.should == ["file://$PROJECT_DIR$/alphabet-7x.iml"]
+ end
+
+ it "includes an IML for a subproject" do
+ mkpath 'h'
+ define(@project_name) do
+ project.version = '0.0.0'; package(:jar)
+ define('h') do
+ package(:jar)
+ end
+ end
+
+ ipr_module_elements.should have(2).elements
+ ipr_module_filepaths.should include("$PROJECT_DIR$/h/alphabet-h-7x.iml")
+ ipr_module_fileurls.should include("file://$PROJECT_DIR$/h/alphabet-h-7x.iml")
+ end
+
+ it "pays attention to the base_dir for a subproject" do
+ mkpath 'aitch'
+ define(@project_name) do
+ project.version = '0.0.0'; package(:jar)
+ define('h', :base_dir => 'aitch') do
+ package(:jar)
+ end
+ end
+
+ ipr_module_elements.should have(2).elements
+ ipr_module_filepaths.should include("$PROJECT_DIR$/aitch/alphabet-h-7x.iml")
+ ipr_module_fileurls.should include("file://$PROJECT_DIR$/aitch/alphabet-h-7x.iml")
+ end
+ end
+end