bts-cucumber 0.1.13.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +297 -0
- data/License.txt +20 -0
- data/Manifest.txt +240 -0
- data/README.txt +4 -0
- data/Rakefile +8 -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 +1 -0
- data/examples/cs/Rakefile +12 -0
- data/examples/cs/compile.bat +1 -0
- data/examples/cs/features/addition.feature +17 -0
- data/examples/cs/features/step_definitons/calculator_steps.rb +23 -0
- data/examples/cs/src/demo/Calculator.cs +20 -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 +26 -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 +131 -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 +346 -0
- data/lib/cucumber/core_ext/proc.rb +69 -0
- data/lib/cucumber/core_ext/string.rb +29 -0
- data/lib/cucumber/executor.rb +188 -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 +10 -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 +175 -0
- data/lib/cucumber/tree/step.rb +142 -0
- data/lib/cucumber/tree/table.rb +26 -0
- data/lib/cucumber/tree/top_down_visitor.rb +23 -0
- data/lib/cucumber/tree.rb +16 -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-lol.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 +11 -0
- data/rails_generators/cucumber/templates/webrat_steps.rb +93 -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 +468 -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 +333 -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,11 @@
|
|
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
|
+
require 'webrat/rails'
|
8
|
+
|
9
|
+
# Comment out the next two lines if you're not using RSpec's matchers (should / should_not) in your steps.
|
10
|
+
require 'cucumber/rails/rspec'
|
11
|
+
require 'webrat/rspec-rails'
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# Commonly used webrat steps
|
2
|
+
# http://github.com/brynary/webrat
|
3
|
+
|
4
|
+
When /^I press "(.*)"$/ do |button|
|
5
|
+
click_button(button)
|
6
|
+
end
|
7
|
+
|
8
|
+
When /^I follow "(.*)"$/ do |link|
|
9
|
+
click_link(link)
|
10
|
+
end
|
11
|
+
|
12
|
+
When /^I fill in "(.*)" with "(.*)"$/ do |field, value|
|
13
|
+
fill_in(field, :with => value)
|
14
|
+
end
|
15
|
+
|
16
|
+
When /^I select "(.*)" from "(.*)"$/ do |value, field|
|
17
|
+
select(value, :from => field)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
21
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
22
|
+
When /^I select "(.*)" as the date and time$/ do |time|
|
23
|
+
select_datetime(time)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
27
|
+
# you want to specify which datetime to select. Given the following view:
|
28
|
+
# <%= f.label :preferred %><br />
|
29
|
+
# <%= f.datetime_select :preferred %>
|
30
|
+
# <%= f.label :alternative %><br />
|
31
|
+
# <%= f.datetime_select :alternative %>
|
32
|
+
# The following steps would fill out the form:
|
33
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" data and time
|
34
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" data and time
|
35
|
+
When /^I select "(.*)" as the "(.*)" date and time$/ do |datetime, datetime_label|
|
36
|
+
select_datetime(datetime, :from => datetime_label)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Use this step in conjuction with Rail's time_select helper. For example:
|
40
|
+
# When I select "2:20PM" as the time
|
41
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
42
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
43
|
+
When /^I select "(.*)" as the time$/ do |time|
|
44
|
+
select_time(time)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
48
|
+
# specify the name of the time on the form. For example:
|
49
|
+
# When I select "7:30AM" as the "Gym" time
|
50
|
+
When /^I select "(.*)" as the "(.*)" time$/ do |time, time_label|
|
51
|
+
select_time(time, :from => time_label)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Use this step in conjuction with Rail's date_select helper. For example:
|
55
|
+
# When I select "February 20, 1981" as the date
|
56
|
+
When /^I select "(.*)" as the date$/ do |date|
|
57
|
+
select_date(date)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Use this step when using multiple date_select helpers on one page or
|
61
|
+
# you want to specify the name of the date on the form. For example:
|
62
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
63
|
+
When /^I select "(.*)" as the "(.*)" date$/ do |date, date_label|
|
64
|
+
select_date(date, :from => date_label)
|
65
|
+
end
|
66
|
+
|
67
|
+
When /^I check "(.*)"$/ do |field|
|
68
|
+
check(field)
|
69
|
+
end
|
70
|
+
|
71
|
+
When /^I uncheck "(.*)"$/ do |field|
|
72
|
+
uncheck(field)
|
73
|
+
end
|
74
|
+
|
75
|
+
When /^I choose "(.*)"$/ do |field|
|
76
|
+
choose(field)
|
77
|
+
end
|
78
|
+
|
79
|
+
When /^I attach the file at "(.*)" to "(.*)" $/ do |path, field|
|
80
|
+
attach_file(field, path)
|
81
|
+
end
|
82
|
+
|
83
|
+
Then /^I should see "(.*)"$/ do |text|
|
84
|
+
response.body.should =~ /#{text}/m
|
85
|
+
end
|
86
|
+
|
87
|
+
Then /^I should not see "(.*)"$/ do |text|
|
88
|
+
response.body.should_not =~ /#{text}/m
|
89
|
+
end
|
90
|
+
|
91
|
+
Then /^the "(.*)" checkbox should be checked$/ do |label|
|
92
|
+
field_labeled(label).should be_checked
|
93
|
+
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
|
+
visit "/<%= 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
|
+
visit <%= plural_name %>_url
|
16
|
+
click_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 %*
|