kosmas58-cucumber 0.2.3.3 → 0.3.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +203 -3
- data/Manifest.txt +0 -346
- data/README.txt +0 -21
- data/Rakefile +3 -1
- data/bin/cucumber +12 -1
- data/config/hoe.rb +6 -5
- data/cucumber.yml +3 -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/dos_line_endings/features/dos_line_endings.feature +9 -9
- data/examples/i18n/Rakefile +1 -1
- data/examples/i18n/ar/Rakefile +1 -1
- data/examples/i18n/bg/Rakefile +6 -0
- data/examples/i18n/bg/features/addition.feature +11 -0
- data/examples/i18n/bg/features/consecutive_calculations.feature +18 -0
- data/examples/i18n/bg/features/division.feature +16 -0
- data/examples/i18n/bg/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/bg/features/support/env.rb +6 -0
- data/examples/i18n/bg/features/support/world.rb +8 -0
- data/examples/i18n/bg/lib/calculator.rb +24 -0
- 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/Rakefile +1 -1
- data/examples/i18n/en-lol/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/fr/features/addition.feature +4 -4
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +1 -1
- data/examples/i18n/fr/lib/calculatrice.rb +1 -1
- data/examples/i18n/he/Rakefile +6 -0
- data/examples/i18n/he/features/addition.feature +16 -0
- data/examples/i18n/he/features/division.feature +9 -0
- data/examples/i18n/he/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/he/lib/calculator.rb +14 -0
- data/examples/i18n/hu/Rakefile +6 -0
- data/examples/i18n/hu/features/addition.feature +16 -0
- data/examples/i18n/hu/features/division.feature +9 -0
- data/examples/i18n/hu/features/step_definitons/calculator_steps.rb +25 -0
- data/examples/i18n/hu/lib/calculator.rb +14 -0
- data/examples/i18n/id/Rakefile +1 -1
- data/examples/i18n/it/Rakefile +1 -1
- data/examples/i18n/ja/Rakefile +1 -1
- data/examples/i18n/ja/features/addition.feature +1 -1
- data/examples/i18n/ja/features/division.feature +1 -1
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +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 +6 -0
- data/examples/i18n/lv/features/addition.feature +16 -0
- data/examples/i18n/lv/features/division.feature +9 -0
- data/examples/i18n/lv/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/lv/lib/calculator.rb +14 -0
- data/examples/i18n/no/Rakefile +1 -1
- data/examples/i18n/pl/Rakefile +6 -0
- data/examples/i18n/pl/features/addition.feature +16 -0
- data/examples/i18n/pl/features/division.feature +9 -0
- data/examples/i18n/pl/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/pl/features/support/env.rb +6 -0
- data/examples/i18n/pl/lib/calculator.rb +14 -0
- 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 +33 -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/selenium_webrat/config.ru +0 -0
- data/examples/selenium_webrat/features/search.feature +1 -1
- data/examples/selenium_webrat/features/step_definitons/search_steps.rb +2 -2
- data/examples/selenium_webrat/features/support/env.rb +7 -3
- data/examples/self_test/features/background/background_tagged_before_on_outline.feature +12 -0
- data/examples/self_test/features/background/failing_background.feature +1 -0
- data/examples/self_test/features/background/passing_background.feature +2 -2
- data/examples/self_test/features/multiline_name.feature +27 -0
- data/examples/self_test/features/sample.feature +2 -0
- data/examples/self_test/features/search_sample.feature +32 -0
- data/examples/self_test/features/step_definitions/sample_steps.rb +11 -0
- data/examples/self_test/features/support/env.rb +17 -1
- data/examples/sinatra/Rakefile +1 -1
- data/examples/test_unit/Rakefile +1 -1
- data/examples/tickets/Rakefile +3 -3
- data/examples/tickets/features/229/tagged_hooks.feature +8 -0
- data/examples/tickets/features/229/tagged_hooks.rb +14 -0
- data/examples/tickets/features/236.feature +9 -9
- data/examples/tickets/features/272/hooks.feature +26 -0
- data/examples/tickets/features/272/hooks_steps.rb +53 -0
- data/examples/tickets/features/279/py_string_indent.feature +25 -0
- data/examples/tickets/features/279/py_string_indent.steps.rb +12 -0
- data/examples/tickets/features/279/wrong.feature_ +11 -0
- data/examples/tickets/features/301/filter_background_tagged_hooks.feature +6 -0
- data/examples/tickets/features/301/filter_background_tagged_hooks_steps.rb +12 -0
- data/examples/tickets/features/306/only_background.feature +4 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +0 -7
- data/examples/watir/Rakefile +1 -1
- data/examples/watir/features/search.feature +4 -1
- data/examples/watir/features/step_definitons/search_steps.rb +2 -4
- data/features/after_block_exceptions.feature +99 -0
- data/features/after_step_block_exceptions.feature +101 -0
- data/features/background.feature +105 -38
- data/features/cucumber_cli.feature +201 -64
- data/features/cucumber_cli_diff_disabled.feature +6 -4
- data/features/cucumber_cli_outlines.feature +60 -35
- data/features/custom_formatter.feature +3 -3
- data/features/exclude_files.feature +20 -0
- data/features/expand.feature +48 -0
- data/features/html_formatter/a.html +1632 -0
- data/features/html_formatter.feature +7 -0
- data/features/junit_formatter.feature +62 -0
- data/features/multiline_names.feature +43 -0
- data/features/rake_task.feature +150 -0
- data/features/report_called_undefined_steps.feature +4 -3
- data/features/snippet.feature +2 -3
- data/features/step_definitions/cucumber_steps.rb +98 -15
- data/features/support/env.rb +78 -3
- data/features/usage.feature +32 -19
- data/features/work_in_progress.feature +148 -0
- data/gem_tasks/deployment.rake +1 -1
- data/gem_tasks/rspec.rake +9 -2
- data/lib/cucumber/ast/background.rb +19 -7
- data/lib/cucumber/ast/comment.rb +4 -0
- data/lib/cucumber/ast/feature.rb +7 -1
- data/lib/cucumber/ast/feature_element.rb +24 -9
- data/lib/cucumber/ast/features.rb +4 -0
- data/lib/cucumber/ast/outline_table.rb +74 -4
- data/lib/cucumber/ast/py_string.rb +5 -1
- data/lib/cucumber/ast/scenario.rb +31 -7
- data/lib/cucumber/ast/scenario_outline.rb +17 -9
- data/lib/cucumber/ast/step.rb +8 -5
- data/lib/cucumber/ast/step_collection.rb +14 -1
- data/lib/cucumber/ast/step_invocation.rb +29 -15
- data/lib/cucumber/ast/table.rb +9 -1
- data/lib/cucumber/ast/tags.rb +9 -1
- data/lib/cucumber/ast/visitor.rb +6 -2
- data/lib/cucumber/cli/configuration.rb +134 -105
- data/lib/cucumber/cli/main.rb +35 -12
- data/lib/cucumber/core_ext/proc.rb +9 -13
- data/lib/cucumber/formatter/ansicolor.rb +1 -1
- data/lib/cucumber/formatter/console.rb +36 -14
- data/lib/cucumber/formatter/cucumber.css +31 -12
- data/lib/cucumber/formatter/duration.rb +10 -0
- data/lib/cucumber/formatter/html.rb +76 -16
- data/lib/cucumber/formatter/junit.rb +79 -0
- data/lib/cucumber/formatter/pretty.rb +19 -14
- data/lib/cucumber/formatter/profile.rb +1 -1
- data/lib/cucumber/formatter/progress.rb +12 -12
- data/lib/cucumber/formatter/rerun.rb +1 -0
- data/lib/cucumber/formatter/tag_cloud.rb +28 -0
- data/lib/cucumber/formatter/usage.rb +5 -5
- data/lib/cucumber/formatters/unicode.rb +5 -0
- data/lib/cucumber/languages.yml +111 -34
- data/lib/cucumber/parser/feature.rb +237 -36
- data/lib/cucumber/parser/feature.tt +68 -30
- data/lib/cucumber/parser/treetop_ext.rb +12 -3
- data/lib/cucumber/rails/rspec.rb +5 -3
- data/lib/cucumber/rails/world.rb +29 -4
- data/lib/cucumber/rake/task.rb +125 -37
- data/lib/cucumber/rspec_neuter.rb +23 -0
- data/lib/cucumber/step_definition.rb +5 -2
- data/lib/cucumber/step_match.rb +10 -6
- data/lib/cucumber/step_mother.rb +98 -26
- data/lib/cucumber/version.rb +3 -3
- data/lib/cucumber/world.rb +2 -2
- data/lib/cucumber.rb +7 -2
- data/rails_generators/cucumber/USAGE +0 -3
- data/rails_generators/cucumber/cucumber_generator.rb +51 -44
- data/rails_generators/cucumber/templates/cucumber.rake +5 -5
- data/rails_generators/cucumber/templates/cucumber_environment.rb +23 -0
- data/rails_generators/cucumber/templates/de/paths.rb +27 -0
- data/rails_generators/cucumber/templates/de/webrat_steps.rb +139 -0
- data/rails_generators/cucumber/templates/en/paths.rb +27 -0
- data/rails_generators/cucumber/templates/{webrat_steps.rb → en/webrat_steps.rb} +26 -2
- data/rails_generators/cucumber/templates/env.rb +1 -1
- data/rails_generators/feature/USAGE +0 -3
- data/rails_generators/feature/feature_generator.rb +6 -30
- data/spec/cucumber/ast/feature_element_spec.rb +40 -0
- data/spec/cucumber/ast/py_string_spec.rb +4 -0
- data/spec/cucumber/ast/table_spec.rb +21 -5
- data/spec/cucumber/ast/visitor_spec.rb +27 -0
- data/spec/cucumber/cli/configuration_spec.rb +75 -54
- data/spec/cucumber/cli/main_spec.rb +60 -154
- data/spec/cucumber/formatter/color_io_spec.rb +1 -0
- data/spec/cucumber/formatter/duration_spec.rb +22 -0
- data/spec/cucumber/formatter/progress_spec.rb +36 -0
- data/spec/cucumber/parser/feature_parser_spec.rb +102 -1
- data/spec/cucumber/step_mother_spec.rb +23 -5
- metadata +79 -22
- data/examples/java/Rakefile +0 -12
- data/examples/self_test/features/support/tag_count_formatter.rb +0 -25
- data/lib/cucumber/formatter.rb +0 -1
- data/rails_generators/cucumber/templates/paths.rb +0 -29
- data/spec/cucumber/formatters/profile_formatter_spec.rb +0 -198
@@ -1,73 +1,80 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'cucumber/version'
|
3
|
+
|
3
4
|
# This generator bootstraps a Rails project for use with Cucumber
|
4
|
-
class CucumberGenerator < Rails::Generator::Base
|
5
|
-
DEFAULT_SHEBANG = File.join(Config::CONFIG[
|
6
|
-
Config::CONFIG[
|
7
|
-
|
8
|
-
attr_accessor :framework
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
5
|
+
class CucumberGenerator < Rails::Generator::Base
|
6
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
7
|
+
Config::CONFIG['ruby_install_name'])
|
8
|
+
|
9
|
+
attr_accessor :framework
|
10
|
+
attr_accessor :language
|
11
|
+
|
12
|
+
def manifest
|
13
|
+
lang = self.language
|
14
|
+
|
15
|
+
record do |m|
|
16
|
+
m.directory "features/step_definitions"
|
17
|
+
m.template File.join(lang, "webrat_steps.rb"), "features/step_definitions/webrat_steps.rb"
|
18
|
+
m.template 'cucumber_environment.rb', 'config/environments/cucumber.rb',
|
19
|
+
:assigns => { :cucumber_version => ::Cucumber::VERSION::STRING }
|
20
|
+
|
21
|
+
m.gsub_file 'config/database.yml', /test:.*\n/, "test: &TEST\n"
|
22
|
+
m.gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *TEST"
|
23
|
+
|
21
24
|
m.directory "features/support"
|
22
|
-
m.
|
23
|
-
m.
|
24
|
-
|
25
|
-
m.file File.join(@language, "webrat_steps.rb"), File.join(@features_path, "step_definitions", "paths.rb")
|
26
|
-
m.file File.join(@language, "webrat_steps.rb"), File.join(@features_path, "step_definitions", "webrat_steps.rb")
|
27
|
-
else
|
28
|
-
m.file "webrat_steps.rb", File.join(@features_path, "step_definitions", "webrat_steps.rb")
|
29
|
-
m.file "paths.rb", "features/support/paths.rb"
|
30
|
-
end
|
31
|
-
|
25
|
+
m.template "env.rb", "features/support/env.rb"
|
26
|
+
m.file File.join(lang, "paths.rb"), "features/support/paths.rb"
|
27
|
+
|
32
28
|
m.directory "lib/tasks"
|
33
|
-
m.template
|
34
|
-
|
35
|
-
m.file
|
29
|
+
m.template "cucumber.rake", "lib/tasks/cucumber.rake"
|
30
|
+
|
31
|
+
m.file "cucumber", "script/cucumber", {
|
36
32
|
:chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
|
37
33
|
}
|
38
34
|
end
|
39
35
|
end
|
40
|
-
|
36
|
+
|
41
37
|
def framework
|
42
38
|
options[:framework] || :rspec
|
43
39
|
end
|
44
40
|
|
41
|
+
def language
|
42
|
+
lang = (options[:language] || :en).to_s
|
43
|
+
supported_languages = YAML.load_file(File.join(File.dirname(File.dirname(File.dirname(__FILE__))),'lib', 'cucumber', 'languages.yml'))
|
44
|
+
unless supported_languages[lang]
|
45
|
+
puts("\"#{lang}\" is not supported by cucumber. Switched to default language: \"en\".")
|
46
|
+
"en"
|
47
|
+
else
|
48
|
+
lang_subdir = File.join(File.dirname(__FILE__), 'templates', lang)
|
49
|
+
if File.exist?(lang_subdir) && File.directory?(lang_subdir)
|
50
|
+
lang
|
51
|
+
else
|
52
|
+
puts "\"#{lang}\ is not supported by the generator. Switched to default language: \"en\""
|
53
|
+
"en"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
45
58
|
protected
|
46
|
-
|
59
|
+
|
47
60
|
def banner
|
48
61
|
"Usage: #{$0} cucumber"
|
49
62
|
end
|
50
|
-
|
51
|
-
# Load up the transations for the passed language, and modify the features_path accordingly
|
52
|
-
def set_language(language)
|
53
|
-
@features_path = File.join(@features_path, language)
|
54
|
-
end
|
55
63
|
|
56
64
|
def add_options!(opt)
|
57
65
|
opt.separator ''
|
58
66
|
opt.separator 'Options:'
|
59
|
-
opt.on('--rspec', 'Setup cucumber for use with RSpec (default)') do
|
67
|
+
opt.on('--rspec', 'Setup cucumber for use with RSpec (default)') do
|
60
68
|
options[:framework] = :rspec
|
61
69
|
end
|
62
70
|
|
63
|
-
opt.on('--testunit', 'Setup cucumber for use with test/unit') do
|
71
|
+
opt.on('--testunit', 'Setup cucumber for use with test/unit') do
|
64
72
|
options[:framework] = :testunit
|
65
73
|
end
|
66
74
|
|
67
|
-
|
68
|
-
|
75
|
+
opt.on('--language [lang]', 'Setup cucumber for use with language [lang] ("en" is default') do |value|
|
76
|
+
options[:language] = value || :en
|
69
77
|
end
|
70
|
-
|
71
78
|
end
|
72
79
|
|
73
80
|
end
|
@@ -3,12 +3,12 @@ $LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.director
|
|
3
3
|
begin
|
4
4
|
require 'cucumber/rake/task'
|
5
5
|
|
6
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
7
|
-
|
8
|
-
|
9
|
-
t.cucumber_opts =
|
6
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
7
|
+
t.fork = true
|
8
|
+
<% if language == :en %>
|
9
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
|
10
10
|
<% else %>
|
11
|
-
t.cucumber_opts =
|
11
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty'), '--language', <%= language%>]
|
12
12
|
<% end %>
|
13
13
|
end
|
14
14
|
task :features => 'db:test:prepare'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
config.cache_classes = true # This must be true for Cucumber to operate correctly!
|
2
|
+
|
3
|
+
# Log error messages when you accidentally call methods on nil.
|
4
|
+
config.whiny_nils = true
|
5
|
+
|
6
|
+
# Show full error reports and disable caching
|
7
|
+
config.action_controller.consider_all_requests_local = true
|
8
|
+
config.action_controller.perform_caching = false
|
9
|
+
|
10
|
+
# Disable request forgery protection in test environment
|
11
|
+
config.action_controller.allow_forgery_protection = false
|
12
|
+
|
13
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
14
|
+
# The :test delivery method accumulates sent emails in the
|
15
|
+
# ActionMailer::Base.deliveries array.
|
16
|
+
config.action_mailer.delivery_method = :test
|
17
|
+
|
18
|
+
config.gem "cucumber", :lib => false, :version => ">=<%= cucumber_version %>" unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber'))
|
19
|
+
config.gem "webrat", :lib => false, :version => ">=0.4.4" unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
|
20
|
+
<% if framework == :rspec -%>
|
21
|
+
config.gem "rspec", :lib => false, :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
|
22
|
+
config.gem "rspec-rails", :lib => 'spec/rails', :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
|
23
|
+
<% end %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
# Maps a name to a path. Used by the
|
3
|
+
#
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
5
|
+
#
|
6
|
+
# step definition in webrat_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when /Startseite/
|
12
|
+
'/'
|
13
|
+
|
14
|
+
# Add more mappings here.
|
15
|
+
# Here is a more fancy example:
|
16
|
+
#
|
17
|
+
# when /^(.*)'s profile page$/i
|
18
|
+
# user_profile_path(User.find_by_login($1))
|
19
|
+
|
20
|
+
else
|
21
|
+
raise "Kann für \"#{page_name}\" kein Mapping zu einem Pfad finden.\n" +
|
22
|
+
"Sie sollten jetzt ein Mapping in #{__FILE__} hinzufügen."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
2
|
+
|
3
|
+
# Commonly used webrat steps
|
4
|
+
# http://github.com/brynary/webrat
|
5
|
+
|
6
|
+
Given /^Ich bin auf (.+)$/ do |page_name|
|
7
|
+
visit path_to(page_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^ich zu (.+) gehe$/ do |page_name|
|
11
|
+
visit path_to(page_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^ich den Knopf "([^\"]*)" betätige$/ do |button|
|
15
|
+
click_button(button)
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^ich dem Link "([^\"]*)" folge$/ do |link|
|
19
|
+
click_link(link)
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^ich das Feld "([^\"]*)" mit "([^\"]*)" fülle$/ do |field, value|
|
23
|
+
fill_in(field, :with => value)
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^ich "([^\"]*)" aus "([^\"]*)" wähle$/ do |value, field|
|
27
|
+
select(value, :from => field)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
31
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
32
|
+
When /^ich "([^\"]*)" als Datum und Uhrzeit wähle$/ do |time|
|
33
|
+
select_datetime(time)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
37
|
+
# you want to specify which datetime to select. Given the following view:
|
38
|
+
# <%%= f.label :preferred %><br />
|
39
|
+
# <%%= f.datetime_select :preferred %>
|
40
|
+
# <%%= f.label :alternative %><br />
|
41
|
+
# <%%= f.datetime_select :alternative %>
|
42
|
+
# The following steps would fill out the form:
|
43
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" data and time
|
44
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" data and time
|
45
|
+
When /^ich "([^\"]*)" als "([^\"]*)" Datum und Uhrzeit wähle$/ do |datetime, datetime_label|
|
46
|
+
select_datetime(datetime, :from => datetime_label)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
50
|
+
# When I select "2:20PM" as the time
|
51
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
52
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
53
|
+
When /^ich "([^\"]*)" als Uhrzeit wähle$/ do |time|
|
54
|
+
select_time(time)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
58
|
+
# specify the name of the time on the form. For example:
|
59
|
+
# When I select "7:30AM" as the "Gym" time
|
60
|
+
When /^ich "([^\"]*)" als "([^\"]*)" Uhrzeit wähle$/ do |time, time_label|
|
61
|
+
select_time(time, :from => time_label)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
65
|
+
# When I select "February 20, 1981" as the date
|
66
|
+
When /^ich "([^\"]*)" als Datum wähle$/ do |date|
|
67
|
+
select_date(date)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Use this step when using multiple date_select helpers on one page or
|
71
|
+
# you want to specify the name of the date on the form. For example:
|
72
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
73
|
+
When /^ich "([^\"]*)" als "([^\"]*)" Datum wähle$/ do |date, date_label|
|
74
|
+
select_date(date, :from => date_label)
|
75
|
+
end
|
76
|
+
|
77
|
+
When /^ich "([^\"]*)" auswähle$/ do |field|
|
78
|
+
check(field)
|
79
|
+
end
|
80
|
+
|
81
|
+
When /^ich die Auswahl "([^\"]*)" aufhebe$/ do |field|
|
82
|
+
uncheck(field)
|
83
|
+
end
|
84
|
+
|
85
|
+
When /^ich "([^\"]*)" wähle$/ do |field|
|
86
|
+
choose(field)
|
87
|
+
end
|
88
|
+
|
89
|
+
When /^ich die Datei "([^\"]*)" an "([^\"]*)" anhänge$/ do |path, field|
|
90
|
+
attach_file(field, path)
|
91
|
+
end
|
92
|
+
|
93
|
+
Then /^sollte ich "([^\"]*)" sehen $/ do |text|
|
94
|
+
<% if framework == :rspec -%>
|
95
|
+
response.should contain(text)
|
96
|
+
<% else -%>
|
97
|
+
assert_contain text
|
98
|
+
<% end -%>
|
99
|
+
end
|
100
|
+
|
101
|
+
Then /^sollte ich nicht "([^\"]*)" sehen$/ do |text|
|
102
|
+
<% if framework == :rspec -%>
|
103
|
+
response.should_not contain(text)
|
104
|
+
<% else -%>
|
105
|
+
assert_not_contain text
|
106
|
+
<% end -%>
|
107
|
+
end
|
108
|
+
|
109
|
+
Then /^sollte das Feld "([^\"]*)" "([^\"]*)" enthalten$/ do |field, value|
|
110
|
+
<% if framework == :rspec -%>
|
111
|
+
field_labeled(field).value.should =~ /#{value}/
|
112
|
+
<% else -%>
|
113
|
+
assert_match(/#{value}/, field_labeled(field).value)
|
114
|
+
<% end -%>
|
115
|
+
end
|
116
|
+
|
117
|
+
Then /^sollte das Feld "([^\"]*)" nicht "([^\"]*)" enthalten$/ do |field, value|
|
118
|
+
<% if framework == :rspec -%>
|
119
|
+
field_labeled(field).value.should_not =~ /#{value}/
|
120
|
+
<% else -%>
|
121
|
+
assert_no_match(/#{value}/, field_labeled(field).value)
|
122
|
+
<% end -%>
|
123
|
+
end
|
124
|
+
|
125
|
+
Then /^sollte das "([^\"]*)" Kästchen ausgewählt sein$/ do |label|
|
126
|
+
<% if framework == :rspec -%>
|
127
|
+
field_labeled(label).should be_checked
|
128
|
+
<% else -%>
|
129
|
+
assert field_labeled(label).checked?
|
130
|
+
<% end -%>
|
131
|
+
end
|
132
|
+
|
133
|
+
Then /^sollte ich auf (.+) sein$/ do |page_name|
|
134
|
+
<% if framework == :rspec -%>
|
135
|
+
URI.parse(current_url).path.should == path_to(page_name)
|
136
|
+
<% else -%>
|
137
|
+
assert_equal path_to(page_name), URI.parse(current_url).path
|
138
|
+
<% end -%>
|
139
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
# Maps a name to a path. Used by the
|
3
|
+
#
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
5
|
+
#
|
6
|
+
# step definition in webrat_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when /the homepage/
|
12
|
+
'/'
|
13
|
+
|
14
|
+
# Add more mappings here.
|
15
|
+
# Here is a more fancy example:
|
16
|
+
#
|
17
|
+
# when /^(.*)'s profile page$/i
|
18
|
+
# user_profile_path(User.find_by_login($1))
|
19
|
+
|
20
|
+
else
|
21
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
22
|
+
"Now, go and add a mapping in #{__FILE__}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
World(NavigationHelpers)
|
@@ -40,8 +40,8 @@ end
|
|
40
40
|
# <%%= f.label :alternative %><br />
|
41
41
|
# <%%= f.datetime_select :alternative %>
|
42
42
|
# The following steps would fill out the form:
|
43
|
-
# When I select "November 23, 2004 11:20" as the "Preferred"
|
44
|
-
# And I select "November 25, 2004 10:30" as the "Alternative"
|
43
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
|
44
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
|
45
45
|
When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
46
46
|
select_datetime(datetime, :from => datetime_label)
|
47
47
|
end
|
@@ -106,6 +106,22 @@ Then /^I should not see "([^\"]*)"$/ do |text|
|
|
106
106
|
<% end -%>
|
107
107
|
end
|
108
108
|
|
109
|
+
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
110
|
+
<% if framework == :rspec -%>
|
111
|
+
field_labeled(field).value.should =~ /#{value}/
|
112
|
+
<% else -%>
|
113
|
+
assert_match(/#{value}/, field_labeled(field).value)
|
114
|
+
<% end -%>
|
115
|
+
end
|
116
|
+
|
117
|
+
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
|
118
|
+
<% if framework == :rspec -%>
|
119
|
+
field_labeled(field).value.should_not =~ /#{value}/
|
120
|
+
<% else -%>
|
121
|
+
assert_no_match(/#{value}/, field_labeled(field).value)
|
122
|
+
<% end -%>
|
123
|
+
end
|
124
|
+
|
109
125
|
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
110
126
|
<% if framework == :rspec -%>
|
111
127
|
field_labeled(label).should be_checked
|
@@ -114,6 +130,14 @@ Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
|
114
130
|
<% end -%>
|
115
131
|
end
|
116
132
|
|
133
|
+
Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
|
134
|
+
<% if framework == :rspec -%>
|
135
|
+
field_labeled(label).should_not be_checked
|
136
|
+
<% else -%>
|
137
|
+
assert !field_labeled(label).checked?
|
138
|
+
<% end -%>
|
139
|
+
end
|
140
|
+
|
117
141
|
Then /^I should be on (.+)$/ do |page_name|
|
118
142
|
<% if framework == :rspec -%>
|
119
143
|
URI.parse(current_url).path.should == path_to(page_name)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Sets up the Rails environment for Cucumber
|
2
|
-
ENV["RAILS_ENV"] ||= "
|
2
|
+
ENV["RAILS_ENV"] ||= "cucumber"
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
4
4
|
require 'cucumber/rails/world'
|
5
5
|
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
|
@@ -7,9 +7,6 @@ Description:
|
|
7
7
|
This generator can take an optional list of attribute pairs similar to Rails'
|
8
8
|
built-in resource generator.
|
9
9
|
|
10
|
-
If you set the language option, then a subdirectory features/[language] will be generated instead.
|
11
|
-
Now your are able to use features in different languages.
|
12
|
-
|
13
10
|
Examples:
|
14
11
|
`./script/generate feature post` # no attributes
|
15
12
|
`./script/generate feature post title:string body:text published:boolean`
|
@@ -1,24 +1,12 @@
|
|
1
|
-
# This generator
|
1
|
+
# This generator generates a baic feature.
|
2
2
|
class FeatureGenerator < Rails::Generator::NamedBase
|
3
|
-
|
4
|
-
|
5
|
-
def initialize(runtime_args, runtime_options = {})
|
6
|
-
super
|
7
|
-
@features_path = "features"
|
8
|
-
end
|
9
|
-
|
10
|
-
def manifest
|
11
|
-
if options[:language]
|
12
|
-
@language = options[:language]
|
13
|
-
set_language(@language)
|
14
|
-
end
|
15
|
-
|
3
|
+
def manifest
|
16
4
|
record do |m|
|
17
|
-
m.directory
|
18
|
-
m.template
|
19
|
-
m.template
|
5
|
+
m.directory 'features/step_definitions'
|
6
|
+
m.template 'feature.erb', "features/manage_#{plural_name}.feature"
|
7
|
+
m.template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
|
20
8
|
|
21
|
-
m.gsub_file 'features/support/paths.rb', /
|
9
|
+
m.gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
|
22
10
|
"#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
|
23
11
|
end
|
24
12
|
end
|
@@ -49,16 +37,4 @@ class FeatureGenerator < Rails::Generator::NamedBase
|
|
49
37
|
def banner
|
50
38
|
"Usage: #{$0} feature ModelName [field:type, field:type]"
|
51
39
|
end
|
52
|
-
|
53
|
-
def add_options!(opt)
|
54
|
-
opt.separator ""
|
55
|
-
opt.separator "Options:"
|
56
|
-
opt.on("-l", "--language=lang", String, "Use a [language] subdirectoy in /features.") { |v| options[:language] = v }
|
57
|
-
end
|
58
|
-
|
59
|
-
# Load up the transations for the passed language, and modify the features_path accordingly
|
60
|
-
def set_language(language)
|
61
|
-
@features_path = File.join(@features_path, language)
|
62
|
-
end
|
63
|
-
|
64
40
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/step_mother'
|
3
|
+
require 'cucumber/ast'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
describe FeatureElement do
|
7
|
+
include FeatureElement
|
8
|
+
|
9
|
+
describe "with multiline names" do
|
10
|
+
it "should select the longest line as the text length" do
|
11
|
+
@keyword = "key"
|
12
|
+
@name = "short\nvery longer\ntiny"
|
13
|
+
text_length.should == 11 + Ast::Step::INDENT - 1
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should add keyword to first lines length" do
|
17
|
+
@keyword = "key"
|
18
|
+
@name = "short\nvery longer\ntiny"
|
19
|
+
|
20
|
+
first_line_length.should == (@keyword.jlength) + (first_line_name_length = 5)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "with empty name" do
|
25
|
+
it "should only return the length of the keyword" do
|
26
|
+
@name = ""
|
27
|
+
@keyword = "key"
|
28
|
+
|
29
|
+
text_length.should == 3
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should support checking if its name matches a list of regexps" do
|
34
|
+
@name = 'test'
|
35
|
+
matches_scenario_names?([/es/]).should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -21,6 +21,10 @@ module Cucumber
|
|
21
21
|
@table.columns[1].map{|cell| cell.value}.should == %w{four 55555}
|
22
22
|
end
|
23
23
|
|
24
|
+
it "should have headers" do
|
25
|
+
@table.headers.should == %w{one four seven}
|
26
|
+
end
|
27
|
+
|
24
28
|
it "should have same cell objects in rows and columns" do
|
25
29
|
# 666666
|
26
30
|
@table.cells_rows[1].__send__(:[], 2).should equal(@table.columns[2].__send__(:[], 1))
|
@@ -57,7 +61,7 @@ module Cucumber
|
|
57
61
|
}.should raise_error('The column named "two" does not exist')
|
58
62
|
end
|
59
63
|
|
60
|
-
describe "
|
64
|
+
describe "#transpose" do
|
61
65
|
before(:each) do
|
62
66
|
@table = Table.new([
|
63
67
|
%w{one 1111},
|
@@ -70,7 +74,7 @@ module Cucumber
|
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
73
|
-
describe "
|
77
|
+
describe "#rows_hash" do
|
74
78
|
|
75
79
|
it "should return a hash of the rows" do
|
76
80
|
table = Table.new([
|
@@ -105,10 +109,10 @@ module Cucumber
|
|
105
109
|
describe "replacing arguments" do
|
106
110
|
|
107
111
|
before(:each) do
|
108
|
-
@table =
|
112
|
+
@table = Table.new([
|
109
113
|
%w{qty book},
|
110
114
|
%w{<qty> <book>}
|
111
|
-
|
115
|
+
])
|
112
116
|
end
|
113
117
|
|
114
118
|
it "should return a new table with arguments replaced with values" do
|
@@ -118,6 +122,18 @@ module Cucumber
|
|
118
122
|
table_with_replaced_args.hashes[0]['qty'].should == '5'
|
119
123
|
end
|
120
124
|
|
125
|
+
it "should recognise when entire cell is delimited" do
|
126
|
+
@table.should have_text('<book>')
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should recognise when just a subset of a cell is delimited" do
|
130
|
+
table = Table.new([
|
131
|
+
%w{qty book},
|
132
|
+
[nil, "This is <who>'s book"]
|
133
|
+
])
|
134
|
+
table.should have_text('<who>')
|
135
|
+
end
|
136
|
+
|
121
137
|
it "should replace nil values with nil" do
|
122
138
|
table_with_replaced_args = @table.arguments_replaced({'<book>' => nil})
|
123
139
|
|
@@ -167,4 +183,4 @@ module Cucumber
|
|
167
183
|
end
|
168
184
|
end
|
169
185
|
end
|
170
|
-
end
|
186
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/step_mother'
|
3
|
+
require 'cucumber/ast'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module Ast
|
7
|
+
describe Visitor do
|
8
|
+
|
9
|
+
it "should support checking scenario name matches regexps" do
|
10
|
+
visitor = Visitor.new(mock("step mother"))
|
11
|
+
scenario = Scenario.new(background=nil,
|
12
|
+
comment=Comment.new(""),
|
13
|
+
tags=Tags.new(0, []),
|
14
|
+
line=99,
|
15
|
+
keyword="",
|
16
|
+
name="test name",
|
17
|
+
steps=[])
|
18
|
+
|
19
|
+
visitor.options = {:name_regexps => [/name/]}
|
20
|
+
|
21
|
+
visitor.matches_scenario_names?(scenario).should be_true
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|