cucumber 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/History.txt +44 -1
  2. data/Manifest.txt +11 -1
  3. data/bin/cucumber +11 -1
  4. data/examples/cs/Rakefile +1 -1
  5. data/examples/cs/features/addition.feature +5 -5
  6. data/examples/cs/features/step_definitons/calculator_steps.rb +2 -2
  7. data/examples/dos_line_endings/Rakefile +1 -1
  8. data/examples/i18n/ar/Rakefile +1 -1
  9. data/examples/i18n/bg/Rakefile +1 -1
  10. data/examples/i18n/cat/Rakefile +6 -0
  11. data/examples/i18n/cat/features/step_definitons/calculator_steps.rb +21 -0
  12. data/examples/i18n/cat/features/suma.feature +16 -0
  13. data/examples/i18n/cat/lib/calculadora.rb +16 -0
  14. data/examples/i18n/da/Rakefile +1 -1
  15. data/examples/i18n/de/Rakefile +1 -1
  16. data/examples/i18n/en-lol/Rakefile +1 -1
  17. data/examples/i18n/en/Rakefile +1 -1
  18. data/examples/i18n/es/Rakefile +1 -1
  19. data/examples/i18n/et/Rakefile +1 -1
  20. data/examples/i18n/fi/Rakefile +1 -1
  21. data/examples/i18n/fr/Rakefile +1 -1
  22. data/examples/i18n/he/Rakefile +1 -1
  23. data/examples/i18n/hu/Rakefile +1 -1
  24. data/examples/i18n/id/Rakefile +1 -1
  25. data/examples/i18n/it/Rakefile +1 -1
  26. data/examples/i18n/ja/Rakefile +1 -1
  27. data/examples/i18n/ko/Rakefile +1 -1
  28. data/examples/i18n/lt/Rakefile +1 -1
  29. data/examples/i18n/lt/features/addition.feature +2 -3
  30. data/examples/i18n/lv/Rakefile +1 -1
  31. data/examples/i18n/no/Rakefile +1 -1
  32. data/examples/i18n/pt/Rakefile +1 -1
  33. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +3 -7
  34. data/examples/i18n/pt/features/support/env.rb +6 -0
  35. data/examples/i18n/ro/Rakefile +1 -1
  36. data/examples/i18n/ru/Rakefile +1 -1
  37. data/examples/i18n/se/Rakefile +1 -1
  38. data/examples/i18n/sk/Rakefile +1 -1
  39. data/examples/i18n/zh-CN/Rakefile +1 -1
  40. data/examples/i18n/zh-TW/Rakefile +1 -1
  41. data/examples/java/README.textile +2 -6
  42. data/examples/java/build.xml +26 -0
  43. data/examples/java/features/step_definitons/hello_steps.rb +0 -2
  44. data/examples/junit/features/one_passing_one_failing.feature +8 -0
  45. data/examples/junit/features/pending.feature +5 -0
  46. data/examples/junit/features/step_definitions/steps.rb +11 -0
  47. data/examples/selenium/Rakefile +1 -1
  48. data/examples/selenium_webrat/Rakefile +1 -1
  49. data/examples/sinatra/Rakefile +1 -1
  50. data/examples/test_unit/Rakefile +1 -1
  51. data/examples/tickets/Rakefile +3 -3
  52. data/examples/tickets/features/177/1.feature +29 -29
  53. data/examples/tickets/features/177/2.feature +20 -20
  54. data/examples/watir/Rakefile +1 -1
  55. data/features/junit_formatter.feature +59 -0
  56. data/features/rake_task.feature +4 -4
  57. data/features/step_definitions/cucumber_steps.rb +25 -2
  58. data/gem_tasks/features.rake +5 -1
  59. data/lib/cucumber.rb +2 -2
  60. data/lib/cucumber/cli/configuration.rb +28 -32
  61. data/lib/cucumber/cli/main.rb +0 -2
  62. data/lib/cucumber/core_ext/proc.rb +9 -13
  63. data/lib/cucumber/formatter.rb +1 -1
  64. data/lib/cucumber/formatter/html.rb +1 -0
  65. data/lib/cucumber/formatter/junit.rb +78 -0
  66. data/lib/cucumber/languages.yml +36 -4
  67. data/lib/cucumber/parser/feature.rb +10 -6
  68. data/lib/cucumber/parser/feature.tt +18 -14
  69. data/lib/cucumber/rake/task.rb +92 -24
  70. data/lib/cucumber/step_mother.rb +3 -0
  71. data/lib/cucumber/version.rb +1 -1
  72. data/rails_generators/cucumber/templates/cucumber.rake +2 -1
  73. data/spec/cucumber/cli/configuration_spec.rb +9 -18
  74. metadata +13 -3
  75. data/examples/java/Rakefile +0 -12
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--language ro"
5
+ t.cucumber_opts = %w{--language ro}
6
6
  end
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--language ru"
5
+ t.cucumber_opts = %w{--language ru}
6
6
  end
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--language se"
5
+ t.cucumber_opts = %w{--language se}
6
6
  end
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--language sk"
5
+ t.cucumber_opts = %w{--language sk}
6
6
  end
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--language zh-CN"
5
+ t.cucumber_opts = %w{--language zh-CN}
6
6
  end
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--language zh-TW"
5
+ t.cucumber_opts = %w{--language zh-TW}
6
6
  end
