jeffrafter-cucumber 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +262 -0
- data/License.txt +20 -0
- data/Manifest.txt +241 -0
- data/README.txt +41 -0
- data/Rakefile +8 -0
- data/TODO.txt +26 -0
- data/bin/cucumber +6 -0
- data/config/hoe.rb +69 -0
- data/config/requirements.rb +15 -0
- data/cucumber.yml +1 -0
- data/examples/calculator_ruby_features/Rakefile +6 -0
- data/examples/calculator_ruby_features/features/addition.rb +23 -0
- data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +43 -0
- data/examples/cs/README.textile +22 -0
- data/examples/cs/Rakefile +12 -0
- data/examples/cs/features/hello.feature +11 -0
- data/examples/cs/features/step_definitons/hello_steps.rb +25 -0
- data/examples/cs/features/step_definitons/tree_steps.rb +14 -0
- data/examples/cs/features/tree.feature +9 -0
- data/examples/cs/src/Hello.cs +18 -0
- data/examples/dos_line_endings/Rakefile +6 -0
- data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
- data/examples/i18n/README.textile +18 -0
- data/examples/i18n/Rakefile +16 -0
- data/examples/i18n/ar/Rakefile +6 -0
- data/examples/i18n/ar/features/addition.feature +17 -0
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +32 -0
- data/examples/i18n/ar/lib/calculator.rb +10 -0
- data/examples/i18n/da/Rakefile +6 -0
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +22 -0
- data/examples/i18n/da/features/summering.feature +17 -0
- data/examples/i18n/da/lib/kalkulator.rb +11 -0
- data/examples/i18n/de/Rakefile +6 -0
- data/examples/i18n/de/features/addition.feature +17 -0
- data/examples/i18n/de/features/division.feature +10 -0
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +30 -0
- data/examples/i18n/de/lib/calculator.rb +14 -0
- data/examples/i18n/en/Rakefile +6 -0
- data/examples/i18n/en/features/addition.feature +17 -0
- data/examples/i18n/en/features/division.feature +10 -0
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +31 -0
- data/examples/i18n/en/lib/calculator.rb +14 -0
- data/examples/i18n/es/Rakefile +6 -0
- data/examples/i18n/es/features/adicion.feature +17 -0
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +22 -0
- data/examples/i18n/es/lib/calculador.rb +11 -0
- data/examples/i18n/et/Rakefile +6 -0
- data/examples/i18n/et/features/liitmine.feature +17 -0
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +26 -0
- data/examples/i18n/et/lib/kalkulaator.rb +10 -0
- data/examples/i18n/fr/Rakefile +6 -0
- data/examples/i18n/fr/features/addition.feature +13 -0
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +22 -0
- data/examples/i18n/fr/lib/calculatrice.rb +10 -0
- data/examples/i18n/id/Rakefile +6 -0
- data/examples/i18n/id/features/addition.feature +17 -0
- data/examples/i18n/id/features/division.feature +10 -0
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +31 -0
- data/examples/i18n/id/lib/calculator.rb +14 -0
- data/examples/i18n/it/Rakefile +6 -0
- data/examples/i18n/it/features/somma.feature +10 -0
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +22 -0
- data/examples/i18n/it/lib/calcolatrice.rb +11 -0
- data/examples/i18n/ja/README.txt +5 -0
- data/examples/i18n/ja/Rakefile +6 -0
- data/examples/i18n/ja/features/addition.feature +17 -0
- data/examples/i18n/ja/features/division.feature +10 -0
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +30 -0
- data/examples/i18n/ja/lib/calculator.rb +14 -0
- data/examples/i18n/lt/Rakefile +6 -0
- data/examples/i18n/lt/features/addition.feature +17 -0
- data/examples/i18n/lt/features/division.feature +10 -0
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +31 -0
- data/examples/i18n/lt/lib/calculator.rb +14 -0
- data/examples/i18n/no/Rakefile +6 -0
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +22 -0
- data/examples/i18n/no/features/summering.feature +17 -0
- data/examples/i18n/no/lib/kalkulator.rb +11 -0
- data/examples/i18n/pt/Rakefile +6 -0
- data/examples/i18n/pt/features/adicao.feature +10 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +22 -0
- data/examples/i18n/pt/lib/calculadora.rb +10 -0
- data/examples/i18n/ro/Rakefile +6 -0
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +22 -0
- data/examples/i18n/ro/features/suma.feature +10 -0
- data/examples/i18n/ro/lib/calculator.rb +11 -0
- data/examples/i18n/se/Rakefile +6 -0
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +22 -0
- data/examples/i18n/se/features/summering.feature +17 -0
- data/examples/i18n/se/lib/kalkulator.rb +11 -0
- data/examples/i18n/zh-CN/Rakefile +6 -0
- data/examples/i18n/zh-CN/features/addition.feature +17 -0
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
- data/examples/java/README.textile +22 -0
- data/examples/java/Rakefile +12 -0
- data/examples/java/features/hello.feature +11 -0
- data/examples/java/features/step_definitons/hello_steps.rb +25 -0
- data/examples/java/features/step_definitons/tree_steps.rb +14 -0
- data/examples/java/features/tree.feature +9 -0
- data/examples/java/src/cucumber/demo/Hello.java +16 -0
- data/examples/selenium/Rakefile +6 -0
- data/examples/selenium/features/search.feature +9 -0
- data/examples/selenium/features/step_definitons/stories_steps.rb +41 -0
- data/examples/test_unit/Rakefile +6 -0
- data/examples/test_unit/features/step_definitions/test_unit_steps.rb +26 -0
- data/examples/test_unit/features/test_unit.feature +9 -0
- data/examples/tickets/Rakefile +11 -0
- data/examples/tickets/cucumber.yml +2 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +32 -0
- data/examples/tickets/features/tickets.feature +24 -0
- data/examples/watir/Rakefile +6 -0
- data/examples/watir/features/search.feature +9 -0
- data/examples/watir/features/step_definitons/stories_steps.rb +51 -0
- data/features/see_features.feature +8 -0
- data/features/steps/features_steps.rb +9 -0
- data/gem_tasks/deployment.rake +34 -0
- data/gem_tasks/environment.rake +7 -0
- data/gem_tasks/features.rake +6 -0
- data/gem_tasks/fix_cr_lf.rake +10 -0
- data/gem_tasks/flog.rake +4 -0
- data/gem_tasks/gemspec.rake +6 -0
- data/gem_tasks/rspec.rake +35 -0
- data/gem_tasks/treetop.rake +41 -0
- data/lib/autotest/cucumber.rb +6 -0
- data/lib/autotest/cucumber_mixin.rb +109 -0
- data/lib/autotest/cucumber_rails.rb +6 -0
- data/lib/autotest/cucumber_rails_rspec.rb +6 -0
- data/lib/autotest/cucumber_rspec.rb +6 -0
- data/lib/autotest/discover.rb +9 -0
- data/lib/cucumber/broadcaster.rb +20 -0
- data/lib/cucumber/cli.rb +303 -0
- data/lib/cucumber/core_ext/proc.rb +69 -0
- data/lib/cucumber/core_ext/string.rb +28 -0
- data/lib/cucumber/executor.rb +190 -0
- data/lib/cucumber/formatters/ansicolor.rb +109 -0
- data/lib/cucumber/formatters/autotest_formatter.rb +23 -0
- data/lib/cucumber/formatters/cucumber.css +132 -0
- data/lib/cucumber/formatters/cucumber.js +11 -0
- data/lib/cucumber/formatters/html_formatter.rb +128 -0
- data/lib/cucumber/formatters/jquery.js +32 -0
- data/lib/cucumber/formatters/pretty_formatter.rb +234 -0
- data/lib/cucumber/formatters/profile_formatter.rb +92 -0
- data/lib/cucumber/formatters/progress_formatter.rb +58 -0
- data/lib/cucumber/formatters.rb +1 -0
- data/lib/cucumber/languages.yml +258 -0
- data/lib/cucumber/model/table.rb +28 -0
- data/lib/cucumber/model.rb +1 -0
- data/lib/cucumber/platform.rb +12 -0
- data/lib/cucumber/rails/rspec.rb +12 -0
- data/lib/cucumber/rails/world.rb +73 -0
- data/lib/cucumber/rake/task.rb +101 -0
- data/lib/cucumber/step_methods.rb +49 -0
- data/lib/cucumber/step_mother.rb +95 -0
- data/lib/cucumber/tree/feature.rb +63 -0
- data/lib/cucumber/tree/features.rb +21 -0
- data/lib/cucumber/tree/given_scenario.rb +13 -0
- data/lib/cucumber/tree/scenario.rb +174 -0
- data/lib/cucumber/tree/step.rb +134 -0
- data/lib/cucumber/tree/table.rb +26 -0
- data/lib/cucumber/tree/top_down_visitor.rb +23 -0
- data/lib/cucumber/tree.rb +18 -0
- data/lib/cucumber/treetop_parser/feature.treetop.erb +206 -0
- data/lib/cucumber/treetop_parser/feature_ar.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_cy.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_da.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_de.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_en.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_es.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_et.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_fr.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_id.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_it.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ja.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_lt.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_nl.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_no.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
- data/lib/cucumber/treetop_parser/feature_pl.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_pt.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ro.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ro2.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ru.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_se.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1591 -0
- data/lib/cucumber/version.rb +9 -0
- data/lib/cucumber.rb +38 -0
- data/rails_generators/cucumber/USAGE +11 -0
- data/rails_generators/cucumber/cucumber_generator.rb +30 -0
- data/rails_generators/cucumber/templates/cucumber +7 -0
- data/rails_generators/cucumber/templates/cucumber.rake +7 -0
- data/rails_generators/cucumber/templates/env.rb +8 -0
- data/rails_generators/cucumber/templates/webrat_steps.rb +95 -0
- data/rails_generators/feature/USAGE +12 -0
- data/rails_generators/feature/feature_generator.rb +16 -0
- data/rails_generators/feature/templates/feature.erb +28 -0
- data/rails_generators/feature/templates/steps.erb +22 -0
- data/script/console +10 -0
- data/script/console.cmd +1 -0
- data/script/destroy +14 -0
- data/script/destroy.cmd +1 -0
- data/script/generate +14 -0
- data/script/generate.cmd +1 -0
- data/script/txt2html +74 -0
- data/script/txt2html.cmd +1 -0
- data/setup.rb +1585 -0
- data/spec/cucumber/broadcaster_spec.rb +27 -0
- data/spec/cucumber/cli_spec.rb +412 -0
- data/spec/cucumber/core_ext/proc_spec.rb +45 -0
- data/spec/cucumber/core_ext/string_spec.rb +34 -0
- data/spec/cucumber/executor_spec.rb +298 -0
- data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +26 -0
- data/spec/cucumber/formatters/features.html +269 -0
- data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +204 -0
- data/spec/cucumber/formatters/profile_formatter_spec.rb +192 -0
- data/spec/cucumber/formatters/progress_formatter_spec.rb +65 -0
- data/spec/cucumber/model/table_spec.rb +20 -0
- data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
- data/spec/cucumber/rails/stubs/test_help.rb +1 -0
- data/spec/cucumber/rails/world_spec.rb +11 -0
- data/spec/cucumber/sell_cucumbers.feature +19 -0
- data/spec/cucumber/step_mother_spec.rb +74 -0
- data/spec/cucumber/tree/feature_spec.rb +43 -0
- data/spec/cucumber/tree/row_scenario_spec.rb +55 -0
- data/spec/cucumber/tree/scenario_spec.rb +76 -0
- data/spec/cucumber/tree/step_spec.rb +50 -0
- data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
- data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +98 -0
- data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
- data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
- data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
- data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
- data/spec/cucumber/treetop_parser/spaces.feature +10 -0
- data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
- data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +20 -0
- metadata +335 -0
data/lib/cucumber.rb
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
|
3
|
+
|
|
4
|
+
require 'cucumber/platform'
|
|
5
|
+
require 'rubygems'
|
|
6
|
+
require 'treetop/runtime'
|
|
7
|
+
require 'treetop/ruby_extensions'
|
|
8
|
+
require 'cucumber/version'
|
|
9
|
+
require 'cucumber/step_methods'
|
|
10
|
+
require 'cucumber/tree'
|
|
11
|
+
require 'cucumber/model'
|
|
12
|
+
require 'cucumber/executor'
|
|
13
|
+
require 'cucumber/step_mother'
|
|
14
|
+
require 'cucumber/formatters'
|
|
15
|
+
require 'cucumber/treetop_parser/feature_parser'
|
|
16
|
+
require 'cucumber/cli'
|
|
17
|
+
require 'cucumber/broadcaster'
|
|
18
|
+
|
|
19
|
+
module Cucumber
|
|
20
|
+
LANGUAGE_FILE = File.expand_path(File.dirname(__FILE__) + '/cucumber/languages.yml')
|
|
21
|
+
|
|
22
|
+
class << self
|
|
23
|
+
attr_reader :language
|
|
24
|
+
|
|
25
|
+
def load_language(lang)
|
|
26
|
+
@language = config[lang]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def languages
|
|
30
|
+
config.keys.sort
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def config
|
|
34
|
+
require 'yaml'
|
|
35
|
+
@config ||= YAML.load_file(LANGUAGE_FILE)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
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 feature generator, which you can use to generate skeletons
|
|
8
|
+
for new features.
|
|
9
|
+
|
|
10
|
+
Examples:
|
|
11
|
+
`./script/generate cucumber`
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'rbconfig'
|
|
2
|
+
|
|
3
|
+
# 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
|
+
def manifest
|
|
8
|
+
record do |m|
|
|
9
|
+
m.directory 'features/step_definitions'
|
|
10
|
+
m.file 'webrat_steps.rb', 'features/step_definitions/webrat_steps.rb'
|
|
11
|
+
|
|
12
|
+
m.directory 'features/support'
|
|
13
|
+
m.file 'env.rb', 'features/support/env.rb'
|
|
14
|
+
|
|
15
|
+
m.directory 'lib/tasks'
|
|
16
|
+
m.file 'cucumber.rake', 'lib/tasks/cucumber.rake'
|
|
17
|
+
|
|
18
|
+
m.file 'cucumber', 'script/cucumber', {
|
|
19
|
+
:chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
protected
|
|
25
|
+
|
|
26
|
+
def banner
|
|
27
|
+
"Usage: #{$0} cucumber"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Sets up the Rails environment for Cucumber
|
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
|
4
|
+
require 'cucumber/rails/world'
|
|
5
|
+
Cucumber::Rails.use_transactional_fixtures
|
|
6
|
+
|
|
7
|
+
# Comment out the next line if you're not using RSpec's matchers (should / should_not) in your steps.
|
|
8
|
+
require 'cucumber/rails/rspec'
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Commonly used webrat steps
|
|
2
|
+
# http://github.com/brynary/webrat
|
|
3
|
+
|
|
4
|
+
require 'webrat' if !defined?(Webrat) # Because some people have it installed as a Gem
|
|
5
|
+
|
|
6
|
+
When /^I press "(.*)"$/ do |button|
|
|
7
|
+
clicks_button(button)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
When /^I follow "(.*)"$/ do |link|
|
|
11
|
+
clicks_link(link)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
When /^I fill in "(.*)" with "(.*)"$/ do |field, value|
|
|
15
|
+
fills_in(field, :with => value)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
When /^I select "(.*)" from "(.*)"$/ do |value, field|
|
|
19
|
+
selects(value, :from => field)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
|
23
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
|
24
|
+
When /^I select "(.*)" as the date and time$/ do |time|
|
|
25
|
+
selects_datetime(time)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
|
29
|
+
# you want to specify which datetime to select. Given the following view:
|
|
30
|
+
# <%= f.label :preferred %><br />
|
|
31
|
+
# <%= f.datetime_select :preferred %>
|
|
32
|
+
# <%= f.label :alternative %><br />
|
|
33
|
+
# <%= f.datetime_select :alternative %>
|
|
34
|
+
# The following steps would fill out the form:
|
|
35
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" data and time
|
|
36
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" data and time
|
|
37
|
+
When /^I select "(.*)" as the "(.*)" date and time$/ do |datetime, datetime_label|
|
|
38
|
+
selects_datetime(datetime, :from => datetime_label)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Use this step in conjuction with Rail's time_select helper. For example:
|
|
42
|
+
# When I select "2:20PM" as the time
|
|
43
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
|
44
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
|
45
|
+
When /^I select "(.*)" as the time$/ do |time|
|
|
46
|
+
selects_time(time)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
|
50
|
+
# specify the name of the time on the form. For example:
|
|
51
|
+
# When I select "7:30AM" as the "Gym" time
|
|
52
|
+
When /^I select "(.*)" as the "(.*)" time$/ do |time, time_label|
|
|
53
|
+
selects_time(time, :from => time_label)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Use this step in conjuction with Rail's date_select helper. For example:
|
|
57
|
+
# When I select "February 20, 1981" as the date
|
|
58
|
+
When /^I select "(.*)" as the date$/ do |date|
|
|
59
|
+
selects_date(date)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Use this step when using multiple date_select helpers on one page or
|
|
63
|
+
# you want to specify the name of the date on the form. For example:
|
|
64
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
|
65
|
+
When /^I select "(.*)" as the "(.*)" date$/ do |date, date_label|
|
|
66
|
+
selects_date(date, :from => date_label)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
When /^I check "(.*)"$/ do |field|
|
|
70
|
+
checks(field)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
When /^I uncheck "(.*)"$/ do |field|
|
|
74
|
+
unchecks(field)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
When /^I choose "(.*)"$/ do |field|
|
|
78
|
+
chooses(field)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
When /^I attach the file at "(.*)" to "(.*)" $/ do |path, field|
|
|
82
|
+
attaches_file(field, path)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
Then /^I should see "(.*)"$/ do |text|
|
|
86
|
+
response.body.should =~ /#{text}/m
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
Then /^I should not see "(.*)"$/ do |text|
|
|
90
|
+
response.body.should_not =~ /#{text}/m
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Then /^the "(.*)" checkbox should be checked$/ do |label|
|
|
94
|
+
field_labeled(label).should be_checked
|
|
95
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Generates a skeleton for a new feature. Both a simple .feature file and
|
|
3
|
+
a steps.rb file is generated. This generator should be used with moderation.
|
|
4
|
+
See http://github.com/aslakhellesoy/cucumber/wikis/feature-coupled-steps-antipattern
|
|
5
|
+
for details about the dangers involved.
|
|
6
|
+
|
|
7
|
+
This generator can take an optional list of attribute pairs similar to Rails'
|
|
8
|
+
built-in resource generator.
|
|
9
|
+
|
|
10
|
+
Examples:
|
|
11
|
+
`./script/generate feature post` # no attributes
|
|
12
|
+
`./script/generate feature post title:string body:text published:boolean`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This generator bootstraps a Rails project for use with Cucumber
|
|
2
|
+
class FeatureGenerator < Rails::Generator::NamedBase
|
|
3
|
+
def manifest
|
|
4
|
+
record do |m|
|
|
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"
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
protected
|
|
12
|
+
|
|
13
|
+
def banner
|
|
14
|
+
"Usage: #{$0} feature ModelName [field:type, field:type]"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Feature: Manage <%= plural_name %>
|
|
2
|
+
In order to [goal]
|
|
3
|
+
[stakeholder]
|
|
4
|
+
wants [behaviour]
|
|
5
|
+
|
|
6
|
+
Scenario: Register new <%= singular_name %>
|
|
7
|
+
Given I am on the new <%= singular_name %> page
|
|
8
|
+
<% keyword = 'When' -%>
|
|
9
|
+
<% args.each do |arg| -%>
|
|
10
|
+
<%= keyword %> I fill in "<%= arg.humanize %>" with "My <%= singular_name %> <%= arg %>"
|
|
11
|
+
<% keyword = 'And' -%>
|
|
12
|
+
<% end -%>
|
|
13
|
+
And I press "Create"
|
|
14
|
+
<% keyword = 'Then' -%>
|
|
15
|
+
<% args.each do |arg| -%>
|
|
16
|
+
<%= keyword %> I should see "My <%= singular_name %> <%= arg %>"
|
|
17
|
+
<% keyword = 'And' -%>
|
|
18
|
+
<% end -%>
|
|
19
|
+
|
|
20
|
+
Scenario: Delete <%= singular_name %>
|
|
21
|
+
Given there are 4 <%= plural_name %>
|
|
22
|
+
When I delete the first <%= singular_name %>
|
|
23
|
+
Then there should be 3 <%= plural_name %> left
|
|
24
|
+
|
|
25
|
+
More Examples:
|
|
26
|
+
| initial | after |
|
|
27
|
+
| 100 | 99 |
|
|
28
|
+
| 1 | 0 |
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Given /I am on the new <%= singular_name %> page/ do
|
|
2
|
+
visits "/<%= plural_name %>/new"
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Given /there are (\d+) <%= plural_name %>/ do |n|
|
|
6
|
+
<%= class_name %>.transaction do
|
|
7
|
+
<%= class_name %>.destroy_all
|
|
8
|
+
n.to_i.times do |n|
|
|
9
|
+
<%= class_name %>.create! :name => "<%= class_name %> #{n}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
When /I delete the first <%= singular_name %>/ do
|
|
15
|
+
visits <%= plural_name %>_url
|
|
16
|
+
clicks_link "Destroy"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Then /there should be (\d+) <%= plural_name %> left/ do |n|
|
|
20
|
+
<%= class_name %>.count.should == n.to_i
|
|
21
|
+
response.should have_tag("table tr", n.to_i + 1) # There is a header row too
|
|
22
|
+
end
|
data/script/console
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# File: script/console
|
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
|
4
|
+
|
|
5
|
+
libs = " -r irb/completion"
|
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/cucumber.rb'}"
|
|
9
|
+
visit_feature "Loading cucumber gem"
|
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/console.cmd
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@ruby script/console %*
|
data/script/destroy
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/destroy'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/destroy.cmd
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@ruby script/destroy %*
|
data/script/generate
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/generate'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/generate.cmd
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@ruby script/generate %*
|
data/script/txt2html
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
begin
|
|
5
|
+
require 'newgem'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
puts "\n\nGenerating the website requires the newgem RubyGem"
|
|
8
|
+
puts "Install: gem install newgem\n\n"
|
|
9
|
+
exit(1)
|
|
10
|
+
end
|
|
11
|
+
require 'redcloth'
|
|
12
|
+
require 'syntax/convertors/html'
|
|
13
|
+
require 'erb'
|
|
14
|
+
require File.dirname(__FILE__) + '/../lib/cucumber/version.rb'
|
|
15
|
+
|
|
16
|
+
version = Cucumber::VERSION::STRING
|
|
17
|
+
download = 'http://rubyforge.org/projects/cucumber'
|
|
18
|
+
|
|
19
|
+
class Fixnum
|
|
20
|
+
def ordinal
|
|
21
|
+
# teens
|
|
22
|
+
return 'th' if (10..19).include?(self % 100)
|
|
23
|
+
# others
|
|
24
|
+
case self % 10
|
|
25
|
+
when 1: return 'st'
|
|
26
|
+
when 2: return 'nd'
|
|
27
|
+
when 3: return 'rd'
|
|
28
|
+
else return 'th'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class Time
|
|
34
|
+
def pretty
|
|
35
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def convert_syntax(syntax, source)
|
|
40
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if ARGV.length >= 1
|
|
44
|
+
src, template = ARGV
|
|
45
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
|
46
|
+
|
|
47
|
+
else
|
|
48
|
+
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
|
49
|
+
exit!
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
template = ERB.new(File.open(template).read)
|
|
53
|
+
|
|
54
|
+
title = nil
|
|
55
|
+
body = nil
|
|
56
|
+
File.open(src) do |fsrc|
|
|
57
|
+
title_text = fsrc.readline
|
|
58
|
+
body_text = fsrc.read
|
|
59
|
+
syntax_items = []
|
|
60
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
|
61
|
+
ident = syntax_items.length
|
|
62
|
+
element, syntax, source = $1, $2, $3
|
|
63
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
|
64
|
+
"syntax-temp-#{ident}"
|
|
65
|
+
}
|
|
66
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
|
67
|
+
body = RedCloth.new(body_text).to_html
|
|
68
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
|
69
|
+
end
|
|
70
|
+
stat = File.stat(src)
|
|
71
|
+
created = stat.ctime
|
|
72
|
+
modified = stat.mtime
|
|
73
|
+
|
|
74
|
+
$stdout << template.result(binding)
|
data/script/txt2html.cmd
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@ruby script/txt2html %*
|