cuke_modeler 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.simplecov +8 -0
  4. data/Gemfile +4 -0
  5. data/History.rdoc +3 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +73 -0
  8. data/Rakefile +38 -0
  9. data/cuke_modeler.gemspec +29 -0
  10. data/features/analysis/test_comparison.feature +123 -0
  11. data/features/analysis/test_manipulation.feature +37 -0
  12. data/features/modeling/background_modeling.feature +75 -0
  13. data/features/modeling/background_output.feature +130 -0
  14. data/features/modeling/directory_modeling.feature +120 -0
  15. data/features/modeling/directory_output.feature +13 -0
  16. data/features/modeling/doc_string_modeling.feature +63 -0
  17. data/features/modeling/doc_string_output.feature +71 -0
  18. data/features/modeling/example_modeling.feature +111 -0
  19. data/features/modeling/example_output.feature +192 -0
  20. data/features/modeling/feature_file_modeling.feature +64 -0
  21. data/features/modeling/feature_file_output.feature +13 -0
  22. data/features/modeling/feature_modeling.feature +164 -0
  23. data/features/modeling/feature_output.feature +244 -0
  24. data/features/modeling/outline_modeling.feature +100 -0
  25. data/features/modeling/outline_output.feature +197 -0
  26. data/features/modeling/row_modeling.feature +77 -0
  27. data/features/modeling/row_output.feature +27 -0
  28. data/features/modeling/scenario_modeling.feature +89 -0
  29. data/features/modeling/scenario_output.feature +147 -0
  30. data/features/modeling/step_modeling.feature +85 -0
  31. data/features/modeling/step_output.feature +52 -0
  32. data/features/modeling/table_modeling.feature +52 -0
  33. data/features/modeling/table_output.feature +42 -0
  34. data/features/modeling/table_row_modeling.feature +67 -0
  35. data/features/modeling/table_row_output.feature +27 -0
  36. data/features/modeling/tag_modeling.feature +58 -0
  37. data/features/modeling/tag_output.feature +16 -0
  38. data/features/step_definitions/action_steps.rb +3 -0
  39. data/features/step_definitions/background_steps.rb +81 -0
  40. data/features/step_definitions/directory_steps.rb +52 -0
  41. data/features/step_definitions/doc_string_steps.rb +63 -0
  42. data/features/step_definitions/feature_file_steps.rb +41 -0
  43. data/features/step_definitions/feature_steps.rb +96 -0
  44. data/features/step_definitions/outline_steps.rb +252 -0
  45. data/features/step_definitions/setup_steps.rb +50 -0
  46. data/features/step_definitions/spec_steps.rb +18 -0
  47. data/features/step_definitions/step_steps.rb +159 -0
  48. data/features/step_definitions/table_steps.rb +54 -0
  49. data/features/step_definitions/tag_steps.rb +61 -0
  50. data/features/step_definitions/test_steps.rb +114 -0
  51. data/features/step_definitions/verification_steps.rb +9 -0
  52. data/features/support/env.rb +27 -0
  53. data/features/support/transforms.rb +3 -0
  54. data/lib/cuke_modeler.rb +29 -0
  55. data/lib/cuke_modeler/background.rb +38 -0
  56. data/lib/cuke_modeler/containing.rb +18 -0
  57. data/lib/cuke_modeler/directory.rb +86 -0
  58. data/lib/cuke_modeler/doc_string.rb +87 -0
  59. data/lib/cuke_modeler/example.rb +184 -0
  60. data/lib/cuke_modeler/feature.rb +147 -0
  61. data/lib/cuke_modeler/feature_element.rb +73 -0
  62. data/lib/cuke_modeler/feature_file.rb +77 -0
  63. data/lib/cuke_modeler/nested.rb +34 -0
  64. data/lib/cuke_modeler/outline.rb +68 -0
  65. data/lib/cuke_modeler/parsing.rb +32 -0
  66. data/lib/cuke_modeler/raw.rb +20 -0
  67. data/lib/cuke_modeler/row.rb +64 -0
  68. data/lib/cuke_modeler/scenario.rb +45 -0
  69. data/lib/cuke_modeler/sourceable.rb +20 -0
  70. data/lib/cuke_modeler/step.rb +214 -0
  71. data/lib/cuke_modeler/table.rb +90 -0
  72. data/lib/cuke_modeler/table_row.rb +64 -0
  73. data/lib/cuke_modeler/tag.rb +62 -0
  74. data/lib/cuke_modeler/taggable.rb +54 -0
  75. data/lib/cuke_modeler/test_element.rb +77 -0
  76. data/lib/cuke_modeler/version.rb +3 -0
  77. data/lib/cuke_modeler/world.rb +113 -0
  78. data/spec/integration/background_integration_spec.rb +72 -0
  79. data/spec/integration/directory_integration_spec.rb +48 -0
  80. data/spec/integration/doc_string_integration_spec.rb +66 -0
  81. data/spec/integration/example_integration_spec.rb +94 -0
  82. data/spec/integration/feature_file_integration_spec.rb +44 -0
  83. data/spec/integration/feature_integration_spec.rb +152 -0
  84. data/spec/integration/outline_integration_spec.rb +92 -0
  85. data/spec/integration/scenario_integration_spec.rb +80 -0
  86. data/spec/integration/step_integration_spec.rb +184 -0
  87. data/spec/integration/table_integration_spec.rb +86 -0
  88. data/spec/integration/table_row_integration_spec.rb +68 -0
  89. data/spec/integration/tag_integration_spec.rb +67 -0
  90. data/spec/integration/world_integration_spec.rb +13 -0
  91. data/spec/spec_helper.rb +30 -0
  92. data/spec/unit/background_unit_spec.rb +55 -0
  93. data/spec/unit/bare_bones_unit_specs.rb +13 -0
  94. data/spec/unit/containing_element_unit_specs.rb +17 -0
  95. data/spec/unit/directory_unit_spec.rb +103 -0
  96. data/spec/unit/doc_string_unit_spec.rb +109 -0
  97. data/spec/unit/example_unit_spec.rb +251 -0
  98. data/spec/unit/feature_element_unit_spec.rb +19 -0
  99. data/spec/unit/feature_element_unit_specs.rb +46 -0
  100. data/spec/unit/feature_file_unit_spec.rb +94 -0
  101. data/spec/unit/feature_unit_spec.rb +135 -0
  102. data/spec/unit/nested_element_unit_specs.rb +36 -0
  103. data/spec/unit/nested_unit_spec.rb +37 -0
  104. data/spec/unit/outline_unit_spec.rb +91 -0
  105. data/spec/unit/parsing_unit_spec.rb +21 -0
  106. data/spec/unit/prepopulated_unit_specs.rb +13 -0
  107. data/spec/unit/raw_element_unit_specs.rb +24 -0
  108. data/spec/unit/raw_unit_spec.rb +25 -0
  109. data/spec/unit/row_unit_spec.rb +55 -0
  110. data/spec/unit/scenario_unit_spec.rb +71 -0
  111. data/spec/unit/sourceable_unit_spec.rb +17 -0
  112. data/spec/unit/sourced_element_unit_specs.rb +18 -0
  113. data/spec/unit/step_unit_spec.rb +259 -0
  114. data/spec/unit/table_row_unit_spec.rb +55 -0
  115. data/spec/unit/table_unit_spec.rb +96 -0
  116. data/spec/unit/tag_unit_spec.rb +51 -0
  117. data/spec/unit/taggable_unit_spec.rb +78 -0
  118. data/spec/unit/tagged_element_unit_specs.rb +63 -0
  119. data/spec/unit/test_element_unit_spec.rb +40 -0
  120. data/spec/unit/test_element_unit_specs.rb +31 -0
  121. data/spec/unit/world_unit_spec.rb +130 -0
  122. metadata +364 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 876bbe0bbe75f460596777b28b51a51bd3347c01