@@ -1,11 +1,10 @@
1
1
  h1. Using Cucumber with Java
2
2
 
3
3
  This directory contains code to demonstrate how Cucumber can be used to develop Java code.
4
- You need JRuby 1.1.3 or higher installed and JRuby's bin directory on your PATH.
5
4
 
6
5
  h2. Installing required gems
7
6
 
8
- jruby -S gem install aslakhellesoy-cucumber
7
+ jruby -S gem install cucumber
9
8
  jruby -S gem install diff-lcs
10
9
 
11
10
  h2. Running the scenarios
@@ -13,10 +12,7 @@ h2. Running the scenarios
13
12
  Open a shell in this directory (java) and execute the following command:
14
13
 
15
14
  <pre><code>
16
- jruby -S rake features
15
+ ant
17
16
  </code></pre>
18
17
 
19
- This will compile the java code and package it in a jar file, and then run Cucumber against
20
- that code.
21
-
22
18
  There is a deliberate error. See if you can fix it!
@@ -0,0 +1,26 @@
1
+ <project name="Cucumber Demo" default="cucumber" basedir=".">
2
+ <target name ="compile" description="Compile classes">
3
+ <mkdir dir="build" />
4
+ <javac srcdir="src" destdir="build" />
5
+ </target>
6
+
7
+ <target name="cucumber" depends="compile" description="Run Cucumber">
8
+ <property environment="ENV" />
9
+ <java classname="org.jruby.Main" fork="true" failonerror="true">
10
+ <classpath>
11
+ <pathelement path="${ENV.JRUBY_HOME}/lib/jruby.jar"/>
12
+ <pathelement path="build"/>
13
+ </classpath>
14
+ <jvmarg value="-Djruby.home=${ENV.JRUBY_HOME}"/>
15
+ <arg value="-S"/>
16
+ <arg value="cucumber"/>
17
+ <arg value="--format"/>
18
+ <arg value="pretty"/>
19
+ <arg value="--format"/>
20
+ <arg value="junit"/>
21
+ <arg value="--out"/>
22
+ <arg value="build"/>
23
+ <arg value="features"/>
24
+ </java>
25
+ </target>
26
+ </project>
@@ -1,6 +1,4 @@
1
1
  require 'spec/expectations' # so we can call .should
2
- $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../src') # so the jar is found
3
- require 'cucumber_demo' # puts the jar on the classpath
4
2
  include_class 'cucumber.demo.Hello'
5
3
 
6
4
  Given /my name is (\w+)/ do |name|
