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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec'
|
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
|
3
|
+
require 'calculator'
|
|
4
|
+
|
|
5
|
+
Before do
|
|
6
|
+
@calc = Calculator.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
After do
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Given "我已经在计算器里输入$n" do |n|
|
|
13
|
+
@calc.push n.to_i
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
When /我按(.*)按钮/ do |op|
|
|
17
|
+
if op == '相加'
|
|
18
|
+
@result = @calc.send "add"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
Then /我应该在屏幕上看到的结果是(.*)/ do |result|
|
|
23
|
+
@result.should == result.to_f
|
|
24
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
h1. Using Cucumber with Java
|
|
2
|
+
|
|
3
|
+
This directory contains code to demonstrate how Cucumber can be used to develop Java code.
|
|
4
|
+
You need JRuby 1.1.3 or higher installed and JRuby's bin directory on your PATH.
|
|
5
|
+
|
|
6
|
+
h2. Installing required gems
|
|
7
|
+
|
|
8
|
+
jruby -S gem install aslakhellesoy-cucumber
|
|
9
|
+
jruby -S gem install diff-lcs
|
|
10
|
+
|
|
11
|
+
h2. Running the scenarios
|
|
12
|
+
|
|
13
|
+
Open a shell in this directory (java) and execute the following command:
|
|
14
|
+
|
|
15
|
+
<pre><code>
|
|
16
|
+
jruby -S rake features
|
|
17
|
+
</code></pre>
|
|
18
|
+
|
|
19
|
+
This will compile the java code and package it in a jar file, and then run Cucumber against
|
|
20
|
+
that code.
|
|
21
|
+
|
|
22
|
+
There is a deliberate error. See if you can fix it!
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
|
2
|
+
require 'cucumber/rake/task'
|
|
3
|
+
|
|
4
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
|
5
|
+
t.cucumber_opts = "--format pretty"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
task :features => :compile
|
|
9
|
+
|
|
10
|
+
task :compile do
|
|
11
|
+
sh "javac src/cucumber/demo/Hello.java && jar cf src/cucumber_demo.jar -C src cucumber/demo/Hello.class"
|
|
12
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Feature: Hello
|
|
2
|
+
In order to have more friends
|
|
3
|
+
I want to say hello
|
|
4
|
+
|
|
5
|
+
Scenario: Personal greeting
|
|
6
|
+
Given my name is Aslak
|
|
7
|
+
When I greet David
|
|
8
|
+
Then he should hear Hi, David. I'm Aslak.
|
|
9
|
+
And I should remember David as a friend
|
|
10
|
+
And I should get David's phone number
|
|
11
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec' # so we can call .should
|
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../src') # so the jar is found
|
|
3
|
+
require 'cucumber_demo' # puts the jar on the classpath
|
|
4
|
+
include_class 'cucumber.demo.Hello'
|
|
5
|
+
|
|
6
|
+
Given /my name is (\w+)/ do |name|
|
|
7
|
+
@hello = Hello.new # A java object
|
|
8
|
+
@name = name
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
When /I greet (.*)/ do |someone|
|
|
12
|
+
@greeting = @hello.greet(someone, @name)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Then /he should hear (.*)\./ do |message|
|
|
16
|
+
@greeting.should == message
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Then /I should remember (\w+) as a friend/ do |name|
|
|
20
|
+
@hello.friend?(name).should == true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Then /I should get (\w+)'s phone number/ do |name| #'
|
|
24
|
+
@hello.getPhoneNumber(name).should_not == nil
|
|
25
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'spec'
|
|
2
|
+
include_class 'java.util.TreeSet'
|
|
3
|
+
|
|
4
|
+
Given /I have an empty set/ do
|
|
5
|
+
@set = TreeSet.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
When /I add (\w+)/ do |s|
|
|
9
|
+
@set.add(s)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Then /the contents should be (.*)/ do |s|
|
|
13
|
+
@set.to_a.join(" ").should == s
|
|
14
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package cucumber.demo;
|
|
2
|
+
|
|
3
|
+
public class Hello {
|
|
4
|
+
public String greet(String who, String from) {
|
|
5
|
+
return "Hi, " + who + ". I'm " + from;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public boolean isFriend(String who) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public String getPhoneNumber(String who) {
|
|
13
|
+
throw new RuntimeException("NOPE");
|
|
14
|
+
//return "98219458";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Feature: Search
|
|
2
|
+
In order to learn more
|
|
3
|
+
As an information seeker
|
|
4
|
+
I want to find more information
|
|
5
|
+
|
|
6
|
+
Scenario: Find what I'm looking for
|
|
7
|
+
Given I am on the Google search page
|
|
8
|
+
When I search for "rspec"
|
|
9
|
+
Then I should see a link to "RSpec-1.1.4: Overview":http://rspec.info/
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'spec'
|
|
2
|
+
require 'selenium'
|
|
3
|
+
|
|
4
|
+
class GoogleSearch
|
|
5
|
+
def initialize(browser)
|
|
6
|
+
@browser = browser
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def goto
|
|
10
|
+
@browser.open 'http://www.google.com/'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def search(text)
|
|
14
|
+
@browser.type('q',text)
|
|
15
|
+
@browser.click 'btnG'
|
|
16
|
+
@browser.wait_for_page_to_load
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
Before do
|
|
21
|
+
@browser = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome", "http://localhost", 15000)
|
|
22
|
+
@browser.start
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
After do
|
|
26
|
+
@browser.stop
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Given 'I am on the Google search page' do
|
|
30
|
+
@page = GoogleSearch.new(@browser)
|
|
31
|
+
@page.goto
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
When /I search for "(.*)"/ do |query|
|
|
35
|
+
@page.search(query)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
Then /I should see a link to "(.*)":(.*)/ do |text, expected_url|
|
|
39
|
+
observed_url = @browser.get_attribute("link=#{text}@href")
|
|
40
|
+
observed_url.should == expected_url
|
|
41
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'test/unit/assertions'
|
|
2
|
+
World do |o|
|
|
3
|
+
o.extend(Test::Unit::Assertions)
|
|
4
|
+
o
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Given /^(\w+) = (\w+)$/ do |var, value|
|
|
8
|
+
instance_variable_set("@#{var}", value)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
begin
|
|
12
|
+
require 'rubygems'
|
|
13
|
+
require 'matchy'
|
|
14
|
+
Then /^I can assert that (\w+) == (\w+)$/ do |var_a, var_b|
|
|
15
|
+
a = instance_variable_get("@#{var_a}")
|
|
16
|
+
b = instance_variable_get("@#{var_b}")
|
|
17
|
+
a.should == b
|
|
18
|
+
end
|
|
19
|
+
rescue LoadError
|
|
20
|
+
STDERR.puts "***** You should install matchy *****"
|
|
21
|
+
Then /^I can assert that (\w+) == (\w+)$/ do |var_a, var_b|
|
|
22
|
+
a = instance_variable_get("@#{var_a}")
|
|
23
|
+
b = instance_variable_get("@#{var_b}")
|
|
24
|
+
assert_equal(a, b)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
|
2
|
+
require 'cucumber/rake/task'
|
|
3
|
+
|
|
4
|
+
# Try these:
|
|
5
|
+
#
|
|
6
|
+
# rake features
|
|
7
|
+
# rake features PROFILE=html
|
|
8
|
+
Cucumber::Rake::Task.new do |t|
|
|
9
|
+
profile = ENV['PROFILE'] || 'default'
|
|
10
|
+
t.cucumber_opts = "--profile #{profile}"
|
|
11
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec'
|
|
2
|
+
|
|
3
|
+
Given "be_empty" do
|
|
4
|
+
[1,2].should_not be_empty
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Given "nested step is called" do
|
|
8
|
+
Given "nested step"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Given "nested step" do
|
|
12
|
+
@magic = 'mushroom'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Then "nested step should be executed" do
|
|
16
|
+
@magic.should == 'mushroom'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Given /^the following table$/ do |table|
|
|
20
|
+
@table = table
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Then /^I should be (\w+) in (\w+)$/ do |key, value|
|
|
24
|
+
hash = @table.hashes[0]
|
|
25
|
+
hash[key].should == value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Then /^I shoule see a multiline string like$/ do |s|
|
|
29
|
+
s.should == %{A string
|
|
30
|
+
that spans
|
|
31
|
+
several lines}
|
|
32
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Feature: Cucumber
|
|
2
|
+
In order to have a happy user base
|
|
3
|
+
As a Cucumber user
|
|
4
|
+
I don't want no stinkin bugs
|
|
5
|
+
|
|
6
|
+
Scenario: RSpec be_*
|
|
7
|
+
Given be_empty
|
|
8
|
+
|
|
9
|
+
Scenario: Call step from step
|
|
10
|
+
Given nested step is called
|
|
11
|
+
Then nested step should be executed
|
|
12
|
+
|
|
13
|
+
Scenario: Reading a table
|
|
14
|
+
Given the following table
|
|
15
|
+
| born | working |
|
|
16
|
+
| Oslo | London |
|
|
17
|
+
Then I should be working in London
|
|
18
|
+
And I should be born in Oslo
|
|
19
|
+
And I shoule see a multiline string like
|
|
20
|
+
"""
|
|
21
|
+
A string
|
|
22
|
+
that spans
|
|
23
|
+
several lines
|
|
24
|
+
"""
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Feature: Search
|
|
2
|
+
In order to learn more
|
|
3
|
+
As an information seeker
|
|
4
|
+
I want to find more information
|
|
5
|
+
|
|
6
|
+
Scenario: Find what I'm looking for
|
|
7
|
+
Given I am on the Google search page
|
|
8
|
+
When I search for "cucumber github"
|
|
9
|
+
Then I should see a link to "Ruby on Rails — cucumber — GitHub":http://github.com/aslakhellesoy/cucumber/wikis/ruby-on-rails
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'spec'
|
|
2
|
+
|
|
3
|
+
case PLATFORM
|
|
4
|
+
when /darwin/
|
|
5
|
+
require 'safariwatir'
|
|
6
|
+
Browser = Watir::Safari
|
|
7
|
+
when /win32|mingw/
|
|
8
|
+
require 'watir'
|
|
9
|
+
Browser = Watir::IE
|
|
10
|
+
when /java/
|
|
11
|
+
require 'celerity'
|
|
12
|
+
Browser = Celerity::Browser
|
|
13
|
+
else
|
|
14
|
+
raise "This platform is not supported (#{PLATFORM})"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Before do
|
|
18
|
+
@b = Browser.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
After do
|
|
22
|
+
@b.close
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class GoogleSearch
|
|
26
|
+
def initialize(b)
|
|
27
|
+
@b = b
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def goto
|
|
31
|
+
@b.goto 'http://www.google.com/'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def search(text)
|
|
35
|
+
@b.text_field(:name, 'q').set(text)
|
|
36
|
+
@b.button(:name, 'btnG').click
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Given 'I am on the Google search page' do
|
|
41
|
+
@page = GoogleSearch.new(@b)
|
|
42
|
+
@page.goto
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
When /I search for "(.*)"/ do |query|
|
|
46
|
+
@page.search(query)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Then /I should see a link to "(.*)":(.*)/ do |text, url|
|
|
50
|
+
@b.link(:url, url).text.should == text
|
|
51
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Feature: See features
|
|
2
|
+
In order to make Cucumber features more accessible
|
|
3
|
+
I should be able to see the existing features in a system
|
|
4
|
+
|
|
5
|
+
Scenario: See features as HTML
|
|
6
|
+
Given the feature server is running
|
|
7
|
+
When I visit "/features"
|
|
8
|
+
Then I should see a link to "See features"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
desc 'Release the website and new gem version'
|
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
|
3
|
+
puts "Remember to create SVN tag:"
|
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
|
6
|
+
puts "Suggested comment:"
|
|
7
|
+
puts "Tagging release #{CHANGES}"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
|
12
|
+
|
|
13
|
+
task :check_version do
|
|
14
|
+
unless ENV['VERSION']
|
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
|
16
|
+
exit
|
|
17
|
+
end
|
|
18
|
+
unless ENV['VERSION'] == VERS
|
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
|
20
|
+
exit
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
namespace :manifest do
|
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
|
31
|
+
task :refresh do
|
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
|
33
|
+
end
|
|
34
|
+
end
|
data/gem_tasks/flog.rake
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
def unable_to_load
|
|
2
|
+
puts <<-EOS
|
|
3
|
+
To use rspec for testing you must install rspec gem:
|
|
4
|
+
gem install rspec
|
|
5
|
+
|
|
6
|
+
EOS
|
|
7
|
+
nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def require_spec
|
|
11
|
+
require 'spec'
|
|
12
|
+
rescue LoadError
|
|
13
|
+
require_spec_with_rubygems
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def require_spec_with_rubygems
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
require 'spec'
|
|
19
|
+
rescue LoadError
|
|
20
|
+
unable_to_load
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
if require_spec
|
|
24
|
+
begin
|
|
25
|
+
require 'spec/rake/spectask'
|
|
26
|
+
rescue LoadError
|
|
27
|
+
unable_to_load
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc "Run the specs under spec/models"
|
|
31
|
+
Spec::Rake::SpecTask.new do |t|
|
|
32
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
|
33
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
class FeatureCompiler
|
|
2
|
+
def initialize
|
|
3
|
+
require 'yaml'
|
|
4
|
+
require 'erb'
|
|
5
|
+
|
|
6
|
+
@tt = PLATFORM =~ /mswin|mingw/ ? 'tt.bat' : 'tt'
|
|
7
|
+
|
|
8
|
+
@template = ERB.new(IO.read(File.dirname(__FILE__) + '/../lib/cucumber/treetop_parser/feature.treetop.erb'))
|
|
9
|
+
@langs = YAML.load_file(File.dirname(__FILE__) + '/../lib/cucumber/languages.yml')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def compile_all
|
|
13
|
+
@langs.keys.each do |lang|
|
|
14
|
+
compile(lang)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def compile(lang)
|
|
19
|
+
words = @langs['en'].merge(@langs[lang]) # Use English words if languages.yml is missing a word
|
|
20
|
+
grammar_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.treetop"
|
|
21
|
+
ruby_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.rb"
|
|
22
|
+
grammar = @template.result(binding)
|
|
23
|
+
File.open(grammar_file, "wb") do |io|
|
|
24
|
+
io.write(grammar)
|
|
25
|
+
end
|
|
26
|
+
sh "#{@tt} #{grammar_file}"
|
|
27
|
+
FileUtils.rm(grammar_file)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
namespace :treetop do
|
|
32
|
+
desc 'Compile the grammar for all languages in languages.yml'
|
|
33
|
+
task :compile do
|
|
34
|
+
FeatureCompiler.new.compile_all
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
desc 'Compile the English grammar'
|
|
38
|
+
task :compile_en do
|
|
39
|
+
FeatureCompiler.new.compile('en')
|
|
40
|
+
end
|
|
41
|
+
end
|