cql 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cql.rb +18 -11
  3. data/lib/cql/dsl.rb +14 -2
  4. data/lib/cql/filters.rb +12 -6
  5. data/lib/cql/map_reduce.rb +29 -11
  6. data/lib/cql/model_dsl.rb +18 -0
  7. data/lib/cql/queriable.rb +14 -0
  8. data/lib/cql/sso_filters.rb +3 -2
  9. data/lib/cql/version.rb +1 -1
  10. data/testing/cql_test_model.rb +42 -0
  11. data/testing/cucumber/features/clauses/as_clause.feature +136 -0
  12. data/testing/cucumber/features/clauses/from_clause.feature +126 -0
  13. data/testing/cucumber/features/clauses/select_clause.feature +117 -0
  14. data/testing/cucumber/features/clauses/transform_clause.feature +153 -0
  15. data/testing/cucumber/features/clauses/with_clause.feature +363 -0
  16. data/testing/cucumber/features/dsl.feature +77 -0
  17. data/testing/cucumber/features/model_querying.feature +18 -0
  18. data/testing/cucumber/features/repository.feature +23 -0
  19. data/testing/cucumber/step_definitions/query_steps.rb +7 -0
  20. data/testing/cucumber/step_definitions/setup_steps.rb +25 -0
  21. data/testing/cucumber/step_definitions/verification_steps.rb +78 -0
  22. data/testing/cucumber/support/env.rb +24 -0
  23. data/testing/cucumber/support/transforms.rb +3 -0
  24. data/testing/fixtures/features/combined/a/f1_4_scenarios_5_so.feature +59 -0
  25. data/testing/fixtures/features/combined/a/f2_7_scenarios_2_so.feature +43 -0
  26. data/testing/fixtures/features/combined/a/f3_2_scenarios_3_so.feature +30 -0
  27. data/testing/fixtures/features/combined/b/f1_1_tag.feature +6 -0
  28. data/testing/fixtures/features/combined/b/f2_2_tags.feature +6 -0
  29. data/testing/fixtures/features/combined/b/f3_3_tags.feature +6 -0
  30. data/testing/fixtures/features/examples/basic/test_with_scenarios.feature +15 -0
  31. data/testing/fixtures/features/examples/filters/tag_count/simple.feature +21 -0
  32. data/testing/fixtures/features/examples/filters/tag_count/simple2.feature +21 -0
  33. data/testing/fixtures/features/examples/filters/tags/simple.feature +34 -0
  34. data/testing/fixtures/features/examples/filters/tags2/simple.feature +34 -0
  35. data/testing/fixtures/features/examples/filters/tags2/simple2.feature +34 -0
  36. data/testing/fixtures/features/examples/multiple_examples/test_with_scenarios.feature +43 -0
  37. data/testing/fixtures/features/examples/name_filter/name.feature +19 -0
  38. data/testing/fixtures/features/got/Lannisters.feature +24 -0
  39. data/testing/fixtures/features/got/Starks.feature +18 -0
  40. data/testing/fixtures/features/scen_outlines/basic/test_with_scenarios.feature +15 -0
  41. data/testing/fixtures/features/scen_outlines/filters/tag_count/simple.feature +21 -0
  42. data/testing/fixtures/features/scen_outlines/filters/tag_count/simple2.feature +21 -0
  43. data/testing/fixtures/features/scen_outlines/filters/tags/simple.feature +34 -0
  44. data/testing/fixtures/features/scen_outlines/filters/tags2/simple.feature +34 -0
  45. data/testing/fixtures/features/scen_outlines/filters/tags2/simple2.feature +34 -0
  46. data/testing/fixtures/features/scen_outlines/line_count/simple.feature +12 -0
  47. data/testing/fixtures/features/scen_outlines/line_count/simple2.feature +16 -0
  48. data/testing/fixtures/features/scen_outlines/line_filter/ll.feature +13 -0
  49. data/testing/fixtures/features/scen_outlines/multiple_examples/test_with_scenarios.feature +43 -0
  50. data/testing/fixtures/features/scen_outlines/name_filter/name.feature +19 -0
  51. data/testing/fixtures/features/scenario/line_count/simple.feature +9 -0
  52. data/testing/fixtures/features/scenario/line_count/simple2.feature +12 -0
  53. data/testing/fixtures/features/scenario/line_filter/ll.feature +9 -0
  54. data/testing/fixtures/features/scenario/name_filter/name.feature +13 -0
  55. data/testing/fixtures/features/scenario/simple/simple.feature +8 -0
  56. data/testing/fixtures/features/scenario/simple/test.feature +9 -0
  57. data/testing/fixtures/features/scenario/simple/test2.feature +5 -0
  58. data/testing/fixtures/features/scenario/simple/test_full.feature +22 -0
  59. data/testing/fixtures/features/scenario/simple2/test_full.feature +23 -0
  60. data/testing/fixtures/features/scenario/table/simple.feature +11 -0
  61. data/testing/fixtures/features/scenario/tag_count/simple.feature +17 -0
  62. data/testing/fixtures/features/scenario/tag_count/simple2.feature +17 -0
  63. data/testing/fixtures/features/scenario/tagged_features/simple.feature +8 -0
  64. data/testing/fixtures/features/scenario/tagged_features/test.feature +10 -0
  65. data/testing/fixtures/features/scenario/tagged_features/test2.feature +6 -0
  66. data/testing/fixtures/features/scenario/tagged_features/test_full.feature +22 -0
  67. data/testing/fixtures/features/scenario/tags/simple.feature +24 -0
  68. data/testing/fixtures/features/scenario/tags2/simple.feature +24 -0
  69. data/testing/fixtures/features/scenario/tags2/simple2.feature +24 -0
  70. data/testing/fixtures/features/scenario/tags3/simple.feature +21 -0
  71. data/testing/gemfiles/cuke_modeler0.gemfile +30 -0
  72. data/testing/gemfiles/cuke_modeler1.gemfile +30 -0
  73. data/testing/rspec/spec/dsl_spec.rb +600 -0
  74. data/testing/rspec/spec/filter_example_spec.rb +65 -0
  75. data/testing/rspec/spec/filter_feature_dsl_spec.rb +286 -0
  76. data/testing/rspec/spec/filter_sso_spec.rb +202 -0
  77. data/testing/rspec/spec/line_count_filterable_specs.rb +74 -0
  78. data/testing/rspec/spec/line_filterable_specs.rb +52 -0
  79. data/testing/rspec/spec/map_reduce_spec.rb +135 -0
  80. data/testing/rspec/spec/model_query_spec.rb +49 -0
  81. data/testing/rspec/spec/multiple_queries_spec.rb +24 -0
  82. data/testing/rspec/spec/name_filterable_specs.rb +52 -0
  83. data/testing/rspec/spec/queriable_specs.rb +45 -0
  84. data/testing/rspec/spec/repository_spec.rb +82 -0
  85. data/testing/rspec/spec/select_feature_dsl_spec.rb +114 -0
  86. data/testing/rspec/spec/select_scen_outline_dsl_spec.rb +234 -0
  87. data/testing/rspec/spec/select_scenario_dsl_spec.rb +132 -0
  88. data/testing/rspec/spec/spec_helper.rb +42 -0
  89. data/testing/rspec/spec/tag_filterable_specs.rb +107 -0
  90. metadata +170 -5