@@ -0,0 +1,8 @@
1
+ Feature: One passing scenario, one failing scenario
2
+
3
+ Scenario: Passing
4
+ Given a passing scenario
5
+
6
+ Scenario: Failing
7
+ Given a failing scenario
8
+
@@ -0,0 +1,5 @@
1
+ Feature: Pending step
2
+
3
+ Scenario: Pending
4
+ Given a pending step
5
+
@@ -0,0 +1,11 @@
1
+ Given /a passing scenario/ do
2
+ #does nothing
3
+ end
4
+
5
+ Given /a failing scenario/ do
6
+ fail
7
+ end
8
+
9
+ Given /a pending step/ do
10
+ pending
11
+ end
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--format pretty"
5
+ t.cucumber_opts = %w{--format pretty}
6
6
  end
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--format pretty"
5
+ t.cucumber_opts = %w{--format pretty}
6
6
  end
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--format pretty"
5
+ t.cucumber_opts = %w{--format pretty}
6
6
  end
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--format pretty"
5
+ t.cucumber_opts = %w{--format pretty}
6
6
  end
@@ -2,15 +2,15 @@ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new(:pretty) do |t|
5
- t.cucumber_opts = "--tags ~@intentional_failure --format pretty -q"
5
+ t.cucumber_opts = %w{--tags ~@intentional_failure --format pretty -q}
6
6
  end
7
7
 
8
8
  Cucumber::Rake::Task.new(:html) do |t|
9
- t.cucumber_opts = "--tags ~@intentional_failure --format html --out features.html"
9
+ t.cucumber_opts = %w{--tags ~@intentional_failure --format html --out features.html}
10
10
  end
11
11
 
12
12
  Cucumber::Rake::Task.new(:progress) do |t|
13
- t.cucumber_opts = "--tags ~@intentional_failure --format progress -i -s"
13
+ t.cucumber_opts = %w{--tags ~@intentional_failure --format progress -i -s}
14
14
  end
15
15
 
16
16
  task :default => [:pretty, :html, :progress]
@@ -1,29 +1,29 @@
1
- Users want to know that nobody can masquerade as them. We want to extend trust
2
- only to visitors who present the appropriate credentials. Everyone wants this
3
- identity verification to be as secure and convenient as possible.
4
-
5
- Feature: Logging in
6
- As an anonymous user with an account
7
- I want to log in to my account
8
- So that I can be myself
9
-
10
- #
11
- # Log in: get form
12
- #
13
- Scenario: Anonymous user can get a login form.
14
- Given I am logged out
15
- When I go to "/login"
16
- Then I should be at the "sessions/new" page
17
-
18
- #
19
- # Log in successfully, but don't remember me
20
- #
21
- Scenario: Anonymous user can log in
22
- Given an "activated" user named "reggie" exists
23
- And I am logged out
24
- When I go to "/login"
25
- And I fill in "Login" with "reggie"
26
- And I fill in "Password" with "password"
27
- And I press "Log in"
28
- Then I should be at the "dashboard/index" page
29
-
1
+ Users want to know that nobody can masquerade as them. We want to extend trust
2
+ only to visitors who present the appropriate credentials. Everyone wants this
3
+ identity verification to be as secure and convenient as possible.
4
+
5
+ Feature: Logging in
6
+ As an anonymous user with an account
7
+ I want to log in to my account
8
+ So that I can be myself
9
+
10
+ #
11
+ # Log in: get form
12
+ #
13
+ Scenario: Anonymous user can get a login form.
14
+ Given I am logged out
15
+ When I go to "/login"
16
+ Then I should be at the "sessions/new" page
17
+
18
+ #
19
+ # Log in successfully, but don't remember me
20
+ #
21
+ Scenario: Anonymous user can log in
22
+ Given an "activated" user named "reggie" exists
23
+ And I am logged out
24
+ When I go to "/login"
25
+ And I fill in "Login" with "reggie"
26
+ And I fill in "Password" with "password"
27
+ And I press "Log in"
28
+ Then I should be at the "dashboard/index" page
29
+
@@ -1,21 +1,21 @@
1
- Visitors may create an account, but for those who are not already in the
2
- system an someone must activate the account for them before it can be used.
3
-
4
- Feature: Activating an account
5
- As a registered, but not yet activated, user
6
- I want to be able to activate my account
7
- So that I can log in to the site
8
-
9
- Scenario: Not-yet-activated user can activate her account
10
- Given a registered user named 'Reggie' # need to rewrite
11
- # And the user has activation_code: 'activate_me', activated_at: nil!
12
- # And we try hard to remember the user's updated_at, and created_at
13
- # When she goes to /activate/activate_me
14
- # Then she should be redirected to 'login'
15
- # When she follows that redirect!
16
- # Then she should see a notice message 'Signup complete!'
17
- # And a user with login: 'reggie' should exist
18
- # And the user should have login: 'reggie', and email: 'registered@example.com'
19
- # And the user's activation_code should be nil
20
- # And the user's activated_at should not be nil
1
+ Visitors may create an account, but for those who are not already in the
2
+ system an someone must activate the account for them before it can be used.
3
+
4
+ Feature: Activating an account
5
+ As a registered, but not yet activated, user
6
+ I want to be able to activate my account
7
+ So that I can log in to the site
8
+
9
+ Scenario: Not-yet-activated user can activate her account
10
+ Given a registered user named 'Reggie' # need to rewrite
11
+ # And the user has activation_code: 'activate_me', activated_at: nil!
12
+ # And we try hard to remember the user's updated_at, and created_at
13
+ # When she goes to /activate/activate_me
14
+ # Then she should be redirected to 'login'
15
+ # When she follows that redirect!
16
+ # Then she should see a notice message 'Signup complete!'
17
+ # And a user with login: 'reggie' should exist
18
+ # And the user should have login: 'reggie', and email: 'registered@example.com'
19
+ # And the user's activation_code should be nil
20
+ # And the user's activated_at should not be nil
21
21
  # And she should not be logged in
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = "--format pretty"
5
+ t.cucumber_opts = %w{--format pretty}
6
6
  end
