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.
Files changed (210) hide show
  1. data/History.txt +203 -3
  2. data/Manifest.txt +0 -346
  3. data/README.txt +0 -21
  4. data/Rakefile +3 -1
  5. data/bin/cucumber +12 -1
  6. data/config/hoe.rb +6 -5
  7. data/cucumber.yml +3 -1
  8. data/examples/cs/Rakefile +1 -1
  9. data/examples/cs/features/addition.feature +5 -5
  10. data/examples/cs/features/step_definitons/calculator_steps.rb +2 -2
  11. data/examples/dos_line_endings/Rakefile +1 -1
  12. data/examples/dos_line_endings/features/dos_line_endings.feature +9 -9
  13. data/examples/i18n/Rakefile +1 -1
  14. data/examples/i18n/ar/Rakefile +1 -1
  15. data/examples/i18n/bg/Rakefile +6 -0
  16. data/examples/i18n/bg/features/addition.feature +11 -0
  17. data/examples/i18n/bg/features/consecutive_calculations.feature +18 -0
  18. data/examples/i18n/bg/features/division.feature +16 -0
  19. data/examples/i18n/bg/features/step_definitons/calculator_steps.rb +24 -0
  20. data/examples/i18n/bg/features/support/env.rb +6 -0
  21. data/examples/i18n/bg/features/support/world.rb +8 -0
  22. data/examples/i18n/bg/lib/calculator.rb +24 -0
  23. data/examples/i18n/cat/Rakefile +6 -0
  24. data/examples/i18n/cat/features/step_definitons/calculator_steps.rb +21 -0
  25. data/examples/i18n/cat/features/suma.feature +16 -0
  26. data/examples/i18n/cat/lib/calculadora.rb +16 -0
  27. data/examples/i18n/da/Rakefile +1 -1
  28. data/examples/i18n/de/Rakefile +1 -1
  29. data/examples/i18n/en/Rakefile +1 -1
  30. data/examples/i18n/en-lol/Rakefile +1 -1
  31. data/examples/i18n/es/Rakefile +1 -1
  32. data/examples/i18n/et/Rakefile +1 -1
  33. data/examples/i18n/fi/Rakefile +1 -1
  34. data/examples/i18n/fr/Rakefile +1 -1
  35. data/examples/i18n/fr/features/addition.feature +4 -4
  36. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +1 -1
  37. data/examples/i18n/fr/lib/calculatrice.rb +1 -1
  38. data/examples/i18n/he/Rakefile +6 -0
  39. data/examples/i18n/he/features/addition.feature +16 -0
  40. data/examples/i18n/he/features/division.feature +9 -0
  41. data/examples/i18n/he/features/step_definitons/calculator_steps.rb +24 -0
  42. data/examples/i18n/he/lib/calculator.rb +14 -0
  43. data/examples/i18n/hu/Rakefile +6 -0
  44. data/examples/i18n/hu/features/addition.feature +16 -0
  45. data/examples/i18n/hu/features/division.feature +9 -0
  46. data/examples/i18n/hu/features/step_definitons/calculator_steps.rb +25 -0
  47. data/examples/i18n/hu/lib/calculator.rb +14 -0
  48. data/examples/i18n/id/Rakefile +1 -1
  49. data/examples/i18n/it/Rakefile +1 -1
  50. data/examples/i18n/ja/Rakefile +1 -1
  51. data/examples/i18n/ja/features/addition.feature +1 -1
  52. data/examples/i18n/ja/features/division.feature +1 -1
  53. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +1 -1
  54. data/examples/i18n/ko/Rakefile +1 -1
  55. data/examples/i18n/lt/Rakefile +1 -1
  56. data/examples/i18n/lt/features/addition.feature +2 -3
  57. data/examples/i18n/lv/Rakefile +6 -0
  58. data/examples/i18n/lv/features/addition.feature +16 -0
  59. data/examples/i18n/lv/features/division.feature +9 -0
  60. data/examples/i18n/lv/features/step_definitons/calculator_steps.rb +24 -0
  61. data/examples/i18n/lv/lib/calculator.rb +14 -0
  62. data/examples/i18n/no/Rakefile +1 -1
  63. data/examples/i18n/pl/Rakefile +6 -0
  64. data/examples/i18n/pl/features/addition.feature +16 -0
  65. data/examples/i18n/pl/features/division.feature +9 -0
  66. data/examples/i18n/pl/features/step_definitons/calculator_steps.rb +24 -0
  67. data/examples/i18n/pl/features/support/env.rb +6 -0
  68. data/examples/i18n/pl/lib/calculator.rb +14 -0
  69. data/examples/i18n/pt/Rakefile +1 -1
  70. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +3 -7
  71. data/examples/i18n/pt/features/support/env.rb +6 -0
  72. data/examples/i18n/ro/Rakefile +1 -1
  73. data/examples/i18n/ru/Rakefile +1 -1
  74. data/examples/i18n/se/Rakefile +1 -1
  75. data/examples/i18n/sk/Rakefile +1 -1
  76. data/examples/i18n/zh-CN/Rakefile +1 -1
  77. data/examples/i18n/zh-TW/Rakefile +1 -1
  78. data/examples/java/README.textile +2 -6
  79. data/examples/java/build.xml +33 -0
  80. data/examples/java/features/step_definitons/hello_steps.rb +0 -2
  81. data/examples/junit/features/one_passing_one_failing.feature +8 -0
  82. data/examples/junit/features/pending.feature +5 -0
  83. data/examples/junit/features/step_definitions/steps.rb +11 -0
  84. data/examples/selenium/Rakefile +1 -1
  85. data/examples/selenium_webrat/Rakefile +1 -1
  86. data/examples/selenium_webrat/config.ru +0 -0
  87. data/examples/selenium_webrat/features/search.feature +1 -1
  88. data/examples/selenium_webrat/features/step_definitons/search_steps.rb +2 -2
  89. data/examples/selenium_webrat/features/support/env.rb +7 -3
  90. data/examples/self_test/features/background/background_tagged_before_on_outline.feature +12 -0
  91. data/examples/self_test/features/background/failing_background.feature +1 -0
  92. data/examples/self_test/features/background/passing_background.feature +2 -2
  93. data/examples/self_test/features/multiline_name.feature +27 -0
  94. data/examples/self_test/features/sample.feature +2 -0
  95. data/examples/self_test/features/search_sample.feature +32 -0
  96. data/examples/self_test/features/step_definitions/sample_steps.rb +11 -0
  97. data/examples/self_test/features/support/env.rb +17 -1
  98. data/examples/sinatra/Rakefile +1 -1
  99. data/examples/test_unit/Rakefile +1 -1
  100. data/examples/tickets/Rakefile +3 -3
  101. data/examples/tickets/features/229/tagged_hooks.feature +8 -0
  102. data/examples/tickets/features/229/tagged_hooks.rb +14 -0
  103. data/examples/tickets/features/236.feature +9 -9
  104. data/examples/tickets/features/272/hooks.feature +26 -0
  105. data/examples/tickets/features/272/hooks_steps.rb +53 -0
  106. data/examples/tickets/features/279/py_string_indent.feature +25 -0
  107. data/examples/tickets/features/279/py_string_indent.steps.rb +12 -0
  108. data/examples/tickets/features/279/wrong.feature_ +11 -0
  109. data/examples/tickets/features/301/filter_background_tagged_hooks.feature +6 -0
  110. data/examples/tickets/features/301/filter_background_tagged_hooks_steps.rb +12 -0
  111. data/examples/tickets/features/306/only_background.feature +4 -0
  112. data/examples/tickets/features/step_definitons/tickets_steps.rb +0 -7
  113. data/examples/watir/Rakefile +1 -1
  114. data/examples/watir/features/search.feature +4 -1
  115. data/examples/watir/features/step_definitons/search_steps.rb +2 -4
  116. data/features/after_block_exceptions.feature +99 -0
  117. data/features/after_step_block_exceptions.feature +101 -0
  118. data/features/background.feature +105 -38
  119. data/features/cucumber_cli.feature +201 -64
  120. data/features/cucumber_cli_diff_disabled.feature +6 -4
  121. data/features/cucumber_cli_outlines.feature +60 -35
  122. data/features/custom_formatter.feature +3 -3
  123. data/features/exclude_files.feature +20 -0
  124. data/features/expand.feature +48 -0
  125. data/features/html_formatter/a.html +1632 -0
  126. data/features/html_formatter.feature +7 -0
  127. data/features/junit_formatter.feature +62 -0
  128. data/features/multiline_names.feature +43 -0
  129. data/features/rake_task.feature +150 -0
  130. data/features/report_called_undefined_steps.feature +4 -3
  131. data/features/snippet.feature +2 -3
  132. data/features/step_definitions/cucumber_steps.rb +98 -15
  133. data/features/support/env.rb +78 -3
  134. data/features/usage.feature +32 -19
  135. data/features/work_in_progress.feature +148 -0
  136. data/gem_tasks/deployment.rake +1 -1
  137. data/gem_tasks/rspec.rake +9 -2
  138. data/lib/cucumber/ast/background.rb +19 -7
  139. data/lib/cucumber/ast/comment.rb +4 -0
  140. data/lib/cucumber/ast/feature.rb +7 -1
  141. data/lib/cucumber/ast/feature_element.rb +24 -9
  142. data/lib/cucumber/ast/features.rb +4 -0
  143. data/lib/cucumber/ast/outline_table.rb +74 -4
  144. data/lib/cucumber/ast/py_string.rb +5 -1
  145. data/lib/cucumber/ast/scenario.rb +31 -7
  146. data/lib/cucumber/ast/scenario_outline.rb +17 -9
  147. data/lib/cucumber/ast/step.rb +8 -5
  148. data/lib/cucumber/ast/step_collection.rb +14 -1
  149. data/lib/cucumber/ast/step_invocation.rb +29 -15
  150. data/lib/cucumber/ast/table.rb +9 -1
  151. data/lib/cucumber/ast/tags.rb +9 -1
  152. data/lib/cucumber/ast/visitor.rb +6 -2
  153. data/lib/cucumber/cli/configuration.rb +134 -105
  154. data/lib/cucumber/cli/main.rb +35 -12
  155. data/lib/cucumber/core_ext/proc.rb +9 -13
  156. data/lib/cucumber/formatter/ansicolor.rb +1 -1
  157. data/lib/cucumber/formatter/console.rb +36 -14
  158. data/lib/cucumber/formatter/cucumber.css +31 -12
  159. data/lib/cucumber/formatter/duration.rb +10 -0
  160. data/lib/cucumber/formatter/html.rb +76 -16
  161. data/lib/cucumber/formatter/junit.rb +79 -0
  162. data/lib/cucumber/formatter/pretty.rb +19 -14
  163. data/lib/cucumber/formatter/profile.rb +1 -1
  164. data/lib/cucumber/formatter/progress.rb +12 -12
  165. data/lib/cucumber/formatter/rerun.rb +1 -0
  166. data/lib/cucumber/formatter/tag_cloud.rb +28 -0
  167. data/lib/cucumber/formatter/usage.rb +5 -5
  168. data/lib/cucumber/formatters/unicode.rb +5 -0
  169. data/lib/cucumber/languages.yml +111 -34
  170. data/lib/cucumber/parser/feature.rb +237 -36
  171. data/lib/cucumber/parser/feature.tt +68 -30
  172. data/lib/cucumber/parser/treetop_ext.rb +12 -3
  173. data/lib/cucumber/rails/rspec.rb +5 -3
  174. data/lib/cucumber/rails/world.rb +29 -4
  175. data/lib/cucumber/rake/task.rb +125 -37
  176. data/lib/cucumber/rspec_neuter.rb +23 -0
  177. data/lib/cucumber/step_definition.rb +5 -2
  178. data/lib/cucumber/step_match.rb +10 -6
  179. data/lib/cucumber/step_mother.rb +98 -26
  180. data/lib/cucumber/version.rb +3 -3
  181. data/lib/cucumber/world.rb +2 -2
  182. data/lib/cucumber.rb +7 -2
  183. data/rails_generators/cucumber/USAGE +0 -3
  184. data/rails_generators/cucumber/cucumber_generator.rb +51 -44
  185. data/rails_generators/cucumber/templates/cucumber.rake +5 -5
  186. data/rails_generators/cucumber/templates/cucumber_environment.rb +23 -0
  187. data/rails_generators/cucumber/templates/de/paths.rb +27 -0
  188. data/rails_generators/cucumber/templates/de/webrat_steps.rb +139 -0
  189. data/rails_generators/cucumber/templates/en/paths.rb +27 -0
  190. data/rails_generators/cucumber/templates/{webrat_steps.rb → en/webrat_steps.rb} +26 -2
  191. data/rails_generators/cucumber/templates/env.rb +1 -1
  192. data/rails_generators/feature/USAGE +0 -3
  193. data/rails_generators/feature/feature_generator.rb +6 -30
  194. data/spec/cucumber/ast/feature_element_spec.rb +40 -0
  195. data/spec/cucumber/ast/py_string_spec.rb +4 -0
  196. data/spec/cucumber/ast/table_spec.rb +21 -5
  197. data/spec/cucumber/ast/visitor_spec.rb +27 -0
  198. data/spec/cucumber/cli/configuration_spec.rb +75 -54
  199. data/spec/cucumber/cli/main_spec.rb +60 -154
  200. data/spec/cucumber/formatter/color_io_spec.rb +1 -0
  201. data/spec/cucumber/formatter/duration_spec.rb +22 -0
  202. data/spec/cucumber/formatter/progress_spec.rb +36 -0
  203. data/spec/cucumber/parser/feature_parser_spec.rb +102 -1
  204. data/spec/cucumber/step_mother_spec.rb +23 -5
  205. metadata +79 -22
  206. data/examples/java/Rakefile +0 -12
  207. data/examples/self_test/features/support/tag_count_formatter.rb +0 -25
  208. data/lib/cucumber/formatter.rb +0 -1
  209. data/rails_generators/cucumber/templates/paths.rb +0 -29
  210. data/spec/cucumber/formatters/profile_formatter_spec.rb +0 -198
