cucumber-rails 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +194 -0
  6. data/History.txt +101 -1
  7. data/LICENSE +22 -0
  8. data/README.md +77 -0
  9. data/Rakefile +3 -19
  10. data/config/cucumber.yml +1 -0
  11. data/cucumber-rails.gemspec +37 -101
  12. data/dev_tasks/cucumber.rake +1 -1
  13. data/dev_tasks/rspec.rake +6 -11
  14. data/features/allow_rescue.feature +63 -0
  15. data/features/capybara_javascript_drivers.feature +87 -0
  16. data/features/database_cleaner.feature +44 -0
  17. data/features/emulate_javascript.feature +34 -0
  18. data/features/inspect_query_string.feature +37 -0
  19. data/features/install_cucumber_rails.feature +16 -0
  20. data/features/mongoid.feature +53 -0
  21. data/features/multiple_databases.feature +74 -0
  22. data/features/named_selectors.feature +33 -0
  23. data/features/no_database.feature +70 -0
  24. data/features/pseduo_class_selectors.feature +24 -0
  25. data/features/rerun_profile.feature +38 -0
  26. data/features/rest_api.feature +47 -0
  27. data/features/routing.feature +18 -0
  28. data/features/select_dates.feature +99 -0
  29. data/features/step_definitions/cucumber_rails_steps.rb +80 -6
  30. data/features/support/env.rb +8 -2
  31. data/features/test_unit.feature +43 -0
  32. data/lib/cucumber/rails/capybara/javascript_emulation.rb +83 -0
  33. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +50 -0
  34. data/lib/cucumber/rails/capybara.rb +6 -0
  35. data/lib/cucumber/rails/hooks/active_record.rb +14 -0
  36. data/lib/cucumber/rails/hooks/allow_rescue.rb +8 -0
  37. data/lib/cucumber/rails/hooks/database_cleaner.rb +13 -0
  38. data/lib/cucumber/rails/hooks/mail.rb +5 -0
  39. data/lib/cucumber/rails/hooks.rb +4 -0
  40. data/lib/cucumber/rails/rspec.rb +4 -6
  41. data/lib/cucumber/rails/world.rb +13 -35
  42. data/lib/cucumber/rails.rb +8 -0
  43. data/lib/cucumber/rails3/action_controller.rb +12 -0
  44. data/lib/cucumber/rails3/active_record.rb +8 -0
  45. data/lib/cucumber/rails3/application.rb +17 -0
  46. data/lib/cucumber/rails3.rb +16 -0
  47. data/lib/cucumber/web/tableish.rb +50 -9
  48. data/lib/generators/cucumber/feature/feature_generator.rb +8 -17
  49. data/lib/generators/cucumber/feature/named_arg.rb +2 -0
  50. data/{templates/feature → lib/generators/cucumber/feature/templates}/feature.erb +10 -12
  51. data/{templates/feature → lib/generators/cucumber/feature/templates}/steps.erb +1 -1
  52. data/lib/generators/cucumber/install/USAGE +15 -0
  53. data/lib/generators/cucumber/install/install_generator.rb +88 -0
  54. data/lib/generators/cucumber/install/templates/config/cucumber.yml.erb +8 -0
  55. data/lib/generators/cucumber/install/templates/step_definitions/web_steps.rb.erb +192 -0
  56. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_cs.rb.erb +127 -0
  57. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_da.rb.erb +105 -0
  58. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_de.rb.erb +127 -0
  59. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_es.rb.erb +127 -0
  60. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ja.rb.erb +140 -0
  61. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ko.rb.erb +142 -0
  62. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_no.rb.erb +105 -0
  63. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_pt-BR.rb.erb +132 -0
  64. data/lib/generators/cucumber/install/templates/support/_rails_each_run.rb.erb +36 -0
  65. data/lib/generators/cucumber/install/templates/support/_rails_prefork.rb.erb +1 -0
  66. data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/capybara.rb +0 -4
  67. data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/paths.rb +11 -5
  68. data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/rails.rb.erb +2 -2
  69. data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/rails_spork.rb.erb +2 -2
  70. data/lib/generators/cucumber/install/templates/support/selectors.rb +39 -0
  71. data/lib/generators/cucumber/install/templates/support/web_steps_warning.txt +19 -0
  72. data/{templates/skeleton → lib/generators/cucumber/install/templates}/tasks/cucumber.rake.erb +18 -0
  73. data/spec/cucumber/web/tableish_spec.rb +83 -6
  74. data/spec/spec_helper.rb +1 -4
  75. metadata +299 -73
  76. data/HACKING.rdoc +0 -34
  77. data/README.rdoc +0 -64
  78. data/VERSION +0 -1
  79. data/features/rails2.feature +0 -56
  80. data/features/rails3.feature +0 -52
  81. data/features/support/matchers/files.rb +0 -17
  82. data/generators/cucumber/USAGE +0 -14
  83. data/generators/cucumber/cucumber_generator.rb +0 -89
  84. data/generators/cucumber/templates/step_definitions/web_steps_ja.rb.erb +0 -136
  85. data/generators/feature/USAGE +0 -12
  86. data/generators/feature/feature_generator.rb +0 -47
  87. data/lib/cucumber/rails/action_controller.rb +0 -65
  88. data/lib/cucumber/rails/active_record.rb +0 -34
  89. data/lib/cucumber/rails/capybara_javascript_emulation.rb +0 -72
  90. data/lib/cucumber/rails/test_unit.rb +0 -9
  91. data/lib/generators/cucumber/feature/feature_base.rb +0 -29
  92. data/lib/generators/cucumber/skeleton/USAGE +0 -21
  93. data/lib/generators/cucumber/skeleton/skeleton_base.rb +0 -202
  94. data/lib/generators/cucumber/skeleton/skeleton_generator.rb +0 -64
  95. data/rvm.yml +0 -22
  96. data/spec/generators/cucumber/skeleton/skeleton_base_spec.rb +0 -84
  97. data/spec/spec.opts +0 -2
  98. data/templates/skeleton/config/cucumber.yml.erb +0 -7
  99. data/templates/skeleton/environments/cucumber.rb.erb +0 -37
  100. data/templates/skeleton/step_definitions/capybara_steps.rb.erb +0 -197
  101. data/templates/skeleton/step_definitions/web_steps_cs.rb.erb +0 -136
  102. data/templates/skeleton/step_definitions/web_steps_da.rb.erb +0 -114
  103. data/templates/skeleton/step_definitions/web_steps_de.rb.erb +0 -136
  104. data/templates/skeleton/step_definitions/web_steps_es.rb.erb +0 -136
  105. data/templates/skeleton/step_definitions/web_steps_no.rb.erb +0 -114
  106. data/templates/skeleton/step_definitions/web_steps_pt-BR.rb.erb +0 -140
  107. data/templates/skeleton/step_definitions/webrat_steps.rb.erb +0 -268
  108. data/templates/skeleton/support/_rails_each_run.rb +0 -34
  109. data/templates/skeleton/support/_rails_prefork.rb.erb +0 -10
  110. data/templates/skeleton/support/webrat.rb +0 -8
  111. /data/{templates/skeleton → lib/generators/cucumber/install/templates}/script/cucumber +0 -0
  112. /data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/edit_warning.txt +0 -0
