Skip to content

Commit

Permalink
add cucumber support
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Jan 14, 2014
1 parent 8ccbc01 commit cf82676
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Gemfile.lock
@@ -1,13 +1,24 @@
PATH
remote: .
specs:
test-queue (0.1.3)
test-queue (0.2.0)

GEM
remote: https://rubygems.org/
specs:
builder (3.2.2)
cucumber (1.3.10)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.0.2)
diff-lcs (1.2.4)
gherkin (2.12.2)
multi_json (~> 1.3)
minitest (4.7.3)
multi_json (1.8.4)
multi_test (0.0.3)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
Expand All @@ -21,6 +32,7 @@ PLATFORMS
ruby

DEPENDENCIES
cucumber (~> 1.3.10)
minitest (~> 4.7.3)
rspec (~> 2.13)
test-queue!
4 changes: 4 additions & 0 deletions bin/cucumber-queue
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require 'test_queue'
require 'test_queue/runner/cucumber'
TestQueue::Runner::Cucumber.new.execute
5 changes: 5 additions & 0 deletions features/bad.feature
@@ -0,0 +1,5 @@
Feature: bad
Scenario: failure
Given a
When bad
Then c
25 changes: 25 additions & 0 deletions features/sample.feature
@@ -0,0 +1,25 @@
Feature: Foobar
Scenario: Bar
Given a
When b
Then c
Scenario: Baz
Given a
When b
Then c
Scenario: Bam
Given a
When b
Then c
Scenario: Car
Given a
When b
Then c
Scenario: Caz
Given a
When b
Then c
Scenario: Cam
Given a
When b
Then c
29 changes: 29 additions & 0 deletions features/sample2.feature
@@ -0,0 +1,29 @@
Feature: Foobar2
Scenario: Bar
Given a
When b
Then c
Scenario: Baz
Given a
When b
Then c
Scenario: Bam
Given a
When b
Then c
Scenario: Car
Given a
When b
Then c
Scenario: Caz
Given a
When b
Then c
Scenario: Cam
Given a
When b
Then c
Scenario: failure
Given a
When bad
Then c
15 changes: 15 additions & 0 deletions features/step_definitions/common.rb
@@ -0,0 +1,15 @@
Given(/^a$/) do
sleep 0.10
end

When(/^b$/) do
sleep 0.25
end

When(/^bad$/) do
1.should == 0
end

Then(/^c$/) do
1.should == 1
end
48 changes: 48 additions & 0 deletions lib/test_queue/runner/cucumber.rb
@@ -0,0 +1,48 @@
require 'cucumber'
require 'cucumber/rspec/disable_option_parser'
require 'cucumber/cli/main'

module Cucumber
module Ast
class Features
attr_accessor :features
end

class Feature
def to_s
title
end
end
end
end

module TestQueue
class Runner
class Cucumber < Runner
def initialize
@cli = ::Cucumber::Cli::Main.new(ARGV.dup)
@runtime = ::Cucumber::Runtime.new(@cli.configuration)
@features_loader = @runtime.send(:features)
features = @features_loader.features.sort_by{ |s| -(stats[s.to_s] || 0) }
super(features)
end

def run_worker(iterator)
@features_loader.features = iterator
@cli.execute!(@runtime)
end

def summarize_worker(worker)
worker.stats.each do |s, val|
stats[s.to_s] = val
end

output = worker.output.gsub(/\e\[\d+./,'')
summary = output.split("\n").grep(/^\d+ (scenarios?|steps?)/).first
failures = output.scan(/^Failing Scenarios:\n(.*)\n\d+ scenarios?/m).join("\n")

[ summary, failures ]
end
end
end
end
1 change: 1 addition & 0 deletions test-queue.gemspec
Expand Up @@ -17,6 +17,7 @@ spec = Gem::Specification.new do |s|

s.add_development_dependency 'rspec', '~> 2.13'
s.add_development_dependency 'minitest', '~> 4.7.3'
s.add_development_dependency 'cucumber', '~> 1.3.10'

s.files = `git ls-files`.split("\n")
end
1 change: 1 addition & 0 deletions test.sh
Expand Up @@ -6,3 +6,4 @@ export TEST_QUEUE_WORKERS=2 TEST_QUEUE_VERBOSE=1
bundle exec minitest-queue ./test/*_minispec.rb
bundle exec minitest-queue ./test/*_test.rb
bundle exec rspec-queue test
bundle exec cucumber-queue

0 comments on commit cf82676

Please sign in to comment.