@@ -1,73 +1,80 @@
1
- require "rbconfig"
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["bindir"],
6
- Config::CONFIG["ruby_install_name"])
7
-
8
- attr_accessor :framework, :language
9
-
10
- def initialize(runtime_args, runtime_options = {})
11
- super
12
- @features_path = "features"
13
- end
14
-
15
- def manifest
16
- if options[:language]
17
- @language = options[:language]
18
- set_language(@language)
19
- end
20
- record do |m|
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.file "env.rb", "features/support/env.rb"
23
- m.directory File.join(@features_path, "step_definitions")
24
- if @language
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 "cucumber.rake", "lib/tasks/cucumber.rake"
34
-
35
- m.file "cucumber", "script/cucumber", {
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 |value|
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 |value|
71
+ opt.on('--testunit', 'Setup cucumber for use with test/unit') do
64
72
  options[:framework] = :testunit
65
73
  end
66
74
 
67
- opt.on("-l", "--language=lang", String, "Use a [language] subdirectoy in /features.") do |value|
68
- options[:language] = value
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
- <% if language %>
8
- t.language = "<%= language%>"
9
- t.cucumber_opts = "--format pretty --language <%= language%>"
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 = "--format pretty"
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" data and time
44
- # And I select "November 25, 2004 10:30" as the "Alternative" data and time
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"] ||= "test"
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 bootstraps a Rails project for use with Cucumber
1
+ # This generator generates a baic feature.
2
2
  class FeatureGenerator < Rails::Generator::NamedBase
3
- attr_reader :language
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 File.join(@features_path, "step_definitions")
18
- m.template "feature.erb", File.join(@features_path, "manage_#{plural_name}.feature")
19
- m.template "steps.erb", File.join(@features_path, "step_definitions", "#{singular_name}_steps.rb")
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', /root_path/mi do |match|
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
+
@@ -40,6 +40,10 @@ module Cucumber
40
40
  py_string_with_replaced_arg.to_s.should == "''"
41
41
  end
42
42
 
43
+ it "should recognise when just a subset of a cell is delimited" do
44
+ @ps.should have_text('<qty>')
45
+ end
46
+
43
47
  end
44
48
 
45
49
  end
@@ -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 ".transpose" do
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 ".rows_hash" do
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 = table = Table.new([
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
+