@@ -1,11 +1,9 @@
1
1
  require File.join(File.dirname(__FILE__), 'named_arg')
2
- require File.join(File.dirname(__FILE__), 'feature_base')
3
2
 
4
3
  module Cucumber
5
- class FeatureGenerator < Rails::Generators::NamedBase
4
+ class FeatureGenerator < ::Rails::Generators::NamedBase
5
+ source_root File.expand_path("../templates", __FILE__)
6
6
 
7
- include Cucumber::Generators::FeatureBase
8
-
9
7
  argument :fields, :optional => true, :type => :array, :banner => "[field:type, field:type]"
10
8
 
11
9
  attr_reader :named_args
@@ -15,23 +13,16 @@ module Cucumber
15
13
  end
16
14
 
17
15
  def generate
18
- create_directory
19
- create_feature_file
20
- create_steps_file
21
- create_support_file
16
+ empty_directory 'features/step_definitions'
17
+ template 'feature.erb', "features/manage_#{plural_name}.feature"
18
+ template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
19
+ gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
20
+ "#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
21
+ end
22
22
  end
23
23
 
24
24
  def self.banner
25
25
  "#{$0} cucumber:feature ModelName [field:type, field:type]"
26
26
  end
27
-
28
- def self.gem_root
29
- File.expand_path("../../../../../", __FILE__)
30
- end
31
-
32
- def self.source_root
33
- File.join(gem_root, 'templates', 'feature')
34
- end
35
-
36
27
  end
