cql 1.2.1 → 1.3.0
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.
- checksums.yaml +4 -4
- data/lib/cql.rb +18 -11
- data/lib/cql/dsl.rb +14 -2
- data/lib/cql/filters.rb +12 -6
- data/lib/cql/map_reduce.rb +29 -11
- data/lib/cql/model_dsl.rb +18 -0
- data/lib/cql/queriable.rb +14 -0
- data/lib/cql/sso_filters.rb +3 -2
- data/lib/cql/version.rb +1 -1
- data/testing/cql_test_model.rb +42 -0
- data/testing/cucumber/features/clauses/as_clause.feature +136 -0
- data/testing/cucumber/features/clauses/from_clause.feature +126 -0
- data/testing/cucumber/features/clauses/select_clause.feature +117 -0
- data/testing/cucumber/features/clauses/transform_clause.feature +153 -0
- data/testing/cucumber/features/clauses/with_clause.feature +363 -0
- data/testing/cucumber/features/dsl.feature +77 -0
- data/testing/cucumber/features/model_querying.feature +18 -0
- data/testing/cucumber/features/repository.feature +23 -0
- data/testing/cucumber/step_definitions/query_steps.rb +7 -0
- data/testing/cucumber/step_definitions/setup_steps.rb +25 -0
- data/testing/cucumber/step_definitions/verification_steps.rb +78 -0
- data/testing/cucumber/support/env.rb +24 -0
- data/testing/cucumber/support/transforms.rb +3 -0
- data/testing/fixtures/features/combined/a/f1_4_scenarios_5_so.feature +59 -0
- data/testing/fixtures/features/combined/a/f2_7_scenarios_2_so.feature +43 -0
- data/testing/fixtures/features/combined/a/f3_2_scenarios_3_so.feature +30 -0
- data/testing/fixtures/features/combined/b/f1_1_tag.feature +6 -0
- data/testing/fixtures/features/combined/b/f2_2_tags.feature +6 -0
- data/testing/fixtures/features/combined/b/f3_3_tags.feature +6 -0
- data/testing/fixtures/features/examples/basic/test_with_scenarios.feature +15 -0
- data/testing/fixtures/features/examples/filters/tag_count/simple.feature +21 -0
- data/testing/fixtures/features/examples/filters/tag_count/simple2.feature +21 -0
- data/testing/fixtures/features/examples/filters/tags/simple.feature +34 -0
- data/testing/fixtures/features/examples/filters/tags2/simple.feature +34 -0
- data/testing/fixtures/features/examples/filters/tags2/simple2.feature +34 -0
- data/testing/fixtures/features/examples/multiple_examples/test_with_scenarios.feature +43 -0
- data/testing/fixtures/features/examples/name_filter/name.feature +19 -0
- data/testing/fixtures/features/got/Lannisters.feature +24 -0
- data/testing/fixtures/features/got/Starks.feature +18 -0
- data/testing/fixtures/features/scen_outlines/basic/test_with_scenarios.feature +15 -0
- data/testing/fixtures/features/scen_outlines/filters/tag_count/simple.feature +21 -0
- data/testing/fixtures/features/scen_outlines/filters/tag_count/simple2.feature +21 -0
- data/testing/fixtures/features/scen_outlines/filters/tags/simple.feature +34 -0
- data/testing/fixtures/features/scen_outlines/filters/tags2/simple.feature +34 -0
- data/testing/fixtures/features/scen_outlines/filters/tags2/simple2.feature +34 -0
- data/testing/fixtures/features/scen_outlines/line_count/simple.feature +12 -0
- data/testing/fixtures/features/scen_outlines/line_count/simple2.feature +16 -0
- data/testing/fixtures/features/scen_outlines/line_filter/ll.feature +13 -0
- data/testing/fixtures/features/scen_outlines/multiple_examples/test_with_scenarios.feature +43 -0
- data/testing/fixtures/features/scen_outlines/name_filter/name.feature +19 -0
- data/testing/fixtures/features/scenario/line_count/simple.feature +9 -0
- data/testing/fixtures/features/scenario/line_count/simple2.feature +12 -0
- data/testing/fixtures/features/scenario/line_filter/ll.feature +9 -0
- data/testing/fixtures/features/scenario/name_filter/name.feature +13 -0
- data/testing/fixtures/features/scenario/simple/simple.feature +8 -0
- data/testing/fixtures/features/scenario/simple/test.feature +9 -0
- data/testing/fixtures/features/scenario/simple/test2.feature +5 -0
- data/testing/fixtures/features/scenario/simple/test_full.feature +22 -0
- data/testing/fixtures/features/scenario/simple2/test_full.feature +23 -0
- data/testing/fixtures/features/scenario/table/simple.feature +11 -0
- data/testing/fixtures/features/scenario/tag_count/simple.feature +17 -0
- data/testing/fixtures/features/scenario/tag_count/simple2.feature +17 -0
- data/testing/fixtures/features/scenario/tagged_features/simple.feature +8 -0
- data/testing/fixtures/features/scenario/tagged_features/test.feature +10 -0
- data/testing/fixtures/features/scenario/tagged_features/test2.feature +6 -0
- data/testing/fixtures/features/scenario/tagged_features/test_full.feature +22 -0
- data/testing/fixtures/features/scenario/tags/simple.feature +24 -0
- data/testing/fixtures/features/scenario/tags2/simple.feature +24 -0
- data/testing/fixtures/features/scenario/tags2/simple2.feature +24 -0
- data/testing/fixtures/features/scenario/tags3/simple.feature +21 -0
- data/testing/gemfiles/cuke_modeler0.gemfile +30 -0
- data/testing/gemfiles/cuke_modeler1.gemfile +30 -0
- data/testing/rspec/spec/dsl_spec.rb +600 -0
- data/testing/rspec/spec/filter_example_spec.rb +65 -0
- data/testing/rspec/spec/filter_feature_dsl_spec.rb +286 -0
- data/testing/rspec/spec/filter_sso_spec.rb +202 -0
- data/testing/rspec/spec/line_count_filterable_specs.rb +74 -0
- data/testing/rspec/spec/line_filterable_specs.rb +52 -0
- data/testing/rspec/spec/map_reduce_spec.rb +135 -0
- data/testing/rspec/spec/model_query_spec.rb +49 -0
- data/testing/rspec/spec/multiple_queries_spec.rb +24 -0
- data/testing/rspec/spec/name_filterable_specs.rb +52 -0
- data/testing/rspec/spec/queriable_specs.rb +45 -0
- data/testing/rspec/spec/repository_spec.rb +82 -0
- data/testing/rspec/spec/select_feature_dsl_spec.rb +114 -0
- data/testing/rspec/spec/select_scen_outline_dsl_spec.rb +234 -0
- data/testing/rspec/spec/select_scenario_dsl_spec.rb +132 -0
- data/testing/rspec/spec/spec_helper.rb +42 -0
- data/testing/rspec/spec/tag_filterable_specs.rb +107 -0
- metadata +170 -5
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/spec_helper"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
shared_examples_for 'a line count filterable target set' do |target_type, test_data|
|
|
5
|
+
|
|
6
|
+
describe 'line count filters' do
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
it "should filter based on 'lc lt'" do
|
|
10
|
+
gs = CQL::Repository.new(test_data[:lc_lt][:fixture_location])
|
|
11
|
+
|
|
12
|
+
expected_results = test_data[:lc_lt][:expected_results]
|
|
13
|
+
|
|
14
|
+
expected_results.each do |number, expected|
|
|
15
|
+
result = gs.query do
|
|
16
|
+
select name
|
|
17
|
+
from target_type
|
|
18
|
+
with lc lt number
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
expect(result).to match_array(expected)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should filter based on 'lc_lte'" do
|
|
26
|
+
gs = CQL::Repository.new(test_data[:lc_lte][:fixture_location])
|
|
27
|
+
|
|
28
|
+
expected_results = test_data[:lc_lte][:expected_results]
|
|
29
|
+
|
|
30
|
+
expected_results.each do |number, expected|
|
|
31
|
+
result = gs.query do
|
|
32
|
+
select name
|
|
33
|
+
from target_type
|
|
34
|
+
with lc lte number
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
expect(result).to match_array(expected)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should filter based on 'lc_gt'" do
|
|
42
|
+
gs = CQL::Repository.new(test_data[:lc_gt][:fixture_location])
|
|
43
|
+
|
|
44
|
+
expected_results = test_data[:lc_gt][:expected_results]
|
|
45
|
+
|
|
46
|
+
expected_results.each do |number, expected|
|
|
47
|
+
result = gs.query do
|
|
48
|
+
select name
|
|
49
|
+
from target_type
|
|
50
|
+
with lc gt number
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
expect(result).to match_array(expected)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should filter based on 'lc_gte'" do
|
|
58
|
+
gs = CQL::Repository.new(test_data[:lc_gte][:fixture_location])
|
|
59
|
+
|
|
60
|
+
expected_results = test_data[:lc_gte][:expected_results]
|
|
61
|
+
|
|
62
|
+
expected_results.each do |number, expected|
|
|
63
|
+
result = gs.query do
|
|
64
|
+
select name
|
|
65
|
+
from target_type
|
|
66
|
+
with lc gte number
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
expect(result).to match_array(expected)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/spec_helper"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
shared_examples_for 'a line filterable target set' do |target_type, test_data|
|
|
5
|
+
|
|
6
|
+
describe 'line match filters' do
|
|
7
|
+
|
|
8
|
+
it 'should filter by exact line' do
|
|
9
|
+
gs = CQL::Repository.new(test_data[:exact_line][:fixture_location])
|
|
10
|
+
|
|
11
|
+
expected_results = test_data[:exact_line][:expected_results]
|
|
12
|
+
|
|
13
|
+
expected_results.each do |matched_line, expected|
|
|
14
|
+
result = gs.query do
|
|
15
|
+
select name
|
|
16
|
+
from target_type
|
|
17
|
+
with line matched_line
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
expect(result).to eq(expected)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'should filter by regexp' do
|
|
25
|
+
gs = CQL::Repository.new(test_data[:regexp][:fixture_location])
|
|
26
|
+
|
|
27
|
+
expected_results = test_data[:regexp][:expected_results]
|
|
28
|
+
|
|
29
|
+
expected_results.each do |matched_line, expected|
|
|
30
|
+
result = gs.query do
|
|
31
|
+
select name
|
|
32
|
+
from target_type
|
|
33
|
+
with line matched_line
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
expect(result).to eq(expected)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'can only handle a string or regular expression' do
|
|
41
|
+
gs = CQL::Repository.new(@feature_fixtures_directory)
|
|
42
|
+
|
|
43
|
+
expect { gs.query do
|
|
44
|
+
select name
|
|
45
|
+
from scenarios
|
|
46
|
+
with line 7
|
|
47
|
+
end }.to raise_error(ArgumentError, "Can only match a String or Regexp. Got Fixnum.")
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/spec_helper"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe "cql" do
|
|
5
|
+
|
|
6
|
+
# describe "file parsing" do
|
|
7
|
+
# it 'should find the physical files' do
|
|
8
|
+
# skip("This is possibly no longer be needed")
|
|
9
|
+
#
|
|
10
|
+
# gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
|
|
11
|
+
# result = CQL::MapReduce.uri(gs.parsed_feature_files)
|
|
12
|
+
#
|
|
13
|
+
# expect(result[0]).to match(/simple\.feature/)
|
|
14
|
+
# expect(result[1]).to match(/test\.feature/)
|
|
15
|
+
# expect(result[2]).to match(/test2\.feature/)
|
|
16
|
+
# expect(result[3]).to match(/test_full\.feature/)
|
|
17
|
+
# end
|
|
18
|
+
# end
|
|
19
|
+
|
|
20
|
+
#it 'should filter by count functions' do
|
|
21
|
+
# input = [{"keyword"=>"Feature", "name"=>"f1_4_scenarios_5_so", "line"=>1, "description"=>"", "id"=>"f1-4-scenarios-5-so", "uri"=>"C:/Users/jarrod/dev/gql/spec/../fixtures/features/combined/a/f1_4_scenarios_5_so.feature", "elements"=>[{"keyword"=>"Scenario", "name"=>"f1_scen1", "line"=>3, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen1", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4}, {"keyword"=>"Then ", "name"=>"something else", "line"=>5}]}, {"keyword"=>"Scenario", "name"=>"f1_scen2", "line"=>7, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen2", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>8}, {"keyword"=>"Then ", "name"=>"something else", "line"=>9}]}, {"keyword"=>"Scenario", "name"=>"f1_scen3", "line"=>11, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen3", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>12}, {"keyword"=>"Then ", "name"=>"something else", "line"=>13}]}, {"keyword"=>"Scenario", "name"=>"f1_scen4", "line"=>15, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen4", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>16}, {"keyword"=>"Then ", "name"=>"something else", "line"=>17}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so1", "line"=>19, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so1", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>20}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>22, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so1;", "rows"=>[{"cells"=>["e"], "line"=>23, "id"=>"f1-4-scenarios-5-so;f1-so1;;1"}, {"cells"=>["r"], "line"=>24, "id"=>"f1-4-scenarios-5-so;f1-so1;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so2", "line"=>26, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so2", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>27}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>29, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so2;", "rows"=>[{"cells"=>["e"], "line"=>30, "id"=>"f1-4-scenarios-5-so;f1-so2;;1"}, {"cells"=>["r"], "line"=>31, "id"=>"f1-4-scenarios-5-so;f1-so2;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so3", "line"=>33, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so3", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>34}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>36, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so3;", "rows"=>[{"cells"=>["e"], "line"=>37, "id"=>"f1-4-scenarios-5-so;f1-so3;;1"}, {"cells"=>["r"], "line"=>38, "id"=>"f1-4-scenarios-5-so;f1-so3;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so4", "line"=>40, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so4", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>41}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>43, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so4;", "rows"=>[{"cells"=>["e"], "line"=>44, "id"=>"f1-4-scenarios-5-so;f1-so4;;1"}, {"cells"=>["r"], "line"=>45, "id"=>"f1-4-scenarios-5-so;f1-so4;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so5", "line"=>47, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so5", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>48}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>50, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so5;", "rows"=>[{"cells"=>["e"], "line"=>51, "id"=>"f1-4-scenarios-5-so;f1-so5;;1"}, {"cells"=>["r"], "line"=>52, "id"=>"f1-4-scenarios-5-so;f1-so5;;2"}]}]}]},
|
|
22
|
+
# {"keyword"=>"Feature", "name"=>"f2_7_scenarios_2_so", "line"=>1, "description"=>"", "id"=>"f2-7-scenarios-2-so", "uri"=>"C:/Users/jarrod/dev/gql/spec/../fixtures/features/combined/a/f2_7_scenarios_2_so.feature", "elements"=>[{"keyword"=>"Scenario", "name"=>"f2_scen1", "line"=>3, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen1", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4}, {"keyword"=>"Then ", "name"=>"something else", "line"=>5}]}, {"keyword"=>"Scenario", "name"=>"f2_scen2", "line"=>7, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen2", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>8}, {"keyword"=>"Then ", "name"=>"something else", "line"=>9}]}, {"keyword"=>"Scenario", "name"=>"f2_scen3", "line"=>11, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen3", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>12}, {"keyword"=>"Then ", "name"=>"something else", "line"=>13}]}, {"keyword"=>"Scenario", "name"=>"f2_scen4", "line"=>15, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen4", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>16}, {"keyword"=>"Then ", "name"=>"something else", "line"=>17}]}, {"keyword"=>"Scenario", "name"=>"f2_scen5", "line"=>19, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen5", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>20}, {"keyword"=>"Then ", "name"=>"something else", "line"=>21}]}, {"keyword"=>"Scenario", "name"=>"f2_scen6", "line"=>23, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen6", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>24}, {"keyword"=>"Then ", "name"=>"something else", "line"=>25}]}, {"keyword"=>"Scenario", "name"=>"f2_scen7", "line"=>27, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen7", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>28}, {"keyword"=>"Then ", "name"=>"something else", "line"=>29}]}, {"keyword"=>"Scenario Outline", "name"=>"f2_so1", "line"=>31, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so1", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>32}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>34, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so1;", "rows"=>[{"cells"=>["e"], "line"=>35, "id"=>"f2-7-scenarios-2-so;f2-so1;;1"}, {"cells"=>["r"], "line"=>36, "id"=>"f2-7-scenarios-2-so;f2-so1;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f2_so2", "line"=>38, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so2", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>39}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>41, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so2;", "rows"=>[{"cells"=>["e"], "line"=>42, "id"=>"f2-7-scenarios-2-so;f2-so2;;1"}, {"cells"=>["r"], "line"=>43}]}]}]},
|
|
23
|
+
# {"keyword"=>"Feature", "name"=>"f3_2_scenarios_3_so", "line"=>1, "description"=>"", "id"=>"f3-2-scenarios-3-so", "uri"=>"C:/Users/jarrod/dev/gql/spec/../fixtures/features/combined/a/f3_2_scenarios_3_so.feature", "elements"=>[{"keyword"=>"Scenario", "name"=>"f3_scen1", "line"=>3, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-scen1", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4}, {"keyword"=>"Then ", "name"=>"something else", "line"=>5}]}, {"keyword"=>"Scenario", "name"=>"f3_scen2", "line"=>7, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-scen2", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>8}, {"keyword"=>"Then ", "name"=>"something else", "line"=>9}]}, {"keyword"=>"Scenario", "name"=>"f3_scen3", "line"=>11, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-scen3", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>12}, {"keyword"=>"Then ", "name"=>"something else", "line"=>13}]}, {"keyword"=>"Scenario Outline", "name"=>"f3_so1", "line"=>15, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so1", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>16}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>18, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so1;", "rows"=>[{"cells"=>["e"], "line"=>19, "id"=>"f3-2-scenarios-3-so;f3-so1;;1"}, {"cells"=>["r"], "line"=>20, "id"=>"f3-2-scenarios-3-so;f3-so1;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f3_so2", "line"=>22, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so2", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>23}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>25, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so2;", "rows"=>[{"cells"=>["e"], "line"=>26, "id"=>"f3-2-scenarios-3-so;f3-so2;;1"}, {"cells"=>["r"], "line"=>27, "id"=>"f3-2-scenarios-3-so;f3-so2;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f3_so3", "line"=>29, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so3", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>30}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>32, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so3;", "rows"=>[{"cells"=>["e"], "line"=>33, "id"=>"f3-2-scenarios-3-so;f3-so3;;1"}, {"cells"=>["r"], "line"=>34, "id"=>"f3-2-scenarios-3-so;f3-so3;;2"}]}]}]}]
|
|
24
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>2})
|
|
25
|
+
# result.size.should == 3
|
|
26
|
+
#
|
|
27
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>0})
|
|
28
|
+
# result.size.should == 3
|
|
29
|
+
#
|
|
30
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>3})
|
|
31
|
+
# result.size.should == 2
|
|
32
|
+
#
|
|
33
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>7})
|
|
34
|
+
# result.size.should == 0
|
|
35
|
+
#
|
|
36
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>4})
|
|
37
|
+
# result.size.should == 1
|
|
38
|
+
#end
|
|
39
|
+
|
|
40
|
+
describe 'filter by tag count' do
|
|
41
|
+
#it 'should filter by tag count' do
|
|
42
|
+
# input = [
|
|
43
|
+
# {"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
|
44
|
+
# "elements"=>[
|
|
45
|
+
# {"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
|
46
|
+
# {"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
|
47
|
+
# {"keyword"=>"Feature", "name"=>"Simple2", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[
|
|
48
|
+
# {"keyword"=>"Scenario", "name"=>"3 tags", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}, {"name"=>"@two", "line"=>3}, {"name"=>"@three", "line"=>3}], "id"=>"simple;3-tags", "type"=>"scenario"},
|
|
49
|
+
# {"keyword"=>"Scenario", "name"=>"4 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}, {"name"=>"@three", "line"=>11}, {"name"=>"@four", "line"=>11}], "id"=>"simple;4-tags", "type"=>"scenario", }]}
|
|
50
|
+
# ]
|
|
51
|
+
#
|
|
52
|
+
# expected = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
|
53
|
+
# "elements"=>[
|
|
54
|
+
# {"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
|
55
|
+
# {"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
|
56
|
+
# {"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[]}]
|
|
57
|
+
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).size.should == expected.size
|
|
58
|
+
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).first['elements'].size.should == expected.first['elements'].size
|
|
59
|
+
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3})[1]['elements'].size.should == expected[1]['elements'].size
|
|
60
|
+
#
|
|
61
|
+
#end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
#describe "tags" do
|
|
65
|
+
# it "retrieve tags from a scenario" do
|
|
66
|
+
# gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tags2"
|
|
67
|
+
# CQL::MapReduce.tag_set(gs.parsed_feature_files).sort.should == ["@five", "@four", "@one", "@two"].sort
|
|
68
|
+
# end
|
|
69
|
+
#
|
|
70
|
+
# it 'should filter features by tag' do
|
|
71
|
+
# input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"simple", "uri"=>"/a/a"},
|
|
72
|
+
# {"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
|
73
|
+
# {"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>1, "description"=>"", "id"=>"test2-feature"},
|
|
74
|
+
# {"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test3-feature"}]
|
|
75
|
+
# result = CQL::MapReduce.filter_features(input, 'tags'=>['@one'])
|
|
76
|
+
# result.size.should == 2
|
|
77
|
+
# result[0]['name'].should == "Test Feature"
|
|
78
|
+
# result[1]['name'].should == "Test3 Feature"
|
|
79
|
+
# end
|
|
80
|
+
#
|
|
81
|
+
# it 'should filter by multiple tags' do
|
|
82
|
+
# input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple"},
|
|
83
|
+
# {"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
|
84
|
+
# {"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"test2-feature"},
|
|
85
|
+
# {"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}, {"name"=>"@two", "line"=>1}], "id"=>"test3-feature"}]
|
|
86
|
+
# result = CQL::MapReduce.filter_features(input, 'tags'=>['@one', '@two'])
|
|
87
|
+
# result.should == [{"keyword"=>"Feature", "name"=>"Test3 Feature",
|
|
88
|
+
# "line"=>2, "description"=>"",
|
|
89
|
+
# "tags"=>[{"name"=>"@one", "line"=>1},
|
|
90
|
+
# {"name"=>"@two", "line"=>1}],
|
|
91
|
+
# "id"=>"test3-feature"}]
|
|
92
|
+
# end
|
|
93
|
+
#end
|
|
94
|
+
|
|
95
|
+
describe 'features query' do
|
|
96
|
+
#it 'should find all feature names' do
|
|
97
|
+
# gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
|
98
|
+
# CQL::MapReduce.name(gs.parsed_feature_files).should eql ["Simple", "Test Feature", "Test2 Feature", "Test3 Feature"]
|
|
99
|
+
#end
|
|
100
|
+
|
|
101
|
+
#it 'should retrieve a full feature' do
|
|
102
|
+
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple"
|
|
103
|
+
# result = CQL::MapReduce.filter_features(gs.parsed_feature_files, {'feature'=>["Test Feature"]})
|
|
104
|
+
# result[0]['name'].should == "Test Feature"
|
|
105
|
+
# result[0]['elements'][0]['name'].should == "Testing the slurping 1"
|
|
106
|
+
# result[0]['elements'].should == [{"keyword"=>"Scenario", "name"=>"Testing the slurping 1", "line"=>3,
|
|
107
|
+
# "description"=>"", "id"=>"test-feature;testing-the-slurping-1", "type"=>"scenario",
|
|
108
|
+
# "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
|
|
109
|
+
# {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}]},
|
|
110
|
+
# {"keyword"=>"Scenario", "name"=>"Testing the slurping not to be found", "line"=>7,
|
|
111
|
+
# "description"=>"", "id"=>"test-feature;testing-the-slurping-not-to-be-found", "type"=>"scenario",
|
|
112
|
+
# "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>8}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>9}]}]
|
|
113
|
+
#end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
#describe 'scenario query' do
|
|
117
|
+
# it 'should get all scenarios as a list' do
|
|
118
|
+
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
|
119
|
+
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=>'scenario'})
|
|
120
|
+
# result.should == [{"keyword"=>"Scenario", "name"=>"A Scenario", "line"=>13, "description"=>"", "id"=>"test-feature;a-scenario", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>14}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>15}]}]
|
|
121
|
+
# end
|
|
122
|
+
#end
|
|
123
|
+
#
|
|
124
|
+
#describe 'scenario outline query' do
|
|
125
|
+
# it 'should get scenario outlines as a list' do
|
|
126
|
+
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
|
127
|
+
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=> 'scenario'})
|
|
128
|
+
# result.should == [{"keyword"=>"Scenario", "name"=>"A Scenario", "line"=>13, "description"=>"", "id"=>"test-feature;a-scenario", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>14}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>15}]}]
|
|
129
|
+
#
|
|
130
|
+
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=> ["Test Feature"], 'what'=> 'scenario_outline'})
|
|
131
|
+
# result.should == [{"keyword"=>"Scenario Outline", "name"=>"An Outline", "line"=>3, "description"=>"", "id"=>"test-feature;an-outline", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>6, "description"=>"", "id"=>"test-feature;an-outline;", "rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;;1"}, {"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;;2"}, {"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;;3"}, {"cells"=>["3", "c"], "line"=>10, "id"=>"test-feature;an-outline;;4"}, {"cells"=>["4", "d"], "line"=>11, "id"=>"test-feature;an-outline;;5"}]}]}]
|
|
132
|
+
# end
|
|
133
|
+
#end
|
|
134
|
+
|
|
135
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/spec_helper"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe 'a query enhanced model', :cuke_modeler_1x => true do
|
|
5
|
+
|
|
6
|
+
let(:clazz) { CukeModeler::Model }
|
|
7
|
+
let(:model) { clazz.new }
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
describe 'common behavior' do
|
|
11
|
+
|
|
12
|
+
it_should_behave_like 'a queriable object'
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
it 'can be queried' do
|
|
18
|
+
expect(model).to respond_to(:query)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'correctly queries itself' do
|
|
22
|
+
model.parent_model = :foo
|
|
23
|
+
|
|
24
|
+
result = model.query do
|
|
25
|
+
select parent_model
|
|
26
|
+
from models
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
expect(result).to eq([{'parent_model' => :foo}])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
describe 'some white box testing for extra safety' do
|
|
34
|
+
|
|
35
|
+
# Need to make sure that a common module is used instead of duplicating code so
|
|
36
|
+
# that duplicate testing is not likewise needed.
|
|
37
|
+
it 'uses the same DSL module as a regular repository' do
|
|
38
|
+
expect(model).to be_a_kind_of(CQL::Queriable)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Need to make sure that the needed #initialize patching does not break the normal
|
|
42
|
+
# behavior of the class.
|
|
43
|
+
it 'still initializes normally' do
|
|
44
|
+
expect { clazz.new(:not_a_string) }.to raise_error(ArgumentError, 'Can only create models from Strings but was given a Symbol.')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/spec_helper"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe "cql" do
|
|
5
|
+
|
|
6
|
+
describe 'repo' do
|
|
7
|
+
it 'should not change between queries' do
|
|
8
|
+
|
|
9
|
+
repo = CQL::Repository.new("#{@feature_fixtures_directory}/got")
|
|
10
|
+
|
|
11
|
+
before_dump = Marshal.dump(repo)
|
|
12
|
+
|
|
13
|
+
repo.query do
|
|
14
|
+
select name
|
|
15
|
+
from scenarios
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
after_dump = Marshal.dump(repo)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
expect(before_dump).to eq(after_dump)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/spec_helper"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
shared_examples_for 'a name filterable target set' do |target_type, test_data|
|
|
5
|
+
|
|
6
|
+
describe 'name filters' do
|
|
7
|
+
|
|
8
|
+
it 'should filter by exact name' do
|
|
9
|
+
gs = CQL::Repository.new(test_data[:exact_name][:fixture_location])
|
|
10
|
+
|
|
11
|
+
expected_results = test_data[:exact_name][:expected_results]
|
|
12
|
+
|
|
13
|
+
expected_results.each do |matched_name, expected|
|
|
14
|
+
result = gs.query do
|
|
15
|
+
select name
|
|
16
|
+
from target_type
|
|
17
|
+
with name matched_name
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
expect(result).to eq(expected)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'should filter by regexp' do
|
|
25
|
+
gs = CQL::Repository.new(test_data[:regexp][:fixture_location])
|
|
26
|
+
|
|
27
|
+
expected_results = test_data[:regexp][:expected_results]
|
|
28
|
+
|
|
29
|
+
expected_results.each do |matched_name, expected|
|
|
30
|
+
result = gs.query do
|
|
31
|
+
select name
|
|
32
|
+
from target_type
|
|
33
|
+
with name matched_name
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
expect(result).to match_array(expected)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'can only handle a string or regular expression' do
|
|
41
|
+
gs = CQL::Repository.new(@feature_fixtures_directory)
|
|
42
|
+
|
|
43
|
+
expect { gs.query do
|
|
44
|
+
select name
|
|
45
|
+
from scenarios
|
|
46
|
+
with name 7
|
|
47
|
+
end }.to raise_error(ArgumentError, "Can only match a String or Regexp. Got Fixnum.")
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/spec_helper"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
shared_examples_for 'a queriable object' do
|
|
5
|
+
|
|
6
|
+
# clazz and seed_arguments must be defined by the calling file
|
|
7
|
+
|
|
8
|
+
let(:object) { (defined? seed_arguments) ? clazz.new(seed_arguments) : clazz.new }
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
it 'has a query root' do
|
|
12
|
+
expect(object).to respond_to(:query_root)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'can change its query root' do
|
|
16
|
+
expect(object).to respond_to(:query_root=)
|
|
17
|
+
|
|
18
|
+
object.query_root = :some_query_root
|
|
19
|
+
expect(object.query_root).to eq(:some_query_root)
|
|
20
|
+
object.query_root = :some_other_query_root
|
|
21
|
+
expect(object.query_root).to eq(:some_other_query_root)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'can be queried' do
|
|
25
|
+
expect(object).to respond_to(:query)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'complains if a query is attempted without a query root being set' do
|
|
29
|
+
object.query_root = nil
|
|
30
|
+
|
|
31
|
+
expect {
|
|
32
|
+
|
|
33
|
+
object.query do
|
|
34
|
+
select :model
|
|
35
|
+
from :all
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
}.to raise_error(ArgumentError, 'Query cannot be run. No query root has been set.')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'starts with a query root' do
|
|
42
|
+
expect(object.query_root).to_not be_nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/spec_helper"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe 'CQL::Repository' do
|
|
5
|
+
|
|
6
|
+
let(:clazz) { CQL::Repository }
|
|
7
|
+
let(:seed_arguments) { @feature_fixtures_directory }
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
describe 'common behavior' do
|
|
11
|
+
|
|
12
|
+
it_should_behave_like 'a queriable object'
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
it 'must be based on a source' do
|
|
18
|
+
expect(clazz.instance_method(:initialize).arity).to eq(1)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'can use a file path as a source' do
|
|
22
|
+
expect { clazz.new(@feature_fixtures_directory) }.to_not raise_error
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'can use a model as a source' do
|
|
26
|
+
some_model = CukeModeler::Scenario.new
|
|
27
|
+
|
|
28
|
+
expect { clazz.new(some_model) }.to_not raise_error
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "complains if can't be made from what it was given" do
|
|
32
|
+
expect { clazz.new(:some_other_thing) }.to raise_error(ArgumentError, "Don't know how to make a repository from a Symbol")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'does not modify the repository during a query' do
|
|
36
|
+
repo = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
|
|
37
|
+
|
|
38
|
+
original_state = Marshal.dump(repo)
|
|
39
|
+
|
|
40
|
+
# Just a big, messy query that does a little of everything
|
|
41
|
+
repo.query do
|
|
42
|
+
with { |scenario| scenario.name =~ /slurping/ }
|
|
43
|
+
as thing1
|
|
44
|
+
transform :self => lambda { |thing1| 1 }
|
|
45
|
+
select :self
|
|
46
|
+
as thing2
|
|
47
|
+
with scenarios => lambda { |scenario| scenario.name =~ /3/ }
|
|
48
|
+
from scenarios
|
|
49
|
+
select :self
|
|
50
|
+
transform :self => lambda { |thing2| 2 }
|
|
51
|
+
select name
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
new_state = Marshal.dump(repo)
|
|
55
|
+
|
|
56
|
+
expect(new_state).to eq(original_state)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'returns the same model instances as the ones being queried' do
|
|
60
|
+
model_1 = CukeModeler::Scenario.new
|
|
61
|
+
model_2 = CukeModeler::Step.new
|
|
62
|
+
model_3 = CukeModeler::Step.new
|
|
63
|
+
|
|
64
|
+
model_1.steps << model_2
|
|
65
|
+
model_1.steps << model_3
|
|
66
|
+
|
|
67
|
+
repo = CQL::Repository.new(model_1)
|
|
68
|
+
|
|
69
|
+
results = repo.query do
|
|
70
|
+
select :self
|
|
71
|
+
from scenarios, steps
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
result_model_ids = results.collect { |result| result[:self].object_id }
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
expect(result_model_ids).to match_array([model_1.object_id,
|
|
78
|
+
model_2.object_id,
|
|
79
|
+
model_3.object_id])
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|