Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/aslakhellesoy/cucumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Wilk committed Nov 24, 2008
2 parents af1eec1 + 6a874fb commit 3ecb396
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 11 deletions.
1 change: 1 addition & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ You can now run multiple features at specific lines numbers like this:
This will run foo.feature at line 15 and bar.feature at line 6, 45 and 111.

=== New features
* Yield existing world object to World block (#87 Aslak Hellesøy)
* AUTOFEATURE=tRue works (case insensitive) (Aslak Hellesøy)
* Support for .NET via IronRuby. See examples for details. (Aslak Hellesøy)
* Lithuanian translation (sauliusgrigaitis)
Expand Down
3 changes: 3 additions & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ examples/java/src/cucumber/demo/Hello.java
examples/selenium/Rakefile
examples/selenium/features/search.feature
examples/selenium/features/step_definitons/stories_steps.rb
examples/test_unit/Rakefile
examples/test_unit/features/step_definitions/test_unit_steps.rb
examples/test_unit/features/test_unit.feature
examples/tickets/Rakefile
examples/tickets/cucumber.yml
examples/tickets/features/step_definitons/tickets_steps.rb
Expand Down
3 changes: 2 additions & 1 deletion config/hoe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def extra_deps
# == Optional
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
p.extra_deps = [ ['term-ansicolor', '>= 1.0.3'], ['treetop', '>= 1.2.4'], ['rspec', '>= 1.1.5'], ['diff-lcs', '>= 1.1.2'] ]
p.extra_deps = [ ['term-ansicolor', '>= 1.0.3'], ['treetop', '>= 1.2.4'], ['diff-lcs', '>= 1.1.2'] ]
p.extra_dev_deps = [ ['rspec', '>= 1.1.11'] ]

#p.spec_extras = {} # A hash of extra values to set in the gemspec.

Expand Down
10 changes: 5 additions & 5 deletions cucumber.gemspec

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions examples/test_unit/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/rake/task'

Cucumber::Rake::Task.new do |t|
t.cucumber_opts = "--format pretty"
end
15 changes: 15 additions & 0 deletions examples/test_unit/features/step_definitions/test_unit_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'test/unit/assertions'
World do |o|
o.extend(Test::Unit::Assertions)
o
end

Given /^(\w+) = (\w+)$/ do |var, value|
instance_variable_set("@#{var}", value)
end

Then /^I can assert that (\w+) == (\w+)$/ do |var_a, var_b|
a = instance_variable_get("@#{var_a}")
b = instance_variable_get("@#{var_b}")
assert_equal(a, b)
end
9 changes: 9 additions & 0 deletions examples/test_unit/features/test_unit.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Test::Unit
In order to please people who like Test::Unit
As a Cucumber user
I want to be able to use assert* in my step definitions

Scenario: assert_equal
Given x = 5
And y = 5
Then I can assert that x == y
15 changes: 10 additions & 5 deletions lib/cucumber/executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class Executor
attr_writer :scenario_names, :lines_for_features

def initialize(step_mother)
@world_proc = lambda do
Object.new
end
@world_procs = []
@before_scenario_procs = []
@after_scenario_procs = []
@after_step_procs = []
Expand All @@ -20,7 +18,7 @@ def initialize(step_mother)
end

def register_world_proc(&proc)
@world_proc = proc
@world_procs << proc
end

def register_before_scenario_proc(&proc)
Expand Down Expand Up @@ -80,7 +78,7 @@ def execute_scenario(scenario)
@error = nil
@pending = nil

@world = @world_proc.call
@world = create_world
@world.extend(Spec::Matchers) if defined?(Spec::Matchers)
define_step_call_methods(@world)

Expand Down Expand Up @@ -181,5 +179,12 @@ def lines_defined_for_current_feature?
@lines_for_features && !@lines_for_features[@feature_file].nil? && !@lines_for_features[@feature_file].empty?
end

def create_world
world = Object.new
@world_procs.each do |world_proc|
world = world_proc.call(world)
end
world
end
end
end
26 changes: 26 additions & 0 deletions spec/cucumber/executor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,32 @@ def mock_scenario(stubs = {})
})
end

describe "creating a world" do
module DoitExtension
def doit
"dunit"
end
end

module BeatitExtension
def beatit
"beatenit"
end
end

it "should yield an Object to the world proc" do
@executor.register_world_proc do |world|
world.extend(DoitExtension)
end
@executor.register_world_proc do |world|
world.extend(BeatitExtension)
end
world = @executor.create_world
world.doit.should == "dunit"
world.beatit.should == "beatenit"
end
end

describe "visiting feature" do

it "should set the feature file being visited" do
Expand Down

0 comments on commit 3ecb396

Please sign in to comment.