37
28
  end
@@ -9,6 +9,8 @@ class NamedArg
9
9
  def value(n)
10
10
  if @type == 'boolean'
11
11
  (n % 2) == 0
12
+ elsif @type == 'integer'
13
+ n
12
14
  else
13
15
  "#{@name} #{n}"
14
16
  end
@@ -25,28 +25,26 @@ Feature: Manage <%= plural_name %>
25
25
  # Rails generates Delete links that use Javascript to pop up a confirmation
26
26
  # dialog and then do a HTTP POST request (emulated DELETE request).
27
27
  #
28
- # Capybara must use Culerity or Selenium2 (webdriver) when pages rely on
29
- # Javascript events. Only Culerity supports confirmation dialogs.
28
+ # Capybara must use Culerity/Celerity or Selenium2 (webdriver) when pages rely
29
+ # on Javascript events. Only Culerity/Celerity supports clicking on confirmation
30
+ # dialogs.
30
31
  #
31
- # Since Culerity and Selenium2 has some overhead, Cucumber-Rails will detect
32
- # the presence of Javascript behind Delete links and issue a DELETE request
32
+ # Since Culerity/Celerity and Selenium2 has some overhead, Cucumber-Rails will
33
+ # detect the presence of Javascript behind Delete links and issue a DELETE request
33
34
  # instead of a GET request.
34
35
  #
35
- # You can turn off this emulation by tagging your scenario with @selenium,
36
- # @culerity, @celerity or @javascript. (See the Capybara documentation for
37
- # details about those tags). If any of these tags are present, Cucumber-Rails
36
+ # You can turn this emulation off by tagging your scenario with @no-js-emulation.
37
+ # Turning on browser testing with @selenium, @culerity, @celerity or @javascript
38
+ # will also turn off the emulation. (See the Capybara documentation for
39
+ # details about those tags). If any of the browser tags are present, Cucumber-Rails
38
40
  # will also turn off transactions and clean the database with DatabaseCleaner
39
41
  # after the scenario has finished. This is to prevent data from leaking into
40
42
  # the next scenario.
41
43
  #
42
- # Another way to avoid Cucumber-Rails'' javascript emulation without using any
44
+ # Another way to avoid Cucumber-Rails' javascript emulation without using any
43
45
  # of the tags above is to modify your views to use <button> instead. You can
44
46
  # see how in http://github.com/jnicklas/capybara/issues#issue/12
45
47
  #
46
- # TODO: Verify with Rob what this means: The rack driver will detect the
47
- # onclick javascript and emulate its behaviour without a real Javascript
48
- # interpreter.
49
- #
50
48
  <% if options[:capybara] -%>
51
49
  @<%= options[:capybara] %>
52
50
  <% end -%>
@@ -3,7 +3,7 @@ Given /^the following <%= plural_name %>:$/ do |<%= plural_name %>|
3
3
  end
4
4
 
