Title: [1400] trunk/web/web-runner/src/main/webapp/ftl/scenario: JBEHAVE-213: Added drop-down selection to toggle between form action methods.

Diff

Modified: trunk/web/web-runner/src/main/java/org/jbehave/web/runner/waffle/controllers/ScenarioContext.java (1399 => 1400)

--- trunk/web/web-runner/src/main/java/org/jbehave/web/runner/waffle/controllers/ScenarioContext.java	2009-12-07 17:33:53 UTC (rev 1399)
+++ trunk/web/web-runner/src/main/java/org/jbehave/web/runner/waffle/controllers/ScenarioContext.java	2009-12-08 09:01:55 UTC (rev 1400)
@@ -11,8 +11,10 @@
 
 public class ScenarioContext {
 
-	private static final String POST = "post";
+    private static final String POST = "post";
+    private static final String GET = "get";
     private static final String EMPTY = "";
+    private static final List<String> METHODS = asList(POST, GET);
 	private static final List<String> EMPTY_LIST = asList();
 
     private String method = POST;
@@ -32,8 +34,11 @@
 		this.messages = new ArrayList<String>();
 		this.messages.addAll(messages);
 	}
-
 	
+	public List<String> getMethods(){
+	    return METHODS;
+	}
+	
 	public String getMethod() {
         return method;
     }

Modified: trunk/web/web-runner/src/main/webapp/ftl/scenario/scenario.ftl (1399 => 1400)

--- trunk/web/web-runner/src/main/webapp/ftl/scenario/scenario.ftl	2009-12-07 17:33:53 UTC (rev 1399)
+++ trunk/web/web-runner/src/main/webapp/ftl/scenario/scenario.ftl	2009-12-08 09:01:55 UTC (rev 1400)
@@ -16,7 +16,10 @@
                 <p>
                 	<@w.textarea "scenarioContext.input" "${scenarioContext.input}" "rows='25' cols='100'"/>
                 </p>
- 				<p><a href="" "runScenario" "Run Scenario"/></a></p> 
+ 				<p><a href="" "runScenario" "Run Scenario"/></a> (Method 
+ 				   <@w.selectSingle "scenarioContext.method" w.asNameableValues(scenarioContext.getMethods(),"name()","name()") scenarioContext.getMethod() 
+                   " />)				
+ 				</p> 
             </fieldset>
         </div>
 

Modified: trunk/web/web-runner/src/test/java/org/jbehave/web/runner/waffle/controllers/ScenarioControllerTest.java (1399 => 1400)

--- trunk/web/web-runner/src/test/java/org/jbehave/web/runner/waffle/controllers/ScenarioControllerTest.java	2009-12-07 17:33:53 UTC (rev 1399)
+++ trunk/web/web-runner/src/test/java/org/jbehave/web/runner/waffle/controllers/ScenarioControllerTest.java	2009-12-08 09:01:55 UTC (rev 1400)
@@ -4,6 +4,8 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.util.List;
+
 import org.codehaus.waffle.menu.Menu;
 import org.jbehave.scenario.Configuration;
 import org.jbehave.scenario.MostUsefulConfiguration;
@@ -62,6 +64,17 @@
 		assertEquals(asList("Test failed"), controller.getScenarioContext().getFailureMessages());
 		assertTrue(controller.getScenarioContext().getFailureStackTrace().startsWith("java.lang.RuntimeException: Test failed"));
 	}
+
+    @Test
+    public void canChangeScenarioContextMethod(){
+        ScenarioController controller = new ScenarioController(MENU, configuration, parser, runner, new MySteps());
+        ScenarioContext scenarioContext = controller.getScenarioContext();
+        List<String> methods = scenarioContext.getMethods();
+        assertEquals(methods.get(0), scenarioContext.getMethod());
+        scenarioContext.setMethod(methods.get(1));
+        controller.show();
+        assertEquals(methods.get(1), scenarioContext.getMethod());
+    }	
 	
 	private void assertLinesMatch(String expected, String actual) {
 		String[] expectedLines = expected.split(NL);


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to