Skip to content

Commit

Permalink
test for issue cucumber#117
Browse files Browse the repository at this point in the history
  • Loading branch information
iromeo committed Aug 11, 2011
1 parent 13df351 commit 6c09406
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
63 changes: 63 additions & 0 deletions features/issue_117.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@spork @my_issues
Feature: DRb Server Integration: Regression test for Issue #117
To prevent waiting for Rails and other large Ruby applications to load their environments
for each feature run Cucumber ships with a DRb client that can speak to a server which
loads up the environment only once.

This regression test highlights bug related to DRb server arguments processing, for more
details see https://github.com/cucumber/cucumber/issues/117

Background: App with Spork support
Spork is a gem that has a DRb server and the scenarios below illustrate how to use it.
However, any DRb server that adheres to the protocol that the client expects would work.

Given a directory without standard Cucumber project directory structure
And a file named "features/support/env.rb" with:
"""
require 'rubygems'
require 'spork'
Spork.prefork do
puts "I'm loading all the heavy stuff..."
end
Spork.each_run do
puts "I'm loading the stuff just for this run..."
end
"""
And a file named "config/cucumber.yml" with:
"""
<%
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: --drb <%= std_opts %> features
"""
And a file named "features/sample.feature" with:
"""
# language: en
Feature: Sample
Scenario: this is a test
Given I am just testing stuff
"""
And a file named "features/step_definitions/all_your_steps_are_belong_to_us.rb" with:
"""
Given /^I am just testing stuff$/ do
# no-op
end
"""

Scenario: Single feature passing with '-r features' option
Given I am running spork in the background
When I run cucumber "features/sample.feature -r features --tags ~@wip"
And it should pass with:
"""
1 step (1 passed)
"""

Scenario: Single feature passing without '-r features' option
Given I am running spork in the background
When I run cucumber "features/sample.feature --tags ~@wip"
And it should pass with:
"""
1 step (1 passed)
"""
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,35 @@ def assert_undefined_scenario
def failed_output
"failed"
end

def run_spork_in_background(port = nil)
require 'spork'

pid = fork
in_current_dir do
if pid
background_jobs << pid
else
# STDOUT.close
# STDERR.close
port_arg = port ? "-p #{port}" : ''
cmd = "#{Cucumber::RUBY_BINARY} -I #{Cucumber::LIBDIR} #{Spork::BINARY} cuc #{port_arg}"
exec cmd
end
end
sleep 1.0
end

def background_jobs
@background_jobs ||= []
end

def terminate_background_jobs
background_jobs.each do |pid|
Process.kill(Signal.list['TERM'], pid)
end
end

end

World(CucumberRubyMappings)
3 changes: 3 additions & 0 deletions features/step_definitions/drb_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Given /^I am running spork in the background$/ do
run_spork_in_background
end
4 changes: 4 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ def unrandom(out)
# Set a longer timeout for aruba
@aruba_timeout_seconds = 15
end

After do
terminate_background_jobs
end

0 comments on commit 6c09406

Please sign in to comment.