aslakhellesoy-cucumber 0.0.1

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.
Files changed (74) hide show
  1. data/History.txt +4 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +73 -0
  4. data/README.txt +78 -0
  5. data/Rakefile +4 -0
  6. data/bin/cucumber +3 -0
  7. data/config/hoe.rb +70 -0
  8. data/config/requirements.rb +15 -0
  9. data/examples/Rakefile +7 -0
  10. data/examples/pure_ruby/addition.rb +16 -0
  11. data/examples/pure_ruby/steps/addition_steps.rb +43 -0
  12. data/examples/simple/addition.story +12 -0
  13. data/examples/simple/division.story +17 -0
  14. data/examples/simple/steps/addition_steps.rb +43 -0
  15. data/examples/simple_norwegian/steg/matte_steg.rb.rb +31 -0
  16. data/examples/simple_norwegian/summering.story +10 -0
  17. data/examples/web/run_stories.story +10 -0
  18. data/examples/web/steps/stories_steps.rb +39 -0
  19. data/gem_tasks/deployment.rake +34 -0
  20. data/gem_tasks/environment.rake +7 -0
  21. data/gem_tasks/fix_cr_lf.rake +10 -0
  22. data/gem_tasks/rspec.rake +21 -0
  23. data/gem_tasks/treetop.rake +33 -0
  24. data/gem_tasks/website.rake +17 -0
  25. data/lib/cucumber.rb +17 -0
  26. data/lib/cucumber/cli.rb +118 -0
  27. data/lib/cucumber/core_ext/proc.rb +35 -0
  28. data/lib/cucumber/core_ext/string.rb +17 -0
  29. data/lib/cucumber/executor.rb +85 -0
  30. data/lib/cucumber/formatters.rb +1 -0
  31. data/lib/cucumber/formatters/ansicolor.rb +89 -0
  32. data/lib/cucumber/formatters/html_formatter.rb +271 -0
  33. data/lib/cucumber/formatters/pretty_formatter.rb +66 -0
  34. data/lib/cucumber/formatters/progress_formatter.rb +41 -0
  35. data/lib/cucumber/parser/languages.yml +35 -0
  36. data/lib/cucumber/parser/nodes.rb +88 -0
  37. data/lib/cucumber/parser/story_parser.rb +13 -0
  38. data/lib/cucumber/parser/story_parser.treetop.erb +41 -0
  39. data/lib/cucumber/parser/story_parser_en.rb +554 -0
  40. data/lib/cucumber/parser/story_parser_fr.rb +554 -0
  41. data/lib/cucumber/parser/story_parser_no.rb +554 -0
  42. data/lib/cucumber/parser/story_parser_pt.rb +554 -0
  43. data/lib/cucumber/parser/top_down_visitor.rb +26 -0
  44. data/lib/cucumber/rails/world.rb +69 -0
  45. data/lib/cucumber/rake/task.rb +74 -0
  46. data/lib/cucumber/ruby_tree.rb +14 -0
  47. data/lib/cucumber/ruby_tree/nodes.rb +68 -0
  48. data/lib/cucumber/step_methods.rb +39 -0
  49. data/lib/cucumber/step_mother.rb +38 -0
  50. data/lib/cucumber/tree.rb +127 -0
  51. data/lib/cucumber/version.rb +9 -0
  52. data/script/console +10 -0
  53. data/script/console.cmd +1 -0
  54. data/script/destroy +14 -0
  55. data/script/destroy.cmd +1 -0
  56. data/script/generate +14 -0
  57. data/script/generate.cmd +1 -0
  58. data/script/txt2html +74 -0
  59. data/script/txt2html.cmd +1 -0
  60. data/setup.rb +1585 -0
  61. data/spec/cucumber/core_ext/string_spec.rb +20 -0
  62. data/spec/cucumber/executor_spec.rb +55 -0
  63. data/spec/cucumber/formatters/ansicolor_spec.rb +18 -0
  64. data/spec/cucumber/formatters/html_formatter_spec.rb +59 -0
  65. data/spec/cucumber/formatters/stories.html +274 -0
  66. data/spec/cucumber/sell_cucumbers.story +9 -0
  67. data/spec/spec.opts +2 -0
  68. data/spec/spec_helper.rb +7 -0
  69. data/website/index.html +11 -0
  70. data/website/index.txt +39 -0
  71. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  72. data/website/stylesheets/screen.css +138 -0
  73. data/website/template.html.erb +48 -0
  74. metadata +157 -0
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-04-08
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 FIXME full name
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,73 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/cucumber
7
+ config/hoe.rb
8
+ config/requirements.rb
9
+ examples/Rakefile
10
+ examples/pure_ruby/addition.rb
11
+ examples/pure_ruby/steps/addition_steps.rb
12
+ examples/simple/addition.story
13
+ examples/simple/division.story
14
+ examples/simple/steps/addition_steps.rb
15
+ examples/simple_norwegian/steg/matte_steg.rb.rb
16
+ examples/simple_norwegian/summering.story
17
+ examples/web/run_stories.story
18
+ examples/web/steps/stories_steps.rb
19
+ gem_tasks/deployment.rake
20
+ gem_tasks/environment.rake
21
+ gem_tasks/fix_cr_lf.rake
22
+ gem_tasks/rspec.rake
23
+ gem_tasks/treetop.rake
24
+ gem_tasks/website.rake
25
+ lib/cucumber.rb
26
+ lib/cucumber/cli.rb
27
+ lib/cucumber/core_ext/proc.rb
28
+ lib/cucumber/core_ext/string.rb
29
+ lib/cucumber/executor.rb
30
+ lib/cucumber/formatters.rb
31
+ lib/cucumber/formatters/ansicolor.rb
32
+ lib/cucumber/formatters/html_formatter.rb
33
+ lib/cucumber/formatters/pretty_formatter.rb
34
+ lib/cucumber/formatters/progress_formatter.rb
35
+ lib/cucumber/parser/languages.yml
36
+ lib/cucumber/parser/nodes.rb
37
+ lib/cucumber/parser/story_parser.rb
38
+ lib/cucumber/parser/story_parser.treetop.erb
39
+ lib/cucumber/parser/story_parser_en.rb
40
+ lib/cucumber/parser/story_parser_fr.rb
41
+ lib/cucumber/parser/story_parser_no.rb
42
+ lib/cucumber/parser/story_parser_pt.rb
43
+ lib/cucumber/parser/top_down_visitor.rb
44
+ lib/cucumber/rails/world.rb
45
+ lib/cucumber/rake/task.rb
46
+ lib/cucumber/ruby_tree.rb
47
+ lib/cucumber/ruby_tree/nodes.rb
48
+ lib/cucumber/step_methods.rb
49
+ lib/cucumber/step_mother.rb
50
+ lib/cucumber/tree.rb
51
+ lib/cucumber/version.rb
52
+ script/console
53
+ script/console.cmd
54
+ script/destroy
55
+ script/destroy.cmd
56
+ script/generate
57
+ script/generate.cmd
58
+ script/txt2html
59
+ script/txt2html.cmd
60
+ setup.rb
61
+ spec/cucumber/core_ext/string_spec.rb
62
+ spec/cucumber/executor_spec.rb
63
+ spec/cucumber/formatters/ansicolor_spec.rb
64
+ spec/cucumber/formatters/html_formatter_spec.rb
65
+ spec/cucumber/formatters/stories.html
66
+ spec/cucumber/sell_cucumbers.story
67
+ spec/spec.opts
68
+ spec/spec_helper.rb
69
+ website/index.html
70
+ website/index.txt
71
+ website/javascripts/rounded_corners_lite.inc.js
72
+ website/stylesheets/screen.css
73
+ website/template.html.erb
@@ -0,0 +1,78 @@
1
+ = cucumber
2
+
3
+ * FIX http://rspec.info/cucumber
4
+
5
+ == DESCRIPTION:
6
+
7
+ This code parses RSpec stories. It uses a Treetop grammar to do the job, and
8
+ this grammar is extended by users of the library. This design makes the code
9
+ very compact, and it makes it easy to give precise line and column info on
10
+ parse errors. Further, when a step fails, the story file will appear in the
11
+ stack trace, along with regular ruby files.
12
+
13
+ == FEATURES/PROBLEMS:
14
+
15
+ * Run examples with:
16
+ ** ruby -Ilib bin/cucumber examples/simple --require examples/simple/steps
17
+ ** ruby -Ilib bin/cucumber examples/web --require examples/web/steps
18
+
19
+ * TODO: OK Refactor: Extract explicit node classes with RDoc (for better API doc)
20
+ * TODO: OK Get rid of the compile method. Compile the parser in Rake.
21
+ * TODO: OK Make grammar support \r\n, \r and \n (Add some fixture stories for that)
22
+ * TODO: OK Make grammar support indentation
23
+ * TODO: OK Make grammar be totally relaxed about narrative
24
+ * TODO: OK Add a yaml file for different languages
25
+ * TODO: OK Custom nodes for the syntax tree
26
+ * TODO: OK Actually execute the stories
27
+ * TODO: Make rake run specs by default
28
+ * TODO: OK Make it work with pure ruby regexen
29
+ * TODO: Make it work with string steps
30
+ * TODO: bin/cucumber --require [dir|file|glob]* --language no --format [file]*
31
+ * TODO: Pending steps shold print a block of code that can be pasted into code
32
+ * TODO: cucumber --where "Some text from a step" that prints "__FILE__:__LINE__ (STEP PATTERN)"
33
+ * TODO: Customisable trace output (like javascriptlint)
34
+ * TODO: Experiment: Make $variables become @variables
35
+ * TODO: GivenScenario
36
+ * TODO: PureRuby
37
+ * Make two trees include accept mixin
38
+ * TODO: Call steps from steps
39
+ * TODO: i18n in ruby too
40
+ * TODO: Don't load any treetop files if no .story files are found
41
+ * TODO: Summary prints execution time
42
+
43
+ == SYNOPSIS:
44
+
45
+ FIX (code sample of usage)
46
+
47
+ == REQUIREMENTS:
48
+
49
+ * gem install treetop
50
+
51
+ == INSTALL:
52
+
53
+ * gem install cucumber
54
+
55
+ == LICENSE:
56
+
57
+ (The MIT License)
58
+
59
+ Copyright (c) 2008 Aslak Hellesøy
60
+
61
+ Permission is hereby granted, free of charge, to any person obtaining
62
+ a copy of this software and associated documentation files (the
63
+ 'Software'), to deal in the Software without restriction, including
64
+ without limitation the rights to use, copy, modify, merge, publish,
65
+ distribute, sublicense, and/or sell copies of the Software, and to
66
+ permit persons to whom the Software is furnished to do so, subject to
67
+ the following conditions:
68
+
69
+ The above copyright notice and this permission notice shall be
70
+ included in all copies or substantial portions of the Software.
71
+
72
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
73
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
74
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
75
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
76
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
77
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
78
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['gem_tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'cucumber/cli'
3
+ Cucumber::CLI.execute
@@ -0,0 +1,70 @@
1
+ require 'cucumber/version'
2
+
3
+ AUTHOR = 'Aslak Hellesøy' # can also be an array of Authors
4
+ EMAIL = "aslak.hellesoy@gmail.com"
5
+ DESCRIPTION = "Executable user stories"
6
+ GEM_NAME = 'cucumber' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'cucumber' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+
11
+ @config_file = "~/.rubyforge/user-config.yml"
12
+ @config = nil
13
+ RUBYFORGE_USERNAME = "aslak_hellesoy"
14
+ def rubyforge_username
15
+ unless @config
16
+ begin
17
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
18
+ rescue
19
+ puts <<-EOS
20
+ ERROR: No rubyforge config file found: #{@config_file}
21
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
23
+ EOS
24
+ exit
25
+ end
26
+ end
27
+ RUBYFORGE_USERNAME.replace @config["username"]
28
+ end
29
+
30
+
31
+ REV = nil
32
+ # UNCOMMENT IF REQUIRED:
33
+ # REV = YAML.load(`svn info`)['Revision']
34
+ VERS = Cucumber::VERSION::STRING + (REV ? ".#{REV}" : "")
35
+ RDOC_OPTS = ['--quiet', '--title', 'cucumber documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.developer(AUTHOR, EMAIL)
52
+ p.description = DESCRIPTION
53
+ p.summary = DESCRIPTION
54
+ p.url = HOMEPATH
55
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
56
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
57
+
58
+ # == Optional
59
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
60
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
61
+ p.extra_deps = [ ['term-ansicolor', '>= 1.0.3'], ['treetop', '>= 1.2.4'] ]
62
+
63
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
+
65
+ end
66
+
67
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
68
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
69
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
70
+ $hoe.rsync_args = '-av --delete --ignore-errors'
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,7 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+
3
+ require 'cucumber/rake/task'
4
+
5
+ Cucumber::Rake::Task.new('simple') do |t|
6
+ t.cucumber_opts = "--format pretty"
7
+ end
@@ -0,0 +1,16 @@
1
+ require 'cucumber/cli' # Needed in order to run the story with ruby
2
+
3
+ Story "Addition", %|
4
+ As a math idiot
5
+ I want to be told the sum of two numbers
6
+ So that I don't make silly mistakes| do
7
+
8
+ Scenario "50+70" do
9
+ Given "I have entered 50 into the calculator"
10
+ Given "foo bar"
11
+ And "I have entered 70 into the calculator"
12
+ When "I add"
13
+ Then "the result should be 12 on the screen"
14
+ And "the result class should be Float"
15
+ end
16
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec'
2
+
3
+ class Calculator
4
+ def push(n)
5
+ @args ||= []
6
+ @args << n
7
+ end
8
+
9
+ def add
10
+ @args.inject(0){|n,sum| sum+=n}
11
+ end
12
+
13
+ def divide
14
+ @args[0].to_f / @args[1].to_f
15
+ end
16
+ end
17
+
18
+ Before do
19
+ @calc = Calculator.new
20
+ end
21
+
22
+ After do
23
+ end
24
+
25
+ Given /I have entered (\d+) into the calculator/ do |n|
26
+ @calc.push n.to_i
27
+ end
28
+
29
+ When 'I add' do
30
+ @result = @calc.add
31
+ end
32
+
33
+ When 'I divide' do
34
+ @result = @calc.divide
35
+ end
36
+
37
+ Then /the result should be (\d*) on the screen/ do |result|
38
+ @result.should == result.to_i
39
+ end
40
+
41
+ Then /the result class should be (\w*)/ do |class_name|
42
+ @result.class.name.should == class_name
43
+ end
@@ -0,0 +1,12 @@
1
+ Story: Addition
2
+ As a math idiot
3
+ I want to be told the sum of two numbers
4
+ So that I don't make silly mistakes
5
+
6
+ Scenario: 50+70
7
+ Given I have entered 50 into the calculator
8
+ Given foo bar
9
+ And I have entered 70 into the calculator
10
+ When I add
11
+ Then the result should be 12 on the screen
12
+ And the result class should be Float
@@ -0,0 +1,17 @@
1
+ Story: Division
2
+ As a math genius
3
+ I want to be told the division of two floats
4
+ So that I don't make silly mistakes
5
+
6
+ Scenario: 7/2
7
+ Given I have entered 3 into the calculator
8
+ And I have entered 2 into the calculator
9
+ When I divide
10
+ Then the result should be 2.5 on the screen
11
+ And the result class should be Float
12
+
13
+ Scenario: 3/0
14
+ Given I have entered 3 into the calculator
15
+ And I have entered 2 into the calculator
16
+ When I divide
17
+ Then the result should be NaN on the screen
@@ -0,0 +1,43 @@
1
+ require 'spec'
2
+
3
+ class Calculator
4
+ def push(n)
5
+ @args ||= []
6
+ @args << n
7
+ end
8
+
9
+ def add
10
+ @args.inject(0){|n,sum| sum+=n}
11
+ end
12
+
13
+ def divide
14
+ @args[0].to_f / @args[1].to_f
15
+ end
16
+ end
17
+
18
+ Before do
19
+ @calc = Calculator.new
20
+ end
21
+
22
+ After do
23
+ end
24
+
25
+ Given /I have entered (\d+) into the calculator/ do |n|
26
+ @calc.push n.to_i
27
+ end
28
+
29
+ When 'I add' do
30
+ @result = @calc.add
31
+ end
32
+
33
+ When 'I divide' do
34
+ @result = @calc.divide
35
+ end
36
+
37
+ Then /the result should be (\d*) on the screen/ do |result|
38
+ @result.should == result.to_i
39
+ end
40
+
41
+ Then /the result class should be (\w*)/ do |class_name|
42
+ @result.class.name.should == class_name
43
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec'
2
+
3
+ class Calculator
4
+ def push(n)
5
+ @args ||= []
6
+ @args << n
7
+ end
8
+
9
+ def add
10
+ @args.inject(0){|n,sum| sum+=n}
11
+ end
12
+ end
13
+
14
+ Before do
15
+ @calc = Calculator.new
16
+ end
17
+
18
+ After do
19
+ end
20
+
21
+ Given /at jeg har tastet inn (\d+)/ do |n|
22
+ @calc.push n.to_i
23
+ end
24
+
25
+ When 'jeg summerer' do
26
+ @result = @calc.add
27
+ end
28
+
29
+ Then /skal resultatet være (\d*)/ do |result|
30
+ @result.should == result.to_i
31
+ end