@@ -0,0 +1,59 @@
1
+ Feature: JUnit output formatter
2
+ In order for developers to create test reports with ant
3
+ Cucumber should be able to output JUnit xml files
4
+
5
+ Background:
6
+ Given I am in junit
7
+ And the tmp directory is empty
8
+
9
+ Scenario: one feature, one passing scenario, one failing scenario
10
+ When I run cucumber --format junit --out tmp/ features/one_passing_one_failing.feature
11
+ Then it should fail with
12
+ """
13
+
14
+ """
15
+ And "examples/junit/tmp/TEST-One_passing_scenario__one_failing_scenario.xml" should contain XML
16
+ """
17
+ <?xml version="1.0" encoding="UTF-8"?>
18
+ <testsuite errors="0" tests="2" name="One passing scenario, one failing scenario" failures="1">
19
+ <testcase name="Given a passing scenario" classname="One passing scenario, one failing scenario.Passing">
20
+ </testcase>
21
+ <testcase name="Given a failing scenario" classname="One passing scenario, one failing scenario.Failing">
22
+ <failure message="Given a failing scenario">
23
+ (RuntimeError)
24
+ ./features/step_definitions/steps.rb:6:in `/a failing scenario/'
25
+ features/one_passing_one_failing.feature:7:in `Given a failing scenario' </failure>
26
+ </testcase>
27
+ </testsuite>
28
+
29
+ """
30
+ Scenario: pending step
31
+ When I run cucumber --format junit --out tmp/ features/pending.feature
32
+ Then it should pass with
33
+ """
34
+
35
+ """
36
+ And "examples/junit/tmp/TEST-Pending_step.xml" should contain XML
37
+ """
38
+ <?xml version="1.0" encoding="UTF-8"?>
39
+ <testsuite errors="0" tests="1" name="Pending step" failures="1">
40
+ <testcase name="Given a pending step" classname="Pending step.Pending">
41
+ <failure message="Given a pending step">
42
+ TODO (Cucumber::Pending)
43
+ ./features/step_definitions/steps.rb:10:in `/a pending step/'
44
+ features/pending.feature:4:in `Given a pending step' </failure>
45
+ </testcase>
46
+ </testsuite>
47
+
48
+ """
49
+
50
+ Scenario: run all features
51
+ When I run cucumber --format junit --out tmp/ features
52
+ Then it should fail with
53
+ """
54
+
55
+ """
56
+ And "examples/junit/tmp/TEST-One_passing_scenario__one_failing_scenario.xml" should exist
57
+ And "examples/junit/tmp/TEST-Pending_step.xml" should exist
58
+
59
+
@@ -47,7 +47,7 @@ Feature: Rake task
47
47
  Scenario: rake task with a defined profile and cucumber_opts
