features2cards 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/.gitignore +3 -0
  2. data/History.txt +11 -0
  3. data/README.rdoc +2 -3
  4. data/Rakefile +26 -2
  5. data/Thorfile +114 -0
  6. data/examples/i18n/.gitignore +1 -0
  7. data/examples/i18n/README.textile +18 -0
  8. data/examples/i18n/Rakefile +30 -0
  9. data/examples/i18n/ar/addition.feature +17 -0
  10. data/examples/i18n/bg/addition.feature +12 -0
  11. data/examples/i18n/bg/consecutive_calculations.feature +19 -0
  12. data/examples/i18n/bg/division.feature +17 -0
  13. data/examples/i18n/cat/suma.feature +17 -0
  14. data/examples/i18n/da/summering.feature +18 -0
  15. data/examples/i18n/de/addition.feature +17 -0
  16. data/examples/i18n/de/division.feature +10 -0
  17. data/examples/i18n/en-lol/stuffing.feature +8 -0
  18. data/examples/i18n/en/addition.feature +17 -0
  19. data/examples/i18n/en/division.feature +10 -0
  20. data/examples/i18n/es/adicion.feature +17 -0
  21. data/examples/i18n/et/jagamine.feature +10 -0
  22. data/examples/i18n/et/liitmine.feature +17 -0
  23. data/examples/i18n/fi/jakolasku.feature +10 -0
  24. data/examples/i18n/fi/yhteenlasku.feature +16 -0
  25. data/examples/i18n/fr/addition.feature +18 -0
  26. data/examples/i18n/he/addition.feature +17 -0
  27. data/examples/i18n/he/division.feature +10 -0
  28. data/examples/i18n/hu/addition.feature +17 -0
  29. data/examples/i18n/hu/division.feature +10 -0
  30. data/examples/i18n/id/addition.feature +17 -0
  31. data/examples/i18n/id/division.feature +10 -0
  32. data/examples/i18n/it/somma.feature +11 -0
  33. data/examples/i18n/ja/addition.feature +17 -0
  34. data/examples/i18n/ja/division.feature +10 -0
  35. data/examples/i18n/ko/addition.feature +17 -0
  36. data/examples/i18n/ko/division.feature +11 -0
  37. data/examples/i18n/lt/addition.feature +17 -0
  38. data/examples/i18n/lt/division.feature +10 -0
  39. data/examples/i18n/lv/addition.feature +17 -0
  40. data/examples/i18n/lv/division.feature +10 -0
  41. data/examples/i18n/no/summering.feature +19 -0
  42. data/examples/i18n/pl/addition.feature +17 -0
  43. data/examples/i18n/pl/division.feature +10 -0
  44. data/examples/i18n/pt/adicao.feature +11 -0
  45. data/examples/i18n/ro/suma.feature +11 -0
  46. data/examples/i18n/ru/addition.feature +11 -0
  47. data/examples/i18n/ru/consecutive_calculations.feature +17 -0
  48. data/examples/i18n/ru/division.feature +16 -0
  49. data/examples/i18n/se/summering.feature +18 -0
  50. data/examples/i18n/sk/addition.feature +17 -0
  51. data/examples/i18n/sk/division.feature +10 -0
  52. data/examples/i18n/zh-CN/addition.feature +18 -0
  53. data/examples/i18n/zh-TW/addition.feature +17 -0
  54. data/examples/i18n/zh-TW/division.feature +11 -0
  55. data/examples/self_test/.gitignore +2 -0
  56. data/examples/self_test/features/features2cards.feature +19 -0
  57. data/features/features2cards_cli.feature +40 -0
  58. data/features/step_definitions/features2cards_steps.rb +41 -0
  59. data/features/support/env.rb +79 -0
  60. data/features2cards.gemspec +118 -0
  61. data/lib/features2cards.rb +2 -8
  62. data/lib/features2cards/card.rb +14 -10
  63. data/lib/features2cards/cli.rb +27 -34
  64. data/lib/features2cards/platform.rb +1 -1
  65. data/lib/features2cards/prawn.rb +13 -13
  66. data/spec/features2cards/card_spec.rb +8 -0
  67. data/spec/features2cards/cli_spec.rb +21 -0
  68. data/spec/features2cards/prawn_spec.rb +5 -0
  69. data/spec/spec.opts +2 -0
  70. data/spec/spec_helper.rb +7 -0
  71. metadata +81 -12
