cucumber 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +44 -1
- data/Manifest.txt +11 -1
- data/bin/cucumber +11 -1
- data/examples/cs/Rakefile +1 -1
- data/examples/cs/features/addition.feature +5 -5
- data/examples/cs/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/dos_line_endings/Rakefile +1 -1
- data/examples/i18n/ar/Rakefile +1 -1
- data/examples/i18n/bg/Rakefile +1 -1
- data/examples/i18n/cat/Rakefile +6 -0
- data/examples/i18n/cat/features/step_definitons/calculator_steps.rb +21 -0
- data/examples/i18n/cat/features/suma.feature +16 -0
- data/examples/i18n/cat/lib/calculadora.rb +16 -0
- data/examples/i18n/da/Rakefile +1 -1
- data/examples/i18n/de/Rakefile +1 -1
- data/examples/i18n/en-lol/Rakefile +1 -1
- data/examples/i18n/en/Rakefile +1 -1
- data/examples/i18n/es/Rakefile +1 -1
- data/examples/i18n/et/Rakefile +1 -1
- data/examples/i18n/fi/Rakefile +1 -1
- data/examples/i18n/fr/Rakefile +1 -1
- data/examples/i18n/he/Rakefile +1 -1
- data/examples/i18n/hu/Rakefile +1 -1
- data/examples/i18n/id/Rakefile +1 -1
- data/examples/i18n/it/Rakefile +1 -1
- data/examples/i18n/ja/Rakefile +1 -1
- data/examples/i18n/ko/Rakefile +1 -1
- data/examples/i18n/lt/Rakefile +1 -1
- data/examples/i18n/lt/features/addition.feature +2 -3
- data/examples/i18n/lv/Rakefile +1 -1
- data/examples/i18n/no/Rakefile +1 -1
- data/examples/i18n/pt/Rakefile +1 -1
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +3 -7
- data/examples/i18n/pt/features/support/env.rb +6 -0
- data/examples/i18n/ro/Rakefile +1 -1
- data/examples/i18n/ru/Rakefile +1 -1
- data/examples/i18n/se/Rakefile +1 -1
- data/examples/i18n/sk/Rakefile +1 -1
- data/examples/i18n/zh-CN/Rakefile +1 -1
- data/examples/i18n/zh-TW/Rakefile +1 -1
- data/examples/java/README.textile +2 -6
- data/examples/java/build.xml +26 -0
- data/examples/java/features/step_definitons/hello_steps.rb +0 -2
- data/examples/junit/features/one_passing_one_failing.feature +8 -0
- data/examples/junit/features/pending.feature +5 -0
- data/examples/junit/features/step_definitions/steps.rb +11 -0
- data/examples/selenium/Rakefile +1 -1
- data/examples/selenium_webrat/Rakefile +1 -1
- data/examples/sinatra/Rakefile +1 -1
- data/examples/test_unit/Rakefile +1 -1
- data/examples/tickets/Rakefile +3 -3
- data/examples/tickets/features/177/1.feature +29 -29
- data/examples/tickets/features/177/2.feature +20 -20
- data/examples/watir/Rakefile +1 -1
- data/features/junit_formatter.feature +59 -0
- data/features/rake_task.feature +4 -4
- data/features/step_definitions/cucumber_steps.rb +25 -2
- data/gem_tasks/features.rake +5 -1
- data/lib/cucumber.rb +2 -2
- data/lib/cucumber/cli/configuration.rb +28 -32
- data/lib/cucumber/cli/main.rb +0 -2
- data/lib/cucumber/core_ext/proc.rb +9 -13
- data/lib/cucumber/formatter.rb +1 -1
- data/lib/cucumber/formatter/html.rb +1 -0
- data/lib/cucumber/formatter/junit.rb +78 -0
- data/lib/cucumber/languages.yml +36 -4
- data/lib/cucumber/parser/feature.rb +10 -6
- data/lib/cucumber/parser/feature.tt +18 -14
- data/lib/cucumber/rake/task.rb +92 -24
- data/lib/cucumber/step_mother.rb +3 -0
- data/lib/cucumber/version.rb +1 -1
- data/rails_generators/cucumber/templates/cucumber.rake +2 -1
- data/spec/cucumber/cli/configuration_spec.rb +9 -18
- metadata +13 -3
- data/examples/java/Rakefile +0 -12
data/examples/i18n/ro/Rakefile
CHANGED
data/examples/i18n/ru/Rakefile
CHANGED
data/examples/i18n/se/Rakefile
CHANGED
data/examples/i18n/sk/Rakefile
CHANGED
@@ -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
|
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
|
-
|
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>
|
data/examples/selenium/Rakefile
CHANGED
data/examples/sinatra/Rakefile
CHANGED
data/examples/test_unit/Rakefile
CHANGED
data/examples/tickets/Rakefile
CHANGED
@@ -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 =
|
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 =
|
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 =
|
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
|
data/examples/watir/Rakefile
CHANGED
@@ -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
|
+
|
data/features/rake_task.feature
CHANGED
@@ -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 =
|
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 =
|
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
|
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
|