5
5
  When /^I delete the (\d+)(?:st|nd|rd|th) <%= singular_name %>$/ do |pos|
6
- visit <%= plural_name %>_url
6
+ visit <%= plural_name %>_path
7
7
  within("table tr:nth-child(#{pos.to_i+1})") do
8
8
  click_link "Destroy"
9
9
  end
@@ -0,0 +1,15 @@
1
+ Description:
2
+ Sets up Cucumber in your Rails project. After running this generator you will
3
+ get a new rake task called features.
4
+
5
+ This also generates the necessary files in the features directory.
6
+
7
+ Also see the cucumber:feature generator.
8
+
9
+ Examples:
10
+ `rails generate cucumber:install`
11
+
12
+ `rails generate cucumber:install --help`
13
+
14
+ You can also provide a language argument for localized web_steps:
15
+ `rails generate cucumber:install de`
@@ -0,0 +1,88 @@
1
+ require 'rbconfig'
2
+
3
+ module Cucumber
4
+ class InstallGenerator < ::Rails::Generators::Base
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
8
+
9
+ argument :language, :type => :string, :banner => "LANG", :optional => true
10
+
11
+ class_option :rspec, :type => :boolean, :desc => "Use RSpec"
12
+ class_option :testunit, :type => :boolean, :desc => "Use Test::Unit"
13
+ class_option :spork, :type => :boolean, :desc => "Use Spork"
14
+ class_option :skip_database, :type => :boolean, :desc => "Skip modification of database.yml", :aliases => '-D', :default => false
15
+
16
+ attr_reader :framework
17
+
18
+ def create_templates
19
+ template 'config/cucumber.yml.erb', 'config/cucumber.yml'
20
+ end
21
+
22
+ def create_scripts
23
+ copy_file 'script/cucumber', 'script/cucumber'
24
+ chmod 'script/cucumber', 0755
25
+ end
26
+
27
+ def create_step_definitions
28
+ empty_directory 'features/step_definitions'
29
+
30
+ template "step_definitions/web_steps.rb.erb", 'features/step_definitions/web_steps.rb'
31
+ if language
32
+ template "step_definitions/web_steps_#{language}.rb.erb", "features/step_definitions/web_steps_#{language}.rb"
33
+ end
34
+ end
35
+
36
+ def create_feature_support
37
+ empty_directory 'features/support'
38
+ copy_file 'support/paths.rb', 'features/support/paths.rb'
39
+ copy_file 'support/selectors.rb', 'features/support/selectors.rb'
40
+
41
+ if spork?
42
+ template 'support/rails_spork.rb.erb', 'features/support/env.rb'
43
+ else
44
+ template 'support/rails.rb.erb', 'features/support/env.rb'
45
+ end
46
+ end
47
+
48
+ def create_tasks
49
+ empty_directory 'lib/tasks'
50
+ template 'tasks/cucumber.rake.erb', 'lib/tasks/cucumber.rake'
51
+ end
52
+
53
+ def create_database
54
+ return unless File.exist?('config/database.yml')
55
+ unless File.read('config/database.yml').include? 'cucumber:'
56
+ gsub_file 'config/database.yml', /^test:.*\n/, "test: &test\n"
57
+ gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *test"
58
+
59
+ # Since gsub_file doesn't ask the user, just inform user that the file was overwritten.
60
+ puts " force config/database.yml"
61
+ end
62
+ end
63
+
64
+ protected
65
+
66
+ def spork?
67
+ options[:spork]
68
+ end
69
+
70
+ def embed_file(source, indent='')
71
+ IO.read(File.join(self.class.source_root, source)).gsub(/^/, indent)
72
+ end
73
+
74
+ def embed_template(source, indent='')
75
+ template = File.join(self.class.source_root, source)
76
+ ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
77
+ end
78
+
79
+ private
80
+
81
+ def framework_from_options
82
+ return 'rspec-rails' if options[:rspec]
83
+ return 'testunit' if options[:testunit]
84
+ return 'rspec-rails'
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,8 @@
1
+ <%%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= spork? ? '--drb ' : '' %><%%= std_opts %> features
7
+ wip: <%= spork? ? '--drb ' : '' %>--tags @wip:3 --wip features
8
+ rerun: <%= spork? ? '--drb ' : '' %><%%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,192 @@
1
+ <%= embed_file('support/web_steps_warning.txt') %>
2
+
3
+ require 'uri'
4
+ require 'cgi'
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
6
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
7
+
8
+ module WithinHelpers
9
+ def with_scope(locator)
10
+ locator ? within(*selector_for(locator)) { yield } : yield
11
+ end
12
+ end
13
+ World(WithinHelpers)
14
+
15
+ # Single-line step scoper
16
+ When /^(.*) within (.*[^:])$/ do |step, parent|
17
+ with_scope(parent) { When step }
18
+ end
19
+
20
+ # Multi-line step scoper
21
+ When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
22
+ with_scope(parent) { When "#{step}:", table_or_string }
23
+ end
24
+
25
+ Given /^(?:|I )am on (.+)$/ do |page_name|
26
+ visit path_to(page_name)
27
+ end
28
+
29
+ When /^(?:|I )go to (.+)$/ do |page_name|
30
+ visit path_to(page_name)
31
+ end
32
+
33
+ When /^(?:|I )press "([^"]*)"$/ do |button|
34
+ click_button(button)
35
+ end
36
+
37
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
38
+ click_link(link)
39
+ end
40
+
41
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
42
+ fill_in(field, :with => value)
43
+ end
44
+
45
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
46
+ fill_in(field, :with => value)
47
+ end
48
+
49
+ # Use this to fill in an entire form with data from a table. Example:
50
+ #
51
+ # When I fill in the following:
52
+ # | Account Number | 5002 |
53
+ # | Expiry date | 2009-11-01 |
54
+ # | Note | Nice guy |
55
+ # | Wants Email? | |
56
+ #
57
+ # TODO: Add support for checkbox, select og option
58
+ # based on naming conventions.
59
+ #
60
+ When /^(?:|I )fill in the following:$/ do |fields|
61
+ fields.rows_hash.each do |name, value|
62
+ When %{I fill in "#{name}" with "#{value}"}
63
+ end
64
+ end
65
+
66
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
67
+ select(value, :from => field)
68
+ end
69
+
70
+ When /^(?:|I )check "([^"]*)"$/ do |field|
71
+ check(field)
72
+ end
73
+
74
+ When /^(?:|I )uncheck "([^"]*)"$/ do |field|
75
+ uncheck(field)
76
+ end
77
+
78
+ When /^(?:|I )choose "([^"]*)"$/ do |field|
79
+ choose(field)
80
+ end
81
+
82
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
83
+ attach_file(field, File.expand_path(path))
84
+ end
85
+
86
+ Then /^(?:|I )should see "([^"]*)"$/ do |text|
87
+ if page.respond_to? :should
88
+ page.should have_content(text)
89
+ else
90
+ assert page.has_content?(text)
91
+ end
92
+ end
93
+
94
+ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
95
+ regexp = Regexp.new(regexp)
96
+
97
+ if page.respond_to? :should
98
+ page.should have_xpath('//*', :text => regexp)
99
+ else
100
+ assert page.has_xpath?('//*', :text => regexp)
101
+ end
102
+ end
103
+
104
+ Then /^(?:|I )should not see "([^"]*)"$/ do |text|
105
+ if page.respond_to? :should
106
+ page.should have_no_content(text)
107
+ else
108
+ assert page.has_no_content?(text)
109
+ end
110
+ end
111
+
112
+ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
113
+ regexp = Regexp.new(regexp)
114
+
115
+ if page.respond_to? :should
116
+ page.should have_no_xpath('//*', :text => regexp)
117
+ else
118
+ assert page.has_no_xpath?('//*', :text => regexp)
119
+ end
120
+ end
121
+
122
+ Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
123
+ with_scope(parent) do
124
+ field = find_field(field)
125
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
126
+ if field_value.respond_to? :should
127
+ field_value.should =~ /#{value}/
128
+ else
129
+ assert_match(/#{value}/, field_value)
130
+ end
131
+ end
132
+ end
133
+
134
+ Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
135
+ with_scope(parent) do
136
+ field = find_field(field)
137
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
138
+ if field_value.respond_to? :should_not
139
+ field_value.should_not =~ /#{value}/
140
+ else
141
+ assert_no_match(/#{value}/, field_value)
142
+ end
143
+ end
144
+ end
145
+
146
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
147
+ with_scope(parent) do
148
+ field_checked = find_field(label)['checked']
149
+ if field_checked.respond_to? :should
150
+ field_checked.should be_true
151
+ else
152
+ assert field_checked
153
+ end
154
+ end
155
+ end
156
+
157
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
158
+ with_scope(parent) do
159
+ field_checked = find_field(label)['checked']
160
+ if field_checked.respond_to? :should
161
+ field_checked.should be_false
162
+ else
163
+ assert !field_checked
164
+ end
165
+ end
166
+ end
167
+
168
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
169
+ current_path = URI.parse(current_url).path
170
+ if current_path.respond_to? :should
171
+ current_path.should == path_to(page_name)
172
+ else
173
+ assert_equal path_to(page_name), current_path
174
+ end
175
+ end
176
+
177
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
178
+ query = URI.parse(current_url).query
179
+ actual_params = query ? CGI.parse(query) : {}
180
+ expected_params = {}
181
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
182
+
183
+ if actual_params.respond_to? :should
184
+ actual_params.should == expected_params
185
+ else
186
+ assert_equal expected_params, actual_params
187
+ end
188
+ end
189
+
190
+ Then /^show me the page$/ do
191
+ save_and_open_page
192
+ end
@@ -0,0 +1,127 @@
1
+ # encoding: utf-8
2
+ <%= embed_file('support/web_steps_warning.txt') %>
3
+
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
6
+
7
+ # Single-line step scoper
8
+ When /^(.*) uvnitř ([^:]+)$/ do |step, parent|
9
+ with_scope(parent) { When step }
10
+ end
11
+
12
+ # Multi-line step scoper
13
+ When /^(.*) uvnitř ([^:]+):$/ do |step, parent, table_or_string|
14
+ with_scope(parent) { When "#{step}:", table_or_string }
15
+ end
16
+
17
+ Given /^jsem na (.+)$/ do |page_name|
18
+ Given %{I am on #{page_name}}
19
+ end
20
+
21
+ When /^jdu na (.+)$/ do |page_name|
22
+ When %{I go to #{page_name}}
23
+ end
24
+
25
+ When /^stisknu tlačítko "([^"]*)"$/ do |button|
26
+ When %{I press "#{button}"}
27
+ end
28
+
29
+ When /^kliknu na "([^"]*)"$/ do |link|
30
+ When %{I follow "#{link}"}
31
+ end
32
+
33
+ When /^vyplním pole "([^"]*)" hodnotou "([^"]*)"$/ do |field, value|
34
+ When %{I fill in "#{field}" with "#{value}"}
35
+ end
36
+
37
+ When /^vyplním "([^"]*)" do pole "([^"]*)"$/ do |value, field|
38
+ When %{I fill in "#{value}" for "#{field}"}
39
+ end
40
+
41
+ When /^vyplním následující:$/ do |fields|
42
+ When %{I fill in the following:}, fields
43
+ end
44
+
45
+ When /^vyberu "([^"]*)" z "([^"]*)"$/ do |value, field|
46
+ When %{I select "#{value}" from "#{field}"}
47
+ end
48
+
49
+ When /^vyberu "([^"]*)" jako datum a čas$/ do |time|
50
+ When %{I select "#{time}" as the date and time}
51
+ end
52
+
53
+ When /^vyberu "([^"]*)" jako "([^"]*)" datum a čas$/ do |datetime, datetime_label|
54
+ When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
55
+ end
56
+
57
+ When /^vyberu "([^"]*)" jako čas$/ do |time|
58
+ When %{I select "#{time}" as the time}
59
+ end
60
+
61
+ When /^vyberu "([^"]*)" jako "([^"]*)" čas$/ do |time, time_label|
62
+ When %{I select "#{time}" as the "#{time_label}" time}
63
+ end
64
+
65
+ When /^vyberu cd jako datum$/ do |date|
66
+ When %{I select "#{date}" as the date}
67
+ end
68
+
69
+ When /^vyberu "([^"]*)" jako "([^"]*)" datum$/ do |date, date_label|
70
+ When %{I select "#{date}" as the "#{date_label}" date}
71
+ end
72
+
73
+ When /^zaškrtnu "([^"]*)"$/ do |field|
74
+ When %{I check "#{field}"}
75
+ end
76
+
77
+ When /^vyškrtnu "([^"]*)"$/ do |field|
78
+ When %{I uncheck "#{field}"}
79
+ end
80
+
81
+ When /^vyberu "([^"]*)"$/ do |field|
82
+ When %{I choose "#{field}"}
83
+ end
84
+
85
+ When /^připojím soubor "([^"]*)" do pole "([^"]*)"$/ do |path, field|
86
+ When %{I attach the file "#{path}" to "#{field}"}
87
+ end
88
+
89
+ Then /^(?:|také )bych měl vidět "([^"]*)"$/ do |text|
90
+ Then %{I should see "#{text}"}
91
+ end
92
+
93
+ Then /^(?:|také )bych měl vidět \/([^\/]*)\/$/ do |regexp|
94
+ Then %{I should see /#{regexp}/}
95
+ end
96
+
97
+ Then /^(?:|také )bych neměl vidět "([^"]*)"$/ do |text|
98
+ Then %{I should not see "#{text}"}
99
+ end
100
+
101
+ Then /^(?:|také )bych neměl vidět \/([^\/]*)\/$/ do |regexp|
102
+ Then %{I should not see /#{regexp}/}
103
+ end
104
+
105
+ Then /^pole "([^"]*)" by mělo obsahovat "([^"]*)"$/ do |field, value|
106
+ Then %{the "#{field}" field should contain "#{value}"}
107
+ end
108
+
109
+ Then /^pole "([^"]*)" by nemělo obsahovat "([^"]*)"$/ do |field, value|
110
+ Then %{the "#{field}" field should not contain "#{value}"}
111
+ end
112
+
113
+ Then /^pole "([^"]*)" by mělo být zaškrtnuté$/ do |label|
114
+ Then %{the "#{label}" checkbox should be checked}
115
+ end
116
+
117
+ Then /^pole "([^"]*)" by nemělo být zaškrtnuté$/ do |label|
118
+ Then %{the "#{label}" checkbox should not be checked}
119
+ end
120
+
121
+ Then /^(?:|také )bych měl být na (.+)$/ do |page_name|
122
+ Then %{I should be on #{page_name}}
123
+ end
124
+
125
+ Then /^(?:|také )mi ukaž stránku$/ do
126
+ Then %{show me the page}
127
+ end
@@ -0,0 +1,105 @@
1
+ # encoding: utf-8
2
+ <%= embed_file('support/web_steps_warning.txt') %>
3
+
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
6
+
7
+ # Single-line step scoper
8
+ Når /^(.*) under ([^:]+)$/ do |step, parent|
9
+ with_scope(parent) { Når step }
10
+ end
11
+
12
+ # Multi-line step scoper
13
+ Når /^(.*) under ([^:]+):$/ do |step, parent, table_or_string|
14
+ with_scope(parent) { Når "#{step}:", table_or_string }
15
+ end
16
+
17
+ Givet /^(?:|at )jeg står på (.*)$/ do |page_name|
18
+ Given %{I am on #{page_name}}
19
+ end
20
+
21
+ Når /^jeg går til (.*)$/ do |page_name|
22
+ When %{I go to #{page_name}}
23
+ end
24
+
25
+ Når /^jeg trykker "([^"]*)"$/ do |button|
26
+ When %{I press "#{button}"}
27
+ end
28
+
29
+ Når /^jeg klikker "([^"]*)"$/ do |link|
30
+ When %{I follow "#{link}"}
31
+ end
32
+
33
+ Når /^jeg fylder ud "([^"]*)" med "([^"]*)"$/ do |field, value|
34
+ When %{I fill in "#{field}" with "#{value}"}
35
+ end
36
+
37
+ Når /^jeg fylder ud "([^"]*)" for "([^"]*)"$/ do |value, field|
38
+ When %{I fill in "#{value}" for "#{field}"}
39
+ end
40
+
41
+ Når /^jeg fylder følgende ud:$/ do |fields|
42
+ When %{I fill in the following:}, fields
43
+ end
44
+
45
+ Når /^jeg vælger "([^"]*)" fra "([^"]*)"$/ do |value, field|
46
+ When %{I select "#{value}" from "#{field}"}
47
+ end
48
+
49
+ # Missing: date stuff
50
+
51
+ Når /^jeg afkrydser "([^"]*)"$/ do |field|
52
+ When %{I check "#{field}"}
53
+ end
54
+
55
+ Når /^jeg fjerner afkrydsning for "([^"]*)"$/ do |field|
56
+ When %{I uncheck "#{field}"}
57
+ end
58
+
59
+ Når /^jeg vælger "([^"]*)"$/ do |field|
60
+ When %{I choose "#{field}"}
61
+ end
62
+
63
+ Når /^jeg tilsætter filen "([^"]*)" til "([^"]*)"$/ do |path, field|
64
+ When %{I attach the file "#{path}" to "#{field}"}
65
+ end
66
+
67
+ Så /^(?:skal jeg|jeg skal) se "([^"]*)"$/ do |text|
68
+ Then %{I should see "#{text}"}
69
+ end
70
+
71
+ Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/$/ do |regexp|
72
+ Then %{I should see /#{regexp}/}
73
+ end
74
+
75
+ Så /^(?:skal jeg|jeg skal) ikke se "([^"]*)"$/ do |text|
76
+ Then %{I should not see "#{text}"}
77
+ end
78
+
79
+ Så /^(?:skal jeg|jeg skal) ikke se \/([^\/]*)\/$/ do |regexp|
80
+ Then %{I should not see /#{regexp}/}
81
+ end
82
+
83
+ Så /^(?:skal )"([^"]*)" feltet (?:skal )indeholde "([^"]*)"$/ do |field, value|
84
+ Then %{the "#{field}" field should contain "#{value}"}
85
+ end
86
+
87
+ Så /^(?:skal ) "([^"]*)" feltet (?:skal )ikke indeholde "([^"]*)"$/ do |field, value|
88
+ Then %{the "#{field}" field should not contain "#{value}"}
89
+ end
90
+
91
+ Så /^(?:skal ) "([^"]*)" afkrydsningsboksen (?:skal )være krydset af$/ do |label|
92
+ Then %{the "#{label}" checkbox should be checked}
93
+ end
94
+
95
+ Så /^(?:skal ) "([^"]*)" afkrydsningsboksen (?:skal )ikke være krydset af$/ do |label|
96
+ Then %{the "#{label}" checkbox should not be checked}
97
+ end
98
+
99
+ Så /^(?:skal jeg|jeg skal) komme til (.+)$/ do |page_name|
100
+ Then %{I should be on #{page_name}}
101
+ end
102
+
103
+ Så /^vil jeg se siden$/ do |page_name|
104
+ Then %{show me the page}
105
+ end