@@ -0,0 +1,17 @@
1
+ # language: sk
2
+ Požiadavka: Sčítavanie
3
+ Aby som sa vyhol hlúpym chybám
4
+ Ako matematický idiot
5
+ Chcem vedieť ako sa sčítavajú dve čísla
6
+
7
+ Náčrt Scenáru: Sčítanie dvoch čísel
8
+ Pokiaľ Zadám číslo <vstup_1> do kalkulačky
9
+ A Zadám číslo <vstup_2> do kalkulačky
10
+ Keď Stlačím tlačidlo <tlačidlo>
11
+ Tak Výsledok by mal byť <výstup>
12
+
13
+ Príklady:
14
+ | vstup_1 | vstup_2 | tlačidlo | výstup |
15
+ | 20 | 30 | add | 50 |
16
+ | 2 | 5 | add | 7 |
17
+ | 0 | 40 | add | 40 |
@@ -0,0 +1,10 @@
1
+ # language: sk
2
+ Požiadavka: Delenie
3
+ Aby som sa vyhol hlúpym chybám
4
+ Pokladníci musia vedieť vypočítať podiel
5
+
6
+ Scenár: Prirodzené čísla
7
+ Pokiaľ Zadám číslo 3 do kalkulačky
8
+ A Zadám číslo 2 do kalkulačky
9
+ Keď Stlačím tlačidlo divide
10
+ Tak Výsledok by mal byť 1.5
@@ -0,0 +1,18 @@
1
+ # language: zh-CN
2
+ 功能:加法
3
+ 为了避免一些愚蠢的错误
4
+ 作为一个数学白痴
5
+ 我希望有人告诉我数字相加的结果
6
+
7
+ 场景: 两个数相加
8
+ 假如我已经在计算器里输入6
9
+ 而且我已经在计算器里输入7
10
+ 当我按相加按钮
11
+ 那么我应该在屏幕上看到的结果是13
12
+
13
+ 场景: 三个数相加
14
+ 假如我已经在计算器里输入6
15
+ 而且我已经在计算器里输入7
16
+ 而且我已经在计算器里输入1
17
+ 当我按相加按钮
18
+ 那么我应该在屏幕上看到的结果是14
@@ -0,0 +1,17 @@
1
+ # language: zh-TW
2
+ 功能: 加法
3
+ 為了避免愚蠢的錯誤
4
+ 作為一個數學白痴
5
+ 我希望有人能告訴我兩個數相加的結果
6
+
7
+ 場景大綱: 將兩個數相加
8
+ 假設我已經在計算機上輸入 <數值_1>
9
+ 而且我已經在計算機上輸入 <數值_2>
10
+ 當我按下 <按鈕>
11
+ 那麼螢幕上應該顯示 <結果>
12
+
13
+ 例子:
14
+ | 數值_1 | 數值_2 | 按鈕 | 結果 |
15
+ | 20 | 30 | add | 50 |
16
+ | 2 | 5 | add | 7 |
17
+ | 0 | 40 | add | 40 |
@@ -0,0 +1,11 @@
1
+ # language: zh-TW
2
+ 功能: 除法
3
+ 為了避免愚蠢的錯誤
4
+ 收銀機必須要能夠計算除法
5
+ 而且必需能顯示非整數的結果
6
+
7
+ 場景: 將兩個數相除
8
+ 假設我已經在計算機上輸入 3
9
+ 而且我已經在計算機上輸入 2
10
+ 當我按下 divide
11
+ 那麼螢幕上應該顯示 1.5
@@ -0,0 +1,2 @@
1
+ tmp
2
+ *.pdf
@@ -0,0 +1,19 @@
1
+ Feature: Generate PDF scenario cards
2
+
3
+ So that I can keep our task board up to date easily
4
+ As a developer
5
+ I want to generate index cards from our Cucumber feature files
6
+
7
+ Scenario: Generate card for the feature
8
+
9
+ Given a feature file with no scenarios
10
+ When I generate cards
11
+ Then I should get a PDF with one feature card
12
+
13
+ Scenario: Generate scenario cards
14
+
15
+ Given a feature file with one scenario
16
+ When I generate cards
17
+ Then I should get a PDF with one scenario card
18
+
19
+
@@ -0,0 +1,40 @@
1
+ Feature: Feature2Cards command line
2
+ In order to visualize features and scenarios in sprint meetings
3
+ Developers should be able to get them in a printable form
4
+
5
+ Scenario: Run features2cards for a single feature
6
+ Given I am in self_test
7
+ When I run features2cards features/features2cards.feature
8
+ Then it should pass
9
+ And "cards.pdf" should exist
10
+
11
+ Scenario: Run features2cards for a feature with custom output file name given
12
+ Given I am in self_test
13
+ When I run features2cards --out test.pdf features/features2cards.feature
14
+ Then it should pass
15
+ And "test.pdf" should exist
16
+
17
+ Scenario: Run features2cards for cucumber german example using a directory as input
18
+ Given I am in i18n
19
+ When I run features2cards --out german_cards.pdf de
20
+ Then it should pass
21
+ And "german_cards.pdf" should exist
22
+
23
+ Scenario: Run features2cards with option: --version
24
+ When I run features2cards --version
25
+ Then it should pass with <actual version>
26
+
27
+ Scenario: Run features2cards with option: --help
28
+ When I run features2cards --help
29
+ Then it should pass with
30
+ """
31
+ Usage: features2cards [options] [ [FILE|DIR] ]+
32
+
33
+ Examples:
34
+ features2cards features2cards.feature
35
+ features2cards examples/i18n/it
36
+ -o, --out [FILE] Specify pdf output file (Default: cards.pdf).
37
+ --version Show version.
38
+ -h, --help You're looking at it.
39
+
40
+ """
@@ -0,0 +1,41 @@
1
+ require 'tempfile'
2
+ require 'features2cards'
3
+ require 'features2cards/cli'
4
+ require 'features2cards/card'
5
+ require 'features2cards/platform'
6
+
7
+ Given /^I am in (.*)$/ do |example_dir_relative_path|
8
+ @current_dir = examples_dir(example_dir_relative_path)
9
+ end
10
+
11
+ When /^I run features2cards (.*)$/ do |features2cards_opts|
12
+ run "#{Features2Cards::RUBY_BINARY} -I #{features2cards_lib_dir} -rrubygems #{Features2Cards::BINARY} #{features2cards_opts}"
13
+ end
14
+
15
+ Then /^it should (fail|pass)$/ do |success|
16
+ if success == 'fail'
17
+ last_exit_status.should_not == 0
18
+ else
19
+ if last_exit_status != 0
20
+ raise "Failed with exit status #{last_exit_status}\nSTDOUT:\n#{last_stdout}\nSTDERR:\n#{last_stderr}"
21
+ end
22
+ end
23
+ end
24
+
25
+ Then /^it should (fail|pass) with$/ do |success, output|
26
+ last_stdout.should == output
27
+ Then("it should #{success}")
28
+ end
29
+
30
+ Then /it should (fail|pass) with (.*)/ do |success, output|
31
+ last_stdout.should == Features2Cards::VERSION::STRING + "\n"
32
+ Then("it should #{success}")
33
+ end
34
+
35
+ Then /^"(.*)" should exist$/ do |file|
36
+ in_current_dir do
37
+ File.exists?(file).should be_true
38
+ FileUtils.rm(file)
39
+ end
40
+ end
41
+
@@ -0,0 +1,79 @@
1
+ require 'rubygems'
2
+ require 'tempfile'
3
+ require 'spec/expectations'
4
+ require 'fileutils'
5
+ require 'forwardable'
6
+
7
+ class Features2CardsWorld
8
+ extend Forwardable
9
+ def_delegators Features2CardsWorld, :examples_dir, :self_test_dir, :working_dir, :features2cards_lib_dir
10
+
11
+ def self.examples_dir(subdir=nil)
12
+ @examples_dir ||= File.expand_path(File.join(File.dirname(__FILE__), '../../examples'))
13
+ subdir ? File.join(@examples_dir, subdir) : @examples_dir
14
+ end
15
+
16
+ def self.self_test_dir
17
+ @self_test_dir ||= examples_dir('self_test')
18
+ end
19
+
20
+ def self.working_dir
21
+ @working_dir ||= examples_dir('self_test/tmp')
22
+ end
23
+
24
+ def features2cards_lib_dir
25
+ @features2cards_lib_dir ||= File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
26
+ end
27
+
28
+ def initialize
29
+ @current_dir = self_test_dir
30
+ end
31
+
32
+ private
33
+ attr_reader :last_exit_status, :last_stderr
34
+
35
+ # The last standard out, with the duration line taken out (unpredictable)
36
+ def last_stdout
37
+ strip_duration(@last_stdout)
38
+ end
39
+
40
+ def strip_duration(s)
41
+ s.gsub(/^\d+m\d+\.\d+s\n/m, "")
42
+ end
43
+
44
+ def replace_duration(s, replacement)
45
+ s.gsub(/\d+m\d+\.\d+s/m, replacement)
46
+ end
47
+
48
+ def create_file(file_name, file_content)
49
+ file_content.gsub!("FEATURES2CARDS_LIB", "'#{features2cards_lib_dir}'") # Some files, such as Rakefiles need to use the lib dir
50
+ in_current_dir do
51
+ File.open(file_name, 'w') { |f| f << file_content }
52
+ end
53
+ end
54
+
55
+ def in_current_dir(&block)
56
+ Dir.chdir(@current_dir, &block)
57
+ end
58
+
59
+ def run(command)
60
+ stderr_file = Tempfile.new('features2cards')
61
+ stderr_file.close
62
+ in_current_dir do
63
+ @last_stdout = `#{command} 2> #{stderr_file.path}`
64
+ @last_exit_status = $?.exitstatus
65
+ end
66
+ @last_stderr = IO.read(stderr_file.path)
67
+ end
68
+
69
+ end
70
+
71
+ World do
72
+ Features2CardsWorld.new
73
+ end
74
+
75
+ Before do
76
+ FileUtils.rm_rf Features2CardsWorld.working_dir
77
+ FileUtils.mkdir Features2CardsWorld.working_dir
78
+ end
79
+
@@ -0,0 +1,118 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{features2cards}
5
+ s.version = "0.4.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Bryan Helmkamp"]
9
+ s.date = %q{2009-11-09}
10
+ s.default_executable = %q{features2cards}
11
+ s.description = %q{Create PDF cards from Cucumber features and scenarios for printing. We use it as we kick
12
+ off our sprints to create index cards for our task board.}
13
+ s.email = %q{bryan@brynary.com}
14
+ s.executables = ["features2cards"]
15
+ s.extra_rdoc_files = [
16
+ "History.txt",
17
+ "README.rdoc",
18
+ "MIT-LICENSE.txt"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "History.txt",
23
+ "MIT-LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "Thorfile",
27
+ "bin/features2cards",
28
+ "examples/i18n/.gitignore",
29
+ "examples/i18n/README.textile",
30
+ "examples/i18n/Rakefile",
31
+ "examples/i18n/ar/addition.feature",
32
+ "examples/i18n/bg/addition.feature",
33
+ "examples/i18n/bg/consecutive_calculations.feature",
34
+ "examples/i18n/bg/division.feature",
35
+ "examples/i18n/cat/suma.feature",
36
+ "examples/i18n/da/summering.feature",
37
+ "examples/i18n/de/addition.feature",
38
+ "examples/i18n/de/division.feature",
39
+ "examples/i18n/en-lol/stuffing.feature",
40
+ "examples/i18n/en/addition.feature",
41
+ "examples/i18n/en/division.feature",
42
+ "examples/i18n/es/adicion.feature",
43
+ "examples/i18n/et/jagamine.feature",
44
+ "examples/i18n/et/liitmine.feature",
45
+ "examples/i18n/fi/jakolasku.feature",
46
+ "examples/i18n/fi/yhteenlasku.feature",
47
+ "examples/i18n/fr/addition.feature",
48
+ "examples/i18n/he/addition.feature",
49
+ "examples/i18n/he/division.feature",
50
+ "examples/i18n/hu/addition.feature",
51
+ "examples/i18n/hu/division.feature",
52
+ "examples/i18n/id/addition.feature",
53
+ "examples/i18n/id/division.feature",
54
+ "examples/i18n/it/somma.feature",
55
+ "examples/i18n/ja/addition.feature",
56
+ "examples/i18n/ja/division.feature",
57
+ "examples/i18n/ko/addition.feature",
58
+ "examples/i18n/ko/division.feature",
59
+ "examples/i18n/lt/addition.feature",
60
+ "examples/i18n/lt/division.feature",
61
+ "examples/i18n/lv/addition.feature",
62
+ "examples/i18n/lv/division.feature",
63
+ "examples/i18n/no/summering.feature",
64
+ "examples/i18n/pl/addition.feature",
65
+ "examples/i18n/pl/division.feature",
66
+ "examples/i18n/pt/adicao.feature",
67
+ "examples/i18n/ro/suma.feature",
68
+ "examples/i18n/ru/addition.feature",
69
+ "examples/i18n/ru/consecutive_calculations.feature",
70
+ "examples/i18n/ru/division.feature",
71
+ "examples/i18n/se/summering.feature",
72
+ "examples/i18n/sk/addition.feature",
73
+ "examples/i18n/sk/division.feature",
74
+ "examples/i18n/zh-CN/addition.feature",
75
+ "examples/i18n/zh-TW/addition.feature",
76
+ "examples/i18n/zh-TW/division.feature",
77
+ "examples/self_test/.gitignore",
78
+ "examples/self_test/features/features2cards.feature",
79
+ "features/features2cards_cli.feature",
80
+ "features/step_definitions/features2cards_steps.rb",
81
+ "features/support/env.rb",
82
+ "features2cards.gemspec",
83
+ "lib/features2cards.rb",
84
+ "lib/features2cards/card.rb",
85
+ "lib/features2cards/cli.rb",
86
+ "lib/features2cards/platform.rb",
87
+ "lib/features2cards/prawn.rb",
88
+ "spec/features2cards/card_spec.rb",
89
+ "spec/features2cards/cli_spec.rb",
90
+ "spec/features2cards/prawn_spec.rb",
91
+ "spec/spec.opts",
92
+ "spec/spec_helper.rb"
93
+ ]
94
+ s.homepage = %q{http://github.com/brynary/features2cards}
95
+ s.require_paths = ["lib"]
96
+ s.rubyforge_project = %q{features2cards}
97
+ s.rubygems_version = %q{1.3.5}
98
+ s.summary = %q{Generate printable PDF index cards from Cucumber feature files}
99
+ s.test_files = [
100
+ "spec/features2cards/card_spec.rb",
101
+ "spec/features2cards/cli_spec.rb",
102
+ "spec/features2cards/prawn_spec.rb",
103
+ "spec/spec_helper.rb"
104
+ ]
105
+
106
+ if s.respond_to? :specification_version then
107
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
108
+ s.specification_version = 3
109
+
110
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
111
+ s.add_runtime_dependency(%q<prawn>, [">= 0"])
112
+ else
113
+ s.add_dependency(%q<prawn>, [">= 0"])
114
+ end
115
+ else
116
+ s.add_dependency(%q<prawn>, [">= 0"])
117
+ end
118
+ end
@@ -1,17 +1,11 @@
1
- require "rubygems"
2
-
3
- unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
4
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
5
- end
6
-
7
1
  require "features2cards/platform"
8
2
  require "features2cards/cli"
9
3
 
10
4
  module Features2Cards#:nodoc:
11
5
  class VERSION #:nodoc:
12
6
  MAJOR = 0
13
- MINOR = 3
14
- TINY = 1
7
+ MINOR = 4
8
+ TINY = 0
15
9
  PATCH = nil # Set to nil for official release
16
10
 
17
11
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
@@ -1,11 +1,11 @@
1
1
  module Features2Cards
2
2
  class Card
3
-
3
+
4
4
  attr_reader :type
5
5
  attr_reader :body
6
6
  attr_reader :footer
7
7
 
8
- def self.for_feature(feature, lang)
8
+ def self.for_feature(feature)
9
9
  actual_feature = feature.to_sexp()
10
10
  actual_feature.shift
11
11
  actual_feature.shift
@@ -14,10 +14,10 @@ module Features2Cards
14
14
  body = actual_feature[0].gsub(/^\s*#{title}\n/, '')
15
15
  card = [new(title, body, "")]
16
16
  footer = title
17
-
17
+
18
18
  actual_feature.shift
19
19
  scenarios = actual_feature
20
-
20
+
21
21
  scenarios.map do |scenario|
22
22
  case(scenario[0])
23
23
  when :scenario_outline
@@ -25,25 +25,29 @@ module Features2Cards
25
25
  when :scenario
26
26
  scenario.shift
27
27
  scenario.shift
28
- end
28
+ when :tag
29
+ next
30
+ when :comment
31
+ next
32
+ end
29
33
  title = scenario[0] + " " + scenario[1]
30
34
  scenario.shift
31
35
  scenario.shift
32
36
  body = ""
33
37
  scenario.map do |step|
34
- body += step[2] + " " + step[3] + "\n" if step[0] == :step or step[0] == :step_invocation
38
+ body += step[2] + " " + step[3] + "\n" if step[0] == :step or step[0] == :step_invocation
35
39
  end
36
40
  card.push(new(title, body, footer))
37
41
  end
38
-
42
+
39
43
  return card
40
44
  end
41
-
45
+
42
46
  def initialize(type, body, footer = nil)
43
47
  @type = type
44
48
  @body = body
45
49
  @footer = footer
46
50
  end
47
-
51
+
48
52
  end
49
- end
53
+ end