48
48
  Given the following profile is defined:
49
49
  """
50
- bar: features/missing_step_definitions.feature:3
50
+ bar: ['features/missing_step_definitions.feature:3']
51
51
  """
52
52
  And a file named "Rakefile" with:
53
53
  """
@@ -56,7 +56,7 @@ Feature: Rake task
56
56
 
57
57
  Cucumber::Rake::Task.new(:features) do |t|
58
58
  t.profile = "bar"
59
- t.cucumber_opts = "--quiet --no-color"
59
+ t.cucumber_opts = %w{--quiet --no-color}
60
60
  end
61
61
  """
62
62
  When I run rake features
@@ -82,7 +82,7 @@ Feature: Rake task
82
82
  """
83
83
  Given the following profile is defined:
84
84
  """
85
- baz: --quiet --no-color
85
+ baz: ['--quiet', '--no-color']
86
86
  """
87
87
  And a file named "Rakefile" with:
88
88
  """
@@ -138,7 +138,7 @@ Feature: Rake task
138
138
 
139
139
  Cucumber::Rake::Task.new(:features) do |t|
140
140
  t.profile = "no_bomb"
141
- t.cucumber_opts = "--quiet --no-color"
141
+ t.cucumber_opts = %w{--quiet --no-color}
142
142
  end
143
143
  """
144
144
 
@@ -1,3 +1,5 @@
1
+ require 'tempfile'
2
+
1
3
  Given /^I am in (.*)$/ do |example_dir_relative_path|
2
4
  @current_dir = examples_dir(example_dir_relative_path)
3
5
  end
@@ -10,6 +12,13 @@ Given /^a standard Cucumber project directory structure$/ do
10
12
  end
11
13
  end
12
14
 
15
+ Given /^the (.*) directory is empty$/ do |directory|
16
+ in_current_dir do
17
+ FileUtils.remove_dir(directory) rescue nil
18
+ FileUtils.mkdir 'tmp'
19
+ end
20
+ end
21
+
13
22
  Given /^a file named "([^\"]*)"$/ do |file_name|
14
23
  create_file(file_name, '')
15
24
  end
@@ -27,14 +36,16 @@ When /^I run cucumber (.*)$/ do |cucumber_opts|
27
36
  end
28
37
 
29
38
  When /^I run rake (.*)$/ do |rake_opts|
30
- run "rake #{rake_opts}"
39
+ run "rake #{rake_opts} --trace"
31
40
  end
32
41
 
33
42
  Then /^it should (fail|pass)$/ do |success|
34
43
  if success == 'fail'
35
44
  last_exit_status.should_not == 0
36
45
  else
37
- last_exit_status.should == 0
46
+ if last_exit_status != 0
47
+ raise "Failed with exit status #{last_exit_status}\nSTDOUT:\n#{last_stdout}\nSTDERR:\n#{last_stderr}"
48
+ end
38
49
  end
39
50
  end
40
51
 
@@ -51,6 +62,18 @@ Then /^the output should not contain$/ do |text|
51
62
  last_stdout.should_not include(text)
52
63
  end
53
64
 
65
+ # http://diffxml.sourceforge.net/
66
+ Then /^"(.*)" should contain XML$/ do |file, xml|
67
+ t = Tempfile.new('cucumber-junit')
68
+ t.write(xml)
69
+ t.flush
70
+ t.close
71
+ diff = `diffxml #{t.path} #{file}`
72
+ if diff =~ /<delta>/m
73
+ raise diff + "\nXML WAS:\n" + IO.read(file)
74
+ end
75
+ end
76
+
54
77
  Then /^"(.*)" should contain$/ do |file, text|
55
78
  IO.read(file).should == text
56
79
  end