@@ -0,0 +1,126 @@
1
+ Feature: 'from' clause
2
+
3
+ The *from* clause specifies what type of models from which the *select* clause will gather its values. The *from* clause can take class objects defined in CukeModeler as well as shorthand versions thereof. The clause can also be given a special identifier in order to gather values from all models instead of specific model types.
4
+
5
+ The following are some example values:
6
+
7
+ CukeModeler::Outline (exact class)
8
+ outline (singular)
9
+ outlines (pluralized)
10
+
11
+ Sample usage:
12
+ cql_repo.query do
13
+ select name
14
+ from scenarios
15
+ end
16
+
17
+ This clause can be repeated multiple times. The arguments for successive clauses are simply added to the previous arguments.
18
+
19
+
20
+ Background: A sample Cucumber suite
21
+ Given a directory "test_directory"
22
+ And a file "test_directory/test_file_1.feature":
23
+ """
24
+ Feature: A test feature
25
+
26
+ Scenario: Test 1
27
+ * some steps
28
+
29
+ @special_tag
30
+ Scenario: Test 2
31
+ * some other steps
32
+
33
+ Scenario Outline: Test 3
34
+ * some steps
35
+ Examples: First examples
36
+ | param |
37
+ | value |
38
+ Examples: Second examples
39
+ | param |
40
+ | value |
41
+ """
42
+ And a repository is made from "test_directory"
43
+
44
+
45
+ Scenario: Using 'from' to specify what kind of objects from which to return attributes
46
+ When the following query is executed:
47
+ """
48
+ select name
49
+ from scenarios
50
+ """
51
+ Then the following values are returned:
52
+ | name |
53
+ | Test 1 |
54
+ | Test 2 |
55
+ When the following query is executed:
56
+ """
57
+ select name
58
+ from outlines
59
+ """
60
+ Then the following values are returned:
61
+ | name |
62
+ | Test 3 |
63
+
64
+ Scenario: Gathering from multiple sources
65
+ When the following query is executed:
66
+ """
67
+ select name
68
+ from scenarios, outlines
69
+ """
70
+ Then the following values are returned:
71
+ | name |
72
+ | Test 1 |
73
+ | Test 2 |
74
+ | Test 3 |
75
+
76
+ Scenario: Using the shorthand form of class names
77
+ When the following query is executed:
78
+ """
79
+ select name
80
+ from CukeModeler::Scenario
81
+ """
82
+ Then the result is the same as the result of the following query:
83
+ """
84
+ select name
85
+ from scenario
86
+ """
87
+ And the result is the same as the result of the following query:
88
+ """
89
+ select name
90
+ from scenarios
91
+ """
92
+
93
+ Scenario: Using the 'from' clause multiple times
94
+
95
+ Note: Selecting from different types of model should be done with care since problems can occur if the attributes specified by the 'select' clause do not exist on all of the models specified by the 'from' clause
96
+
97
+ When the following query is executed:
98
+ """
99
+ select name
100
+ from scenarios
101
+ from outlines
102
+ """
103
+ And the result is the same as the result of the following query:
104
+ """
105
+ select name
106
+ from scenarios, outlines
107
+ """
108
+
109
+ Scenario: Gathering from everything
110
+
111
+ Note: Very few selections will be applicable for all models
112
+
113
+ When the following query is executed:
114
+ """
115
+ select :model
116
+ from :all
117
+ """
118
+ Then all models are queried from
119
+
120
+
121
+ # Commented out so that they aren't picked up by Relish
122
+ # @wip
123
+ # Scenario: Can 'from' from all type of model
124
+ #
125
+ # @wip
126
+ # Scenario: From-ing from a collection
@@ -0,0 +1,117 @@
1
+ Feature: 'select' clause
2
+
3
+ The *select* clause specifies what attributes will be retrieved from the models specified by the *from* clause. Multiple values can be given and they are delimited by a comma. The *select* clause can take any method to which the objects specified by *from* know how to respond. The clause can also be given a special identifier in order to return the underlying models themselves instead of their attributes. If no attributes are specified then the underlying model will be returned instead, just as if the special identifier had been used (it is simply an alternate syntax and may look nicer in some queries).
4
+
5
+ Sample usage:
6
+ cql_repo.query do
7
+ select name, tags, description_text
8
+ from features
9
+ end
10
+
11
+ This clause can be repeated multiple times. The arguments for successive clauses are simply added to the previous arguments.
12
+
13
+
14
+ Background: A sample Cucumber suite
15
+ Given a directory "test_directory"
16
+ And a file "test_directory/test_file_1.feature":
17
+ """
18
+ Feature: A test feature
19
+
20
+ Scenario: Test 1
21
+ * some steps
22
+
23
+ @special_tag
24
+ Scenario: Test 2
25
+ * some other steps
26
+
27
+ Scenario Outline: Test 3
28
+ * some steps
29
+ Examples: First examples
30
+ | param |
31
+ | value |
32
+ Examples: Second examples
33
+ | param |
34
+ | value |
35
+ """
36
+ And a repository is made from "test_directory"
37
+
38
+
39
+ Scenario: Using 'select' to specify which attributes of an object to return
40
+ When the following query is executed:
41
+ """
42
+ select name
43
+ from scenarios
44
+ """
45
+ Then the following values are returned:
46
+ | name |
47
+ | Test 1 |
48
+ | Test 2 |
49
+
50
+ Scenario: Selection of multiple attributes
51
+ When the following query is executed:
52
+ """
53
+ select name, source_line
54
+ from scenarios
55
+ """
56
+ Then the following values are returned:
57
+ | name | source_line |
58
+ | Test 1 | 3 |
59
+ | Test 2 | 7 |
60
+
61
+ Scenario: Selection of the same attribute multiple times
62
+ When the following query is executed:
63
+ """
64
+ select name, name
65
+ from scenarios
66
+ """
67
+ Then the following values are returned:
68
+ | name | name |
69
+ | Test 1 | Test 1 |
70
+ | Test 2 | Test 2 |
71
+
72
+ Scenario: Selection of the underlying models
73
+
74
+ Note: There is no difference between the two different special identifiers. They are merely aliases for each other.
75
+
76
+ When the following query is executed:
77
+ """
78
+ select :self
79
+ from scenarios
80
+ """
81
+ Then the models for the following items are returned:
82
+ | Test 1 |
83
+ | Test 2 |
84
+ And equivalent results are returned for the following query:
85
+ """
86
+ select :model
87
+ from scenarios
88
+ """
89
+
90
+ Scenario: Repetitive selection
91
+ When the following query is executed:
92
+ """
93
+ select name
94
+ select source_line
95
+ from scenarios
96
+ """
97
+ Then the result is the same as the result of the following query:
98
+ """
99
+ select name, source_line
100
+ from scenarios
101
+ """
102
+
103
+ Scenario: Default selection
104
+ When the following query is executed:
105
+ """
106
+ select
107
+ from scenarios
108
+ """
109
+ Then the result is the same as the result of the following query:
110
+ """
111
+ select :self
112
+ from scenarios
113
+ """
114
+
115
+ # Commented out so that they aren't picked up by Relish
116
+ # @wip
117
+ # Scenario: Can select from all types of model
@@ -0,0 +1,153 @@
1
+ Feature: 'transform' clause
2
+
3
+ The *transform* clause allows you to change the values of the attributes specified by the *select* clause after they are gathered. Value transforming can be done as a list of transformation blocks that are applied in order or as a mapping of specific keys and their transformations.
4
+
5
+ Sample usage:
6
+ cql_repo.query do
7
+ select name
8
+ transform { |name| name.upcase }
9
+ from features
10
+ end
11
+
12
+ This will return a list of all of the feature names but with all of their names upcased.
13
+
14
+ This clause can be repeated multiple times. When using lists of transforms, the arguments for successive clauses are simply added to the previous arguments. When using mapped transforms, the mappings are likewise combined. If the same key is mapped more than once, the mappings are tracked separately such that they can be applied to different instances of attribute retrieval (see examples below).
15
+
16
+ Background: A sample Cucumber suite
17
+ Given a directory "test_directory"
18
+ And a file "test_directory/test_file_1.feature":
19
+ """
20
+ Feature: A test feature
21
+
22
+ Scenario: Test 1
23
+ * some steps
24
+
25
+ @special_tag
26
+ Scenario: Test 2
27
+ * some other steps
28
+
29
+ Scenario Outline: Test 3
30
+ * some steps
31
+ Examples: First examples
32
+ | param |
33
+ | value |
34
+ Examples: Second examples
35
+ | param |
36
+ | value |
37
+ """
38
+ And a repository is made from "test_directory"
39
+
40
+
41
+ Scenario: Using 'transform' to change values after they are gathered
42
+ When the following query is executed:
43
+ """
44
+ select name
45
+ transform lambda { |name| name.upcase }
46
+ from scenarios, outlines
47
+ """
48
+ Then the following values are returned:
49
+ | name |
50
+ | TEST 1 |
51
+ | TEST 2 |
52
+ | TEST 3 |
53
+
54
+ Scenario: Single transformation shorthand
55
+ When the following query is executed:
56
+ """
57
+ select name
58
+ transform { |name| name.upcase }
59
+ from scenarios, outlines
60
+ """
61
+ Then the result is the same as the result of the following query:
62
+ """
63
+ select name
64
+ transform lambda { |name| name.upcase }
65
+ from scenarios, outlines
66
+ """
67
+
68
+ Scenario: Transformation of multiple values
69
+ When the following query is executed:
70
+ """
71
+ select name, tags
72
+ transform lambda{ |name| name.upcase },
73
+ lambda{ |tags| 9 }
74
+ from scenarios, outlines
75
+ """
76
+ Then the following values are returned:
77
+ | name | tags |
78
+ | TEST 1 | 9 |
79
+ | TEST 2 | 9 |
80
+ | TEST 3 | 9 |
81
+
82
+ Scenario: Selectively transforming attributes
83
+ When the following query is executed:
84
+ """
85
+ select name, tags
86
+ transform tags => lambda{ |tags| 9 }
87
+ from scenarios, outlines
88
+ """
89
+ Then the following values are returned:
90
+ | name | tags |
91
+ | Test 1 | 9 |
92
+ | Test 2 | 9 |
93
+ | Test 3 | 9 |
94
+
95
+ Scenario: Using the 'transform' clause multiple times
96
+ When the following query is executed:
97
+ """
98
+ select name, tags
99
+ transform { |name| name.upcase }
100
+ transform { |tags| 9 }
101
+ from scenarios, outlines
102
+ """
103
+ Then the result is the same as the result of the following query:
104
+ """
105
+ select name, tags
106
+ transform lambda { |name| name.upcase },
107
+ lambda { |tags| 9 }
108
+ from scenarios, outlines
109
+ """
110
+ When the following query is executed:
111
+ """
112
+ select name, tags
113
+ transform name => lambda { |name| name.upcase }
114
+ transform tags => lambda { |tags| 9 }
115
+ from scenarios, outlines
116
+ """
117
+ Then the result is the same as the result of the following query:
118
+ """
119
+ select name, tags
120
+ transform name => lambda { |name| name.upcase },
121
+ tags => lambda { |tags| 9 }
122
+ from scenarios, outlines
123
+ """
124
+
125
+ Scenario: Transforming duplicate attributes
126
+
127
+ Sometimes you may want to select the same attribute multiple times and perform multiple different transformations on it. This can be done with both set transforming and selective transforming.
128
+
129
+ When the following query is executed:
130
+ """
131
+ select name, tags, name
132
+ transform lambda { |name| name.upcase },
133
+ lambda { |tags| 9 },
134
+ lambda { |name| name.downcase }
135
+ from scenarios, outlines
136
+ """
137
+ Then the following values are returned:
138
+ | name | tags | name |
139
+ | TEST 1 | 9 | test 1 |
140
+ | TEST 2 | 9 | test 2 |
141
+ | TEST 3 | 9 | test 3 |
142
+ When the following query is executed:
143
+ """
144
+ select name, source_line, name
145
+ transform name => lambda { |name| name.upcase }
146
+ transform name => lambda { |name| name.downcase }
147
+ from scenarios, outlines
148
+ """
149
+ Then the following values are returned:
150
+ | name | source_line | name |
151
+ | TEST 1 | 3 | test 1 |
152
+ | TEST 2 | 7 | test 2 |
153
+ | TEST 3 | 10 | test 3 |
@@ -0,0 +1,363 @@
1
+ # todo - Rewrite the scenarios such that they use their own test specific feature files instead of setting up a large suite in the background
2
+ Feature: 'with' clause
3
+
4
+ The *with* clause specifies filter conditions that will reduce the number of things targeted by the *from* clause. The *with* clause can take one or more blocks that will filter out any object for which the block does not evaluate to true (using 'without' instead of 'with' will have the opposite effect). Alternatively, mappings of specific *from* targets to their respective filtering blocks can be provided. The *with* clause can also take predefined filters (detailed below).
5
+
6
+ Sample usage:
7
+ cql_repo.query do
8
+ select name, tags, description_text
9
+ from features
10
+ with { |feature| feature.name =~ /foo/ }
11
+ with tc lt 3
12
+ end
13
+
14
+ This clause can be repeated multiple times. The arguments for successive clauses are simply added to the previous arguments.
15
+
16
+
17
+ The following filters are supported for models that have tags:
18
+
19
+ * tags - Filters out models that do not have the exact set of tags provided.
20
+ * tc - (tag count) Filters out models based on the number of tags that they have.
21
+
22
+ The following filters are supported for models that have names:
23
+
24
+ * name - Filters out models whose name does not match the name provided. Can be a string or regular expression.
25
+
26
+ The following filters are supported for models that have steps:
27
+
28
+ * line - Filters out models whose steps do not include the provided step (keywords and blocks are ignored). Can be a string or regular expression.
29
+ * lc - (line count) Filters out models based on the number of steps that they have.
30
+
31
+ The following filters are supported for feature models:
32
+
33
+ * sc - (scenario count) Filters out models based on the number of scenarios that they have.
34
+ * soc - (scenario outline count) Filters out models based on the number of outlines that they have.
35
+ * ssoc - (scenario and scenario outline count) Filters out models based on the total number of scenarios and outlines that they have.
36
+
37
+ For count based filters, the following operators are available:
38
+
39
+ * lt (Less than)
40
+ * lte (Less than or equals)
41
+ * gt (Greater than)
42
+ * gte (Greater than or equals)
43
+
44
+
45
+ Background: A sample Cucumber suite
46
+ Given a directory "test_directory"
47
+ And a file "test_directory/test_file_1.feature":
48
+ """
49
+ Feature: A test feature
50
+
51
+ @tag_1 @tag_2
52
+ Scenario: Test 1
53
+ * some steps
54
+
55
+ @special_tag @tag_2
56
+ Scenario: Test 2
57
+ * some other steps
58
+
59
+ @a @b @c
60
+ Scenario Outline: Test 3
61
+ * some steps
62
+ * some more steps
63
+ Examples: First examples
64
+ | param |
65
+ | value |
66
+ Examples: Second examples
67
+ | param |
68
+ | value |
69
+ """
70
+ And a file "test_directory/test_file_2.feature":
71
+ """
72
+ Feature: A feature with lots of scenarios
73
+
74
+ Scenario: 1
75
+ * different steps
76
+
77
+ Scenario: 2
78
+ * different steps
79
+
80
+ Scenario: 3
81
+ * different steps
82
+ """
83
+ And a file "test_directory/test_file_3.feature":
84
+ """
85
+ Feature: A feature with lots of outlines
86
+
87
+ Scenario Outline: 1
88
+ * different steps
89
+ Examples:
90
+ | param |
91
+ | value |
92
+
93
+ Scenario Outline: 2
94
+ * different steps
95
+ Examples:
96
+ | param |
97
+ | value |
98
+
99
+ Scenario Outline: 3
100
+ * different steps
101
+ Examples:
102
+ | param |
103
+ | value |
104
+ """
105
+ And a file "test_directory/test_file_4.feature":
106
+ """
107
+ Feature: A feature with a mix of tests
108
+
109
+ Scenario: 4
110
+ * different steps
111
+
112
+ Scenario Outline: 4
113
+ * different steps
114
+ Examples:
115
+ | param |
116
+ | value |
117
+ """
118
+ And a repository is made from "test_directory"
119
+
120
+
121
+ Scenario: Using 'with' to limit the objects from which to return attributes
122
+ When the following query is executed:
123
+ """
124
+ select name
125
+ from scenarios
126
+ with lambda { |scenario| scenario.source_line == 8 }
127
+ """
128
+ Then the following values are returned:
129
+ | name |
130
+ | Test 2 |
131
+
132
+ Scenario: Single filter shorthand
133
+ When the following query is executed:
134
+ """
135
+ select name
136
+ from scenarios
137
+ with { |scenario| scenario.tags.include?('@special_tag') }
138
+ """
139
+ Then the result is the same as the result of the following query:
140
+ """
141
+ select name
142
+ from scenarios
143
+ with lambda { |scenario| scenario.tags.include?('@special_tag') }
144
+ """
145
+
146
+ Scenario: Using multiple filters
147
+ When the following query is executed:
148
+ """
149
+ select name
150
+ from scenarios, outlines, examples
151
+ with lambda { |element| element.is_a?(CukeModeler::Example) },
152
+ lambda { |element| element.name =~ /Second/ }
153
+ """
154
+ Then the following values are returned:
155
+ | name |
156
+ | Second examples |
157
+
158
+ Scenario: Selectively filtering models
159
+ When the following query is executed:
160
+ """
161
+ select name
162
+ from features, scenarios
163
+ with scenarios => tags('@tag_1','@tag_2')
164
+ """
165
+ Then the following values are returned:
166
+ | name |
167
+ | A test feature |
168
+ | A feature with lots of scenarios |
169
+ | A feature with lots of outlines |
170
+ | A feature with a mix of tests |
171
+ | Test 1 |
172
+
173
+ Scenario: Using the 'with' clause multiple times
174
+ When the following query is executed:
175
+ """
176
+ select name
177
+ from scenarios, outlines, examples
178
+ with { |element| element.is_a?(CukeModeler::Example) }
179
+ with { |element| element.name =~ /Second/ }
180
+ """
181
+ Then the result is the same as the result of the following query:
182
+ """
183
+ select name
184
+ from scenarios, outlines, examples
185
+ with lambda { |element| element.is_a?(CukeModeler::Example) },
186
+ lambda { |element| element.name =~ /Second/ }
187
+ """
188
+ When the following query is executed:
189
+ """
190
+ select name
191
+ from features, scenarios
192
+ with scenarios => lambda { |scenario| scenario.tags.include?('@tag_1') }
193
+ with scenarios => lambda { |scenario| scenario.tags.include?('@tag_2') }
194
+ """
195
+ Then the result is the same as the result of the following query:
196
+ """
197
+ select name
198
+ from features, scenarios
199
+ with({ scenarios => lambda { |scenario| scenario.tags.include?('@tag_1') }},
200
+ { scenarios => lambda { |scenario| scenario.tags.include?('@tag_2') }})
201
+ """
202
+
203
+ Scenario: Mixing targeted and blanket filters
204
+ When the following query is executed:
205
+ """
206
+ select name
207
+ from examples, features
208
+ with { |element| element.name != '' }
209
+ with features => lambda { |feature| feature.name =~ /lots/ }
210
+ """
211
+ Then the following values are returned:
212
+ | name |
213
+ | First examples |
214
+ | Second examples |
215
+ | A feature with lots of scenarios |
216
+ | A feature with lots of outlines |
217
+
218
+ # todo - break out the predefined filters into another feature file?
219
+ Scenario: Filtering by tags
220
+ When the following query is executed:
221
+ """
222
+ select name
223
+ from scenarios
224
+ with tags '@tag_1', '@tag_2'
225
+ """
226
+ Then the following values are returned:
227
+ | name |
228
+ | Test 1 |
229
+
230
+ Scenario: Filtering by tag count
231
+ When the following query is executed:
232
+ """
233
+ select name
234
+ from scenarios, outlines
235
+ with tc gt 2
236
+ """
237
+ Then the following values are returned:
238
+ | name |
239
+ | Test 3 |
240
+
241
+ Scenario: Filtering by name
242
+ When the following query is executed:
243
+ """
244
+ select name
245
+ from scenarios, outlines
246
+ with name 'Test 3'
247
+ """
248
+ Then the following values are returned:
249
+ | name |
250
+ | Test 3 |
251
+ When the following query is executed:
252
+ """
253
+ select name
254
+ from scenarios, outlines
255
+ with name /Test [12]/
256
+ """
257
+ Then the following values are returned:
258
+ | name |
259
+ | Test 1 |
260
+ | Test 2 |
261
+
262
+ Scenario: Filtering by line
263
+ When the following query is executed:
264
+ """
265
+ select name
266
+ from scenarios, outlines
267
+ with line 'some steps'
268
+ """
269
+ Then the following values are returned:
270
+ | name |
271
+ | Test 1 |
272
+ | Test 3 |
273
+ When the following query is executed:
274
+ """
275
+ select name
276
+ from scenarios, outlines
277
+ with line /other/
278
+ """
279
+ Then the following values are returned:
280
+ | name |
281
+ | Test 2 |
282
+
283
+ Scenario: Filtering by line count
284
+ When the following query is executed:
285
+ """
286
+ select name
287
+ from scenarios, outlines
288
+ with lc gt 1
289
+ """
290
+ Then the following values are returned:
291
+ | name |
292
+ | Test 3 |
293
+
294
+ Scenario: Filtering by scenario count
295
+ When the following query is executed:
296
+ """
297
+ select name
298
+ from features
299
+ with sc gt 2
300
+ """
301
+ Then the following values are returned:
302
+ | name |
303
+ | A feature with lots of scenarios |
304
+
305
+ Scenario: Filtering by outline count
306
+ When the following query is executed:
307
+ """
308
+ select name
309
+ from features
310
+ with soc gt 2
311
+ """
312
+ Then the following values are returned:
313
+ | name |
314
+ | A feature with lots of outlines |
315
+
316
+ Scenario: Filtering by combined test count
317
+ When the following query is executed:
318
+ """
319
+ select name
320
+ from features
321
+ with ssoc lt 3
322
+ """
323
+ Then the following values are returned:
324
+ | name |
325
+ | A feature with a mix of tests |
326
+
327
+ @wip
328
+ Scenario: Using the 'lt' count filter
329
+
330
+ @wip
331
+ Scenario: Using the 'lte' count filter
332
+
333
+ @wip
334
+ Scenario: Using the 'gt' count filter
335
+
336
+ @wip
337
+ Scenario: Using the 'gte' count filter
338
+
339
+ Scenario: Using 'without' for negation
340
+ When the following query is executed:
341
+ """
342
+ select name
343
+ from scenarios
344
+ without { |scenario| scenario.source_line == 8 }
345
+ """
346
+ Then the result is the same as the result of the following query:
347
+ """
348
+ select name
349
+ from scenarios
350
+ with { |scenario| !(scenario.source_line == 8) }
351
+ """
352
+ When the following query is executed:
353
+ """
354
+ select name
355
+ from features
356
+ without ssoc lt 3
357
+ """
358
+ Then the result is the same as the result of the following query:
359
+ """
360
+ select name
361
+ from features
362
+ with ssoc gt 2
363
+ """