- Revision
- 188
- Author
- mward
- Date
- 2007-06-25 22:11:01 -0500 (Mon, 25 Jun 2007)
Log Message
created rspec test for waffle.rb within core
Modified Paths
- trunk/core/core.iml
- trunk/core/pom.xml
- trunk/core/src/main/java/org/codehaus/waffle/servlet/WaffleServlet.java
- trunk/core/src/main/ruby/org/codehaus/waffle/waffle.rb
- trunk/waffle.ipr
Added Paths
- trunk/core/src/test/specs/
- trunk/core/src/test/specs/org/
- trunk/core/src/test/specs/org/codehaus/
- trunk/core/src/test/specs/org/codehaus/waffle/
- trunk/core/src/test/specs/org/codehaus/waffle/servlet/
- trunk/core/src/test/specs/org/codehaus/waffle/servlet/waffle_spec.rb
Diff
Modified: trunk/core/core.iml (187 => 188)
--- trunk/core/core.iml 2007-06-22 18:23:37 UTC (rev 187) +++ trunk/core/core.iml 2007-06-26 03:11:01 UTC (rev 188) @@ -10,7 +10,7 @@ <sourceFolder url="" isTestSource="false" /> <sourceFolder url="" isTestSource="true" /> <sourceFolder url="" isTestSource="true" /> - <excludeFolder url="" /> + <sourceFolder url="" isTestSource="true" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" />
Modified: trunk/core/pom.xml (187 => 188)
--- trunk/core/pom.xml 2007-06-22 18:23:37 UTC (rev 187) +++ trunk/core/pom.xml 2007-06-26 03:11:01 UTC (rev 188) @@ -58,6 +58,24 @@ </resources> <plugins> <plugin> + <groupId>org.codehaus.waffle</groupId> + <artifactId>rspec-maven-plugin</artifactId> + <configuration> + <jrubyHome>${env.JRUBY_HOME}</jrubyHome> + <sourceDirectory>${basedir}/src/test/specs</sourceDirectory> + <outputDirectory>${basedir}/target</outputDirectory> + </configuration> + <executions> + <execution> + <id>test</id> + <phase>test</phase> + <goals> + <goal>spec</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> <groupId>com.thoughtworks.paranamer</groupId> <artifactId>paranamer-maven-plugin</artifactId> <configuration>
Modified: trunk/core/src/main/java/org/codehaus/waffle/servlet/WaffleServlet.java (187 => 188)
--- trunk/core/src/main/java/org/codehaus/waffle/servlet/WaffleServlet.java 2007-06-22 18:23:37 UTC (rev 187) +++ trunk/core/src/main/java/org/codehaus/waffle/servlet/WaffleServlet.java 2007-06-26 03:11:01 UTC (rev 188) @@ -102,7 +102,7 @@ * Obtain the controller the user is requesting. */ protected ControllerDefinition getControllerDefinition(HttpServletRequest request, - HttpServletResponse response) throws ServletException { + HttpServletResponse response) throws ServletException { ControllerDefinition controllerDefinition = controllerDefinitionFactory.getControllerDefinition(request, response); if (controllerDefinition.getController() == null) { throw new ServletException("Unable to locate the Waffle Controller: " + request.getServletPath());
Modified: trunk/core/src/main/ruby/org/codehaus/waffle/waffle.rb (187 => 188)
--- trunk/core/src/main/ruby/org/codehaus/waffle/waffle.rb 2007-06-22 18:23:37 UTC (rev 187) +++ trunk/core/src/main/ruby/org/codehaus/waffle/waffle.rb 2007-06-26 03:11:01 UTC (rev 188) @@ -8,22 +8,23 @@ # load/require files class ScriptLoader + def ScriptLoader.load_all(prefix, servlet_context) - @@__servlet_context = servlet_context + @__servlet_context = servlet_context if (prefix.gsub!(/^dir:/, '')) - @@_ruby_script_path = prefix + @__ruby_script_path = prefix ScriptLoader.load_from_file_system else servlet_context.getResourcePaths(prefix).each do |path| # this would be for production!! - require(path.gsub(Regexp.new("^#{prefix}"), 'ruby/')) + require(path.gsub(Regexp.new("^#{prefix}\/"), 'ruby/')) end end end def ScriptLoader.load_from_file_system - path = @@__servlet_context.getRealPath('/') - path = "#{path}#{@@_ruby_script_path}" + path = @__servlet_context.getRealPath('/') + path = "[EMAIL PROTECTED]" Dir.new(path).each do |entry| file = "#{path}#{entry}"
Added: trunk/core/src/test/specs/org/codehaus/waffle/servlet/waffle_spec.rb (0 => 188)
--- trunk/core/src/test/specs/org/codehaus/waffle/servlet/waffle_spec.rb (rev 0) +++ trunk/core/src/test/specs/org/codehaus/waffle/servlet/waffle_spec.rb 2007-06-26 03:11:01 UTC (rev 188) @@ -0,0 +1,29 @@ +require 'org/codehaus/waffle/waffle' + +describe "Waffle::ScriptLoader module" do + + it "should use 'load' when path prefix begins with 'dir:'" do + servlet_context = mock('servlet_context') + + Waffle::ScriptLoader.should_receive(:load_from_file_system) + Waffle::ScriptLoader.load_all('dir:/fake/dir/path', servlet_context) + + # Class instance variables should have been set + Waffle::ScriptLoader.instance_variable_get(:@__servlet_context).should == servlet_context + Waffle::ScriptLoader.instance_variable_get(:@__ruby_script_path).should == '/fake/dir/path' + end + + it "should use 'require' when path prefix does NOT beign with 'dir:' (as is the case in production)" do + paths = ['fake/dir/path/one', 'fake/dir/path/two'] + + servlet_context = mock('servlet_context') + servlet_context.should_receive(:getResourcePaths).with('fake/dir/path').and_return(paths) + + Waffle::ScriptLoader.should_receive(:require).with('ruby/one') + Waffle::ScriptLoader.should_receive(:require).with('ruby/two') + Waffle::ScriptLoader.load_all('fake/dir/path', servlet_context) + + Waffle::ScriptLoader.instance_variable_get(:@__servlet_context).should == servlet_context + end + +end \ No newline at end of file
Modified: trunk/waffle.ipr (187 => 188)
--- trunk/waffle.ipr 2007-06-22 18:23:37 UTC (rev 187) +++ trunk/waffle.ipr 2007-06-26 03:11:01 UTC (rev 188) @@ -319,7 +319,7 @@ <module fileurl="file://$PROJECT_DIR$/examples/jruby-example/jruby-example.iml" filepath="$PROJECT_DIR$/examples/jruby-example/jruby-example.iml" /> <module fileurl="file://$PROJECT_DIR$/examples/paranamer-example/paranamer-example.iml" filepath="$PROJECT_DIR$/examples/paranamer-example/paranamer-example.iml" /> <module fileurl="file://$PROJECT_DIR$/root.iml" filepath="$PROJECT_DIR$/root.iml" /> - <module fileurl="file://$PROJECT_DIR$/jruby-rspec-runner/rspec-maven-plugin.iml" filepath="$PROJECT_DIR$/jruby-rspec-runner/rspec-maven-plugin.iml" /> + <module fileurl="file://$PROJECT_DIR$/rspec-maven-plugin/rspec-maven-plugin.iml" filepath="$PROJECT_DIR$/rspec-maven-plugin/rspec-maven-plugin.iml" /> <module fileurl="file://$PROJECT_DIR$/examples/simple-example/simple-example.iml" filepath="$PROJECT_DIR$/examples/simple-example/simple-example.iml" /> </modules> </component>
To unsubscribe from this list please visit:
