macros4cuke 0.1.02 → 0.1.03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/HISTORY.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.1.03]
2
+ ### Documentation
3
+ * README.md: slightly reworked and added link to Mustache.
4
+ ### Changes:
5
+ * env.rb: All dependencies on Macros4Cuke were moved to the file macro_support.rb
6
+ * travelling-demo.feature: Demo feature file with output on the screen (the other demos don't display any result).
7
+
8
+
1
9
  ## [0.0.02]
2
10
  ### Documentation
3
11
  * In README: added a reference to the features folder.
data/README.md CHANGED
@@ -1,17 +1,24 @@
1
1
  Macros4Cuke
2
2
  ===========
3
3
 
4
- ## Add macros to your Cucumber feature files. ##
4
+ _Add macros to your Cucumber scenarios._
5
5
  [Homepage](https://github.com/famished-tiger/Macros4Cuke)
6
6
 
7
- ## What is it? ##
8
- Macros4Cuke gives you to ability to define a new Cucumber (macro-)step directly in a feature file
9
- and to associate with it a sequence of steps to execute when the macro-step is used in
10
- a scenario.
7
+ __Macros4Cuke__ gives you the opportunity to factor out repeated steps
8
+ in your Cucumber scenarios. You can create (macro-)steps directly in feature files.
9
+ To each macro-step, it is possible to associate a sequence of sub-steps
10
+ that will be executed every time a macro-step occurs in a scenario.
11
11
 
12
- ## How can create such a macro? ##
13
- Here follows an example taken from our demo files:
12
+ ### Highlights ###
13
+ * Works with out-of-the-box Cucumber
14
+ * Simple installation and setup (no programming required),
15
+ * Substep sequence can be of arbitrary length,
16
+ * Macro-steps may have data arguments,
17
+ * Data values can be passed to the sub-steps.
14
18
 
19
+ ## Synopsis ##
20
+ Here is an example taken from our demo files:
21
+ ```cucumber
15
22
  Given I define the step "When I [enter my userid {{userid}} and password {{password}}]" to mean:
16
23
  """
17
24
  Given I landed in the homepage
@@ -20,35 +27,45 @@ Here follows an example taken from our demo files:
20
27
  And I fill in "Password" with "{{password}}"
21
28
  And I click "Submit"
22
29
  """
23
-
24
- That macro step can be used in a scenario like this:
25
- When I [enter my userid "jdoe" and password "hello-world"]
30
+ ```
26
31
 
32
+ Notice how the arguments are enclosed between curly braces {{..}}. In its current incarnation,
33
+ Macros4Cuke relies on the [Mustache](http://mustache.github.io/mustache.5.html) template engine
34
+ for generating the sub-steps.
35
+
36
+ That macro-step can then be used in a scenario like this:
37
+ ```cucumber
38
+ When I [enter my userid "jdoe" and password "hello-world"]
39
+ ```
27
40
 
28
41
  See also the working examples in the features folder.
29
42
 
43
+ ## Install and setup ##
44
+ * Step 1: Install the macros4cuke gem:
45
+ ```bash
46
+ gem install macros4cuke
47
+ ```
30
48
 
31
- ## What do I need to start? ##
32
- * Install the macros4cuke gem:
33
- - gem install macros4cuke
34
-
35
- * In your 'env.rb' file
36
- - 1. Load the modules and classes from the gem:
37
- require 'macros4cuke'
38
-
39
-
40
- - 2. Extend the world object like this:
41
- World(Macros4Cuke::MacroStepSupport)
42
49
 
50
+ * Step 2: Add support for macros in your Cucumber project
51
+ In your /features/support/ folder:
52
+ - Create a Ruby file (e.g. 'macro\_support.rb') with the following contents:
53
+ ```ruby
54
+ require 'macros4cuke'
55
+
56
+ World(Macros4Cuke::MacroStepSupport)
57
+ ```
43
58
 
44
- * In your 'step_definitions' folder
45
- - 3. Import the macro-management steps.
46
- Create a ruby file (say, 'use_macro_steps.rb').
47
- Add the following line:
48
- require 'macros4cuke/../macro_steps'
59
+ * Step 3: Import the macro-management steps
60
+ In your /features/step_definitions/ folder:
61
+ - Create a ruby file (say, 'use\_macro\_steps.rb') with the following line:
62
+ ```ruby
63
+ require 'macros4cuke/../macro_steps'
64
+ ```
49
65
 
50
- Your can start writing macros in your Cucumber project.
66
+ Now, you can start writing macros in your Cucumber project.
51
67
 
68
+ ---
52
69
 
53
70
  Copyright
54
71
  ---------
@@ -21,17 +21,21 @@ end
21
21
 
22
22
 
23
23
  When(/^I leave (.+)$/) do |city|
24
- trace_steps << %Q|Invoked step: ... I leave #{city}|
24
+ show "I leave #{city}"
25
25
  end
26
26
 
27
27
 
28
28
  When(/^I visit (.+)$/) do |city|
29
- trace_steps << %Q|Invoked step: ... I visit #{city}|
29
+ show "I visit #{city}"
30
30
  end
31
31
 
32
32
 
33
33
  When(/^I arrive in (.+)$/) do |city|
34
- trace_steps << %Q|Invoked step: ... I arrive in #{city}|
34
+ show "I arrive in #{city}"
35
+ end
36
+
37
+ When(/^I type (.+)$/) do |text|
38
+ show text
35
39
  end
36
40
 
37
41
 
@@ -4,16 +4,13 @@
4
4
  # It also demonstrate what to do in your env.rb file to use the Macros4Cuke gem.
5
5
 
6
6
 
7
- # Macros4Cuke step one: Load modules and classes from the gem.
8
- require 'macros4cuke'
9
7
 
8
+ module DemoMacros4Cuke # Use the module as a namespace
10
9
 
11
- module Macros4Cuke # Use the module as a namespace
10
+
11
+ # Class created just for testing and demonstration purposes.
12
+ # Its instance, will record the output emitted by the steps.
12
13
 
13
- =begin
14
- Class created just for testing and demonstration purposes.
15
- Its instance, will record the output emitted by the steps.
16
- =end
17
14
  class TracingWorld
18
15
  # Will contain the text emitted by the steps
19
16
  attr_reader(:trace_steps)
@@ -25,6 +22,11 @@ class TracingWorld
25
22
  end
26
23
 
27
24
  public
25
+ # Write the given text to the error console
26
+
27
+ def show(someText)
28
+ $stderr.puts(someText)
29
+ end
28
30
 
29
31
 
30
32
  end # class
@@ -33,14 +35,8 @@ end # module
33
35
 
34
36
  # For testing purpose we override the default Cucumber behaviour
35
37
  # making our world object an instance of the TracingWorld class
36
- World { Macros4Cuke::TracingWorld.new }
37
-
38
-
39
- # Macros4Cuke step two: extend the world object with the mix-in module
40
- # that adds the support for macros in Cucumber.
41
- World(Macros4Cuke::MacroStepSupport)
38
+ World { DemoMacros4Cuke::TracingWorld.new }
42
39
 
43
- # That's all folks!...
44
40
 
45
41
 
46
42
  # End of file
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8 You should see a paragraph character: §
2
+ # File: macro_support.rb
3
+ # Purpose: Add the support for macros in Cucumber.
4
+ # This file is meant to be put next to the 'env.rb' file of your Cucumeber project.
5
+
6
+
7
+ # Macros4Cuke step one: Load modules and classes from the gem.
8
+ require 'macros4cuke'
9
+
10
+
11
+ # Macros4Cuke step two: extend the world object with the mix-in module
12
+ # that adds the support for macros in Cucumber.
13
+ World(Macros4Cuke::MacroStepSupport)
14
+
15
+
16
+ # End of file
@@ -0,0 +1,65 @@
1
+ # File: travelling-demo.feature
2
+
3
+ Feature: Show -visually- the several ways to use macros
4
+ As a Cuke user
5
+ So that I enjoy writing scenario.
6
+
7
+
8
+ Scenario: Definition of a simple macro-step with two arguments
9
+ Given I define the step "When I [travel from {{origin}} to {{destination}}]" to mean:
10
+ """
11
+ When I leave {{origin}}
12
+ And I arrive in {{destination}}
13
+ """
14
+
15
+ Scenario: Do a simple travel
16
+ # Call a macro-step defined earlier
17
+ When I [travel from "Brussels" to "Rome"]
18
+
19
+ # You should see the output:
20
+ # I leave Brussels
21
+ # I arrive in Rome
22
+
23
+
24
+ Scenario: Defining a macro calling other macro(s)
25
+ Given I define the step "When I [travel from {{origin}} to {{destination}} and back]" to mean:
26
+ """
27
+ {{! The next two steps are, in fact, macro-step invokations}}
28
+ When I [travel from "{{origin}}" to "{{destination}}"]
29
+ When I [travel from "{{destination}}" to "{{origin}}"]
30
+ """
31
+
32
+ Scenario: Do a travel back and forth
33
+ When I [travel from "Paris" to "London" and back]
34
+
35
+ # You should see the output:
36
+ # I leave Paris
37
+ # I arrive in London
38
+ # I leave London
39
+ # I arrive in Paris
40
+
41
+
42
+ Scenario: Defining a macro that requires a data table
43
+ Given I define the step "When I [fill in the form with]:" to mean:
44
+ """
45
+ When I type {{firstname}}
46
+ And I type {{lastname}}
47
+ And I type {{street_address}}
48
+ And I type {{city}}
49
+ And I type {{country}}
50
+ """
51
+
52
+ Scenario: Using a macro-step with a data table
53
+ When I [fill in the form with]:
54
+ |firstname| Sherlock|
55
+ |lastname|Holmes|
56
+ |street_address| 221B, Baker Street|
57
+ |city|London|
58
+ |country|U.K.|
59
+
60
+ # You should see the output:
61
+ # Sherlock
62
+ # Holmes
63
+ # 221B, Baker Street
64
+ # London
65
+ # U.K.
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Macros4Cuke # Module used as a namespace
5
5
  # This constant keeps the current version of the gem.
6
- Version = '0.1.02'
6
+ Version = '0.1.03'
7
7
 
8
8
  Description = "Macros for Cucumber"
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macros4cuke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.02
4
+ version: 0.1.03
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-22 00:00:00.000000000 Z
12
+ date: 2013-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -82,9 +82,11 @@ files:
82
82
  - features/demo02.feature
83
83
  - features/demo03.feature
84
84
  - features/demo04.feature
85
+ - features/travelling-demo.feature
85
86
  - features/step_definitions/demo_steps.rb
86
87
  - features/step_definitions/use_macro_steps.rb
87
88
  - features/support/env.rb
89
+ - features/support/macro_support.rb
88
90
  homepage: https://github.com/famished-tiger/Macros4Cuke
89
91
  licenses: []
90
92
  post_install_message: ! '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~