Permalink
Browse files

.wire files are now rendered through ERB before use so that ports and…

… other settings can be dynamically altered at runtime. (see Lighthouse #694)
  • Loading branch information...
1 parent e2df150 commit 0c11d206e08e8d5647e03bf78be93723d59529ef Kevin Olbrich committed Jan 20, 2011
@@ -11,7 +11,7 @@ Feature: Wire Protocol
#
# Communication is over a TCP socket, which Cucumber connects to when it finds
# a definition file with the .wire extension in the step_definitions folder
- # (or other load path).
+ # (or other load path). Note that these files are rendered with ERB when loaded.
#
# Cucumber sends the following request messages out over the wire:
#
@@ -31,7 +31,7 @@ Feature: Wire Protocol
# Some messages support more responses - see below for details.
#
# A WirePacket flowing in either direction is formatted as a JSON-encoded
- # string, with a newline character signalling the end of a packet. See the
+ # string, with a newline character signaling the end of a packet. See the
# specs for Cucumber::WireSupport::WirePacket for more details.
#
# These messages are described in detail below, with examples.
@@ -0,0 +1,57 @@
+@wire
+Feature: Wire Protocol with ERB
+ In order to be allow Cucumber to touch my app in intimate places
+ As a developer on server with multiple users
+ I want to be able to configure which port my wire server runs on
+ So that I can avoid port conflicts
+
+ Background:
+ Given a standard Cucumber project directory structure
+ And a file named "features/wired.feature" with:
+ """
+ Feature: High strung
+ Scenario: Wired
+ Given we're all wired
+
+ """
+
+ Scenario: ERB is used in the wire file which references an environment variable that is not set
+ Given a file named "features/step_definitions/server.wire" with:
+ """
+ host: localhost
+ port: <%= ENV['PORT'] || 12345 %>
+ """
+ And there is a wire server running on port 12345 which understands the following protocol:
+ | request | response |
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
+ When I run cucumber --dry-run --no-snippets -f progress
+ And it should pass with
+ """
+ U
+
+ 1 scenario (1 undefined)
+ 1 step (1 undefined)
+
+ """
+
+
+ Scenario: ERB is used in the wire file which references an environment variable
+ Given I have environment variable PORT set to "16816"
+ And a file named "features/step_definitions/server.wire" with:
+ """
+ host: localhost
+ port: <%= ENV['PORT'] || 12345 %>
+ """
+ And there is a wire server running on port 16816 which understands the following protocol:
+ | request | response |
+ | ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[]] |
+ When I run cucumber --dry-run --no-snippets -f progress
+ And it should pass with
+ """
+ U
+
+ 1 scenario (1 undefined)
+ 1 step (1 undefined)
+
+ """
+
@@ -1,12 +1,13 @@
require 'yaml'
+require 'erb'
module Cucumber
module WireSupport
class Configuration
attr_reader :host, :port
def initialize(wire_file)
- params = YAML.load_file(wire_file)
+ params = YAML.load(ERB.new(File.read(wire_file)).result)
@host = params['host']
@port = params['port']
@timeouts = default_timeouts.merge(params['timeout'] || {})

0 comments on commit 0c11d20

Please sign in to comment.