package com.greghaskins.spectrum;

import static com.greghaskins.spectrum.Spectrum.compositeSpec;
import static com.greghaskins.spectrum.Spectrum.describe;
import static com.greghaskins.spectrum.Spectrum.it;

/**
 * A translation from Spectrum describe/it to Gherkin like Feature/Scenario/Given/When/Then syntax
 * Note - the beforeEach and afterEach will still be executed between given/when/then steps which
 * may not make sense in many situations.
 */
public interface GherkinSyntax {
  /**
   * Describes a feature of the system. A feature may have many scenarios.
   * 
   * @param featureName name of feature
   * @param block the contents of the feature
   */
  public static void feature(final String featureName, final Block block) {
    describe("Feature: " + featureName, block);
  }

  /**
   * Describes a scenario of the system. These can be at root level, though are best grouped inside
   * features.
   * 
   * @param scenarioName name of scenario
   * @param block the contents of the scenario - given/when/then steps
   */
  public static void scenario(final String scenarioName, final Block block) {
    compositeSpec("Scenario: " + scenarioName, block);
  }

  /**
   * A gherkin like given block.
   * 
   * @param behavior the behaviour to associate with the precondition
   * @param block how to execute that precondition
   */
  public static void given(final String behavior, final Block block) {
    it("Given " + behavior, block);
  }

  /**
   * A gherkin like when block.
   * 
   * @param behavior the behaviour to associate with the manipulation of the system under test
   * @param block how to execute that behaviour
   */
  public static void when(final String behavior, final Block block) {
    it("When " + behavior, block);
  }

  /**
   * A gherkin like then block.
   * 
   * @param behavior the behaviour to associate with the postcondition
   * @param block how to execute that postcondition
   */
  public static void then(final String behavior, final Block block) {
    it("Then " + behavior, block);
  }

  /**
   * An and block.
   * 
   * @param behavior what we would like to describe as an and
   * @param block how to achieve the and block
   */
  public static void and(final String behavior, final Block block) {
    it("And " + behavior, block);
  }

}

@@ -255,25 +255,25 @@
 t to Gherkin
- 
+-
 like Feature
@@ -563,25 +563,24 @@
 narios.%0A   *
- 
 %0A   * @param
@@ -650,24 +650,49 @@
 the feature%0A
+   *%0A   * @see #scenario%0A
    */%0A  publ
@@ -900,16 +900,26 @@
 ugh 
+scenarios 
 are best
  gro
@@ -914,16 +914,21 @@
 are best
+%0A   *
  grouped
@@ -938,29 +938,44 @@
 side
-%0A   * feature
+ %7B@link #feature%7D declaration
 s.%0A   *
- 
 %0A   
@@ -1084,16 +1084,89 @@
 n steps%0A
+   *%0A   * @see #feature%0A   * @see #given%0A   * @see #when%0A   * @see #then%0A
    */%0A  
@@ -1316,41 +1316,126 @@
   * 
-A g
+Define a precondition step with a G
 herkin
- 
+-
 like 
+%7B@code 
 given
+%7D
  block.
+ Must be used inside a%0A   * %7B@link #scenario%7D.
 %0A   *
- 
 %0A   
@@ -1455,33 +1455,32 @@
 vior the behavio
-u
 r to associate w
@@ -1543,32 +1543,69 @@
 at precondition%0A
+   *%0A   * @see #when%0A   * @see #then%0A
    */%0A  public s
@@ -1721,27 +1721,95 @@
   * 
-A g
+Define the action performed by the system under test using a G
 herkin
- 
+-
 like 
+%7B@code 
 when
+ %7D
  blo
@@ -1809,32 +1809,77 @@
 n %7D block.%0A   * 
+Must be used inside a %7B@link #scenario%7D.%0A   *
 %0A   * @param beh
@@ -1887,33 +1887,32 @@
 vior the behavio
-u
 r to associate w
@@ -2006,11 +2006,48 @@
 avio
-u
 r%0A
+   *%0A   * @see #given%0A   * @see #then%0A
    *
@@ -2173,40 +2173,126 @@
   * 
-A g
+Define a postcondition step with a G
 herkin
- 
+-
 like 
+%7B@code 
 then
+%7D
  block.
+ Must be used inside a%0A   * %7B@link #scenario%7D.
 %0A   *
- 
 %0A   
@@ -2320,17 +2320,16 @@
  behavio
-u
 r to ass
@@ -2406,24 +2406,62 @@
 stcondition%0A
+   *%0A   * @see #given%0A   * @see #when%0A
    */%0A  publ
@@ -2579,27 +2579,129 @@
   * 
-An and block.%0A   * 
+Syntactic sugar for an additional %7B@link #given%7D or %7B@link then%7D step. Must be used inside a%0A   * %7B@link #scenario%7D.%0A   *
 %0A   
@@ -2806,16 +2806,70 @@
 d block%0A
+   *%0A   * @see #given%0A   * @see #when%0A   * @see #then%0A
    */%0A  

Tweak Gherkin javadoc for consistency