4
+ data.tar.gz: 5ee73b6f5366259721f57dbca7ca7120b9497243
5
+ SHA512:
6
+ metadata.gz: f8b1099a66acacf4442cc6d5a64f61ae52762727fe8f70279a6049b450de56b49335b502ec7ecbc84395404ac0081df7792a6de6a2b6f6e7c1bbcb361e590a36
7
+ data.tar.gz: 387d74e18f8be3cd4b028f8f2d1e79660ee67041636f701af58601bf660b9731e97ed5482e4c91add71f8f33856b05274e785dacd79c5a19d6e4a4f9749b2bf6
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.simplecov ADDED
@@ -0,0 +1,8 @@
1
+ SimpleCov.start do
2
+ root File.dirname(__FILE__)
3
+
4
+ add_filter '/features/'
5
+ add_filter '/spec/'
6
+
7
+ merge_timeout 300
8
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cuke_modeler.gemspec
4
+ gemspec
data/History.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ === Version 0.0.1 / 2014-06-02
2
+
3
+ * Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Eric Kessler
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # CukeModeler
2
+
3
+ The intention of this gem is to provide the ability to model a Cucumber test
4
+ suite. It provides a foundation upon which to build other useful tools for
5
+ interacting with a test suite that is written in Gherkin (and written with
6
+ Cucumber in particular).
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'cuke_modeler'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install cuke_modeler
21
+
22
+ ## Usage
23
+
24
+ First, load up the gem code.
25
+
26
+ require 'cuke_modeler'
27
+
28
+ Next, choose what you want to model. Directories and feature files are the most
29
+ common thing to model but smaller portions of a test suite can be modeled as well.
30
+
31
+ directory = CukeModeler::Directory.new('path/to/the/code_directory')
32
+ file = CukeModeler::FeatureFile.new('path/to/the/feature_file')
33
+
34
+ gherkin = "Scenario: some test\n* a step"
35
+ test = CukeModeler::Scenario.new(gherkin)
36
+
37
+ The models can then be inspected for information.
38
+
39
+ directory.path #=> 'path/to/the/code_directory'
40
+ file.feature.name #=> 'the name of the feature'
41
+ test.steps.count #=> 1
42
+
43
+
44
+ Things can be done in the other direction as well by starting with empty models
45
+ and setting their attributes afterward.
46
+
47
+ step = CukeModeler::Step.new
48
+ step.keyword = 'Given'
49
+ step.base = 'some step'
50
+
51
+ test = CukeModeler::Scenario.new
52
+ test.steps = [step]
53
+
54
+ test.to_s #=> "Scenario:\n Given some step"
55
+
56
+ One could, if so inclined, use this method to dynamically edit or even create an
57
+ entire test suite.
58
+
59
+
60
+ ### Other gems that are (or soon will be) powered by cuke_modeler
61
+
62
+ https://github.com/enkessler/cucumber_analytics
63
+ https://github.com/enkessler/cql
64
+ https://github.com/enkessler/cuketagger
65
+ https://github.com/enkessler/cuke_cataloger
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require "bundler/gem_tasks"
2
+ require 'cucumber/rake/task'
3
+ require 'rspec/core/rake_task'
4
+
5
+
6
+ def set_cucumber_options(options)
7
+ ENV['CUCUMBER_OPTS'] = options
8
+ end
9
+
10
+ def combine_options(set_1, set_2)
11
+ set_2 ? "#{set_1} #{set_2}" : set_1
12
+ end
13
+
14
+
15
+ task :clear_coverage do
16
+ code_coverage_directory = "#{File.dirname(__FILE__)}/coverage"
17
+
18
+ FileUtils.remove_dir(code_coverage_directory, true)
19
+ end
20
+
21
+ desc 'Run all Cucumber tests for the gem'
22
+ task :tests, [:options] do |t, args|
23
+ set_cucumber_options(combine_options("-t ~@wip -t ~@off -f progress", args[:options]))
24
+ end
25
+ Cucumber::Rake::Task.new(:tests)
26
+
27
+ desc 'Run all RSpec tests for the gem'
28
+ RSpec::Core::RakeTask.new(:specs) do |t|
29
+ t.rspec_opts = "-t ~wip -t ~off"
30
+ end
31
+
32
+ desc 'Run All The Things'
33
+ task :everything => :clear_coverage do
34
+ Rake::Task[:specs].invoke
35
+ Rake::Task[:tests].invoke('-t ~@redundant')
36
+ end
37
+
38
+ task :default => :everything
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cuke_modeler/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cuke_modeler"
8
+ spec.version = CukeModeler::VERSION
9
+ spec.authors = ["Eric Kessler"]
10
+ spec.email = ["morrow748@gmail.com"]
11
+ spec.summary = %q{A gem providing functionality to model a Cucumber test suite.}
12
+ spec.homepage = 'https://github.com/enkessler/cuke_modeler'
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency('gherkin')
21
+ spec.add_runtime_dependency('json', '~> 1.0')
22
+ spec.add_runtime_dependency('multi_json', '~> 1.0')
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.5"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency 'cucumber'
27
+ spec.add_development_dependency 'rspec', '~> 2.14.0'
28
+ spec.add_development_dependency 'simplecov'
29
+ end
@@ -0,0 +1,123 @@
1
+ Feature: Test equality can be determined.
2
+
3
+
4
+ Acceptance criteria
5
+
6
+ Tests can be compared for equality.
7
+ 1. tests whose steps are the same except for arguments and keywords (i.e.
8
+ they match the same step definition) are equal
9
+
10
+
11
+ Background: Test file setup.
12
+ Given the following feature file:
13
+ """
14
+ Feature: A feature with duplicate tests.
15
+
16
+ Scenario: A test
17
+ Given this *parameterized* step takes a table:
18
+ | data 1 |
19
+ | data 2 |
20
+ And some setup step
21
+ When a step with a *parameter*
22
+ And a big step:
23
+ \"\"\"
24
+ little doc block
25
+ \"\"\"
26
+ Then *lots* *of* *parameters*
27
+
28
+ Scenario: Same test, different arguments and keywords
29
+ Given this *similarly parameterized* step takes a table:
30
+ | data 3 |
31
+ | data 4 |
32
+ Given some setup step
33
+ When a step with a *parameter*
34
+ * a big step:
35
+ \"\"\"
36
+ A little
37
+ bigger doc block
38
+ \"\"\"
39
+ Then *lots* *of* *parameters*
40
+
41
+ Scenario Outline: This is the same test as an outline
42
+ Given this *parameterized* step takes a table:
43
+ | <param1> |
44
+ | <param2> |
45
+ And some setup step
46
+ When a step with a *parameter*
47
+ And a big step:
48
+ \"\"\"
49
+ little doc block
50
+ \"\"\"
51
+ Then *lots* *of* *parameters*
52
+ Examples:
53
+ | param1 | param2 |
54
+ | x | y |
55
+ Examples:
56
+ | param1 | param2 |
57
+ | a | b |
58
+
59
+ Scenario Outline: Same outline, different arguments and keywords
60
+ Given this *similarly parameterized* step takes a table:
61
+ | <param3> |
62
+ | <param4> |
63
+ Given some setup step
64
+ When a step with a *slightly different parameter*
65
+ * a big step:
66
+ \"\"\"
67
+ A little
68
+ bigger doc block
69
+ \"\"\"
70
+ Then *lots* *of effectively the same* *parameters*
71
+ Examples:
72
+ | param1 | param2 |
73
+ | h | k |
74
+ Examples:
75
+ | param1 | param2 |
76
+ | i | j |
77
+
78
+ Scenario: A different test
79
+ Given this *parameterized* step takes a table:
80
+ | data 1 |
81
+ | data 2 |
82
+ And not the same setup step as before
83
+ When a step with a *parameter*
84
+ And a big step:
85
+ \"\"\"
86
+ little doc block
87
+ \"\"\"
88
+ Then *lots* *of* *parameters*
89
+
90
+ Scenario Outline: This is the same different test as an outline
91
+ Given this *similarly parameterized* step takes a table:
92
+ | <param1> |
93
+ | <param2> |
94
+ And not the same setup step as before
95
+ When a step with a *slightly different parameter*
96
+ And a big step:
97
+ \"\"\"
98
+ A little
99
+ bigger doc block
100
+ \"\"\"
101
+ Then *lots* *of effectively the same* *parameters*
102
+ Examples:
103
+ | param1 | param2 |
104
+ | x | y |
105
+ Examples:
106
+ | param1 | param2 |
107
+ | a | b |
108
+ """
109
+ And parameter delimiters of "*" and "*"
110
+ When the file is read
111
+
112
+
113
+ Scenario: Scenario to Scenario comparison
114
+ Then test "1" is equal to test "2"
115
+ And test "1" is not equal to test "5"
116
+
117
+ Scenario: Outline to Outline comparison
118
+ Then test "3" is equal to test "4"
119
+ And test "3" is not equal to test "6"
120
+
121
+ Scenario: Scenario to Outline comparison
122
+ Then test "1" is equal to test "3"
123
+ And test "1" is not equal to test "6"
@@ -0,0 +1,37 @@
1
+ Feature: Tests can be manipulated in various ways.
2
+
3
+
4
+ Acceptance criteria
5
+
6
+ Tests can be manipulated:
7
+ 1. outlines can have rows added and removed
8
+
9
+
10
+ Background: Test file setup.
11
+ Given the following feature file:
12
+ """
13
+ Feature: A feature containing our starting outline.
14
+
15
+ Scenario Outline:
16
+ Given this *parameterized* step takes a table:
17
+ | <param1> |
18
+ | <param2> |
19
+ Then I don't really need another step
20
+ Examples: Only one row to start with
21
+ | param1 | param2 |
22
+ | x | y |
23
+ """
24
+ And parameter delimiters of "*" and "*"
25
+ And the file is read
26
+
27
+ Scenario: Rows can be added to an outline
28
+ When the test example block has the following rows added to it:
29
+ | 1,2 |
30
+ Then the test example block rows are as follows:
31
+ | x,y |
32
+ | 1,2 |
33
+
34
+ Scenario: Rows can be removed from an outline
35
+ When the test example block has the following rows removed from it:
36
+ | x,y |
37
+ Then the test example block has no rows
@@ -0,0 +1,75 @@
1
+ Feature: Background elements can be modeled.
2
+
3
+
4
+ Acceptance criteria
5
+
6
+ 1. All conceptual pieces of a background can be modeled:
7
+ - the background's name
8
+ - the background's description
9
+ - the background's steps
10
+ - the background's source line
11
+ - the background's raw element
12
+
13
+ 2. Backgrounds can be outputted in a convenient form
14
+
15
+
16
+ Background: Test file setup.
17
+ Given the following feature file:
18
+ """
19
+ Feature:
20
+
21
+ Background: Some general test setup stuff.
22
+
23
+ Some background description.
24
+
25
+ Some more.
26
+ Even more.
27
+
28
+ Given a setup step
29
+ And another setup step
30
+ When an action step
31
+ """
32
+ And parameter delimiters of "*" and "*"
33
+ When the file is read
34
+
35
+
36
+ Scenario: The raw background element is modeled.
37
+ Then the background correctly stores its underlying implementation
38
+
39
+ Scenario: The background source line is modeled.
40
+ Then the background is found to have the following properties:
41
+ | source_line | 3 |
42
+
43
+ Scenario: The background name is modeled.
44
+ Then the background is found to have the following properties:
45
+ | name | Some general test setup stuff. |
46
+
47
+ Scenario: The background description is modeled.
48
+ Then the background has the following description:
49
+ """
50
+
51
+ Some background description.
52
+
53
+ Some more.
54
+ Even more.
55
+ """
56
+
57
+ Scenario: The background steps are modeled.
58
+ Then the background's steps are as follows:
59
+ | a setup step |
60
+ | another setup step |
61
+ | an action step |
62
+
63
+ Scenario: Convenient output of a background
64
+ Then the background has convenient output
65
+
66
+ @redundant
67
+ Scenario Outline: Background models pass all other specifications
68
+ Exact specifications detailing the API for background models.
69
+ Given that there are "<additional specifications>" detailing models
70
+ When the corresponding specifications are run
71
+ Then all of those specifications are met
72
+ Examples:
73
+ | additional specifications |
74
+ | background_unit_spec.rb |
75
+ | background_integration_spec.rb |