activefacts 0.7.3 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. data/LICENSE +19 -0
  2. data/Manifest.txt +24 -2
  3. data/Rakefile +25 -3
  4. data/bin/afgen +1 -1
  5. data/bin/cql +13 -2
  6. data/css/offline.css +3 -0
  7. data/css/orm2.css +24 -0
  8. data/css/print.css +8 -0
  9. data/css/style-print.css +357 -0
  10. data/css/style.css +387 -0
  11. data/download.html +85 -0
  12. data/examples/CQL/Address.cql +3 -3
  13. data/examples/CQL/Blog.cql +13 -14
  14. data/examples/CQL/CompanyDirectorEmployee.cql +4 -4
  15. data/examples/CQL/Death.cql +3 -2
  16. data/examples/CQL/Genealogy.cql +13 -11
  17. data/examples/CQL/Marriage.cql +2 -2
  18. data/examples/CQL/Metamodel.cql +136 -93
  19. data/examples/CQL/MultiInheritance.cql +2 -2
  20. data/examples/CQL/OilSupply.cql +14 -10
  21. data/examples/CQL/Orienteering.cql +22 -19
  22. data/examples/CQL/PersonPlaysGame.cql +3 -2
  23. data/examples/CQL/SchoolActivities.cql +4 -2
  24. data/examples/CQL/SimplestUnary.cql +1 -1
  25. data/examples/CQL/SubtypePI.cql +6 -7
  26. data/examples/CQL/Warehousing.cql +16 -19
  27. data/examples/CQL/unit.cql +584 -0
  28. data/examples/index.html +276 -0
  29. data/examples/intro.html +497 -0
  30. data/examples/local.css +20 -0
  31. data/index.html +96 -0
  32. data/lib/activefacts/api/concept.rb +48 -46
  33. data/lib/activefacts/api/constellation.rb +43 -23
  34. data/lib/activefacts/api/entity.rb +2 -2
  35. data/lib/activefacts/api/instance.rb +6 -2
  36. data/lib/activefacts/api/instance_index.rb +5 -0
  37. data/lib/activefacts/api/value.rb +8 -2
  38. data/lib/activefacts/api/vocabulary.rb +15 -10
  39. data/lib/activefacts/cql/CQLParser.treetop +109 -88
  40. data/lib/activefacts/cql/Concepts.treetop +32 -10
  41. data/lib/activefacts/cql/Context.treetop +34 -0
  42. data/lib/activefacts/cql/Expressions.treetop +9 -9
  43. data/lib/activefacts/cql/FactTypes.treetop +30 -31
  44. data/lib/activefacts/cql/Language/English.treetop +50 -0
  45. data/lib/activefacts/cql/LexicalRules.treetop +2 -1
  46. data/lib/activefacts/cql/Terms.treetop +117 -0
  47. data/lib/activefacts/cql/ValueTypes.treetop +152 -0
  48. data/lib/activefacts/cql/compiler.rb +1718 -0
  49. data/lib/activefacts/cql/parser.rb +124 -57
  50. data/lib/activefacts/generate/absorption.rb +1 -1
  51. data/lib/activefacts/generate/cql.rb +111 -100
  52. data/lib/activefacts/generate/cql/html.rb +5 -5
  53. data/lib/activefacts/generate/oo.rb +3 -3
  54. data/lib/activefacts/generate/ordered.rb +51 -19
  55. data/lib/activefacts/generate/ruby.rb +10 -8
  56. data/lib/activefacts/generate/sql/mysql.rb +14 -10
  57. data/lib/activefacts/generate/sql/server.rb +29 -24
  58. data/lib/activefacts/input/cql.rb +9 -1264
  59. data/lib/activefacts/input/orm.rb +213 -200
  60. data/lib/activefacts/persistence/columns.rb +11 -10
  61. data/lib/activefacts/persistence/index.rb +15 -18
  62. data/lib/activefacts/persistence/reference.rb +17 -17
  63. data/lib/activefacts/persistence/tables.rb +50 -51
  64. data/lib/activefacts/version.rb +1 -1
  65. data/lib/activefacts/vocabulary/extensions.rb +79 -8
  66. data/lib/activefacts/vocabulary/metamodel.rb +183 -114
  67. data/spec/absorption_ruby_spec.rb +99 -0
  68. data/spec/absorption_spec.rb +3 -4
  69. data/spec/api/constellation.rb +1 -1
  70. data/spec/api/entity_type.rb +3 -1
  71. data/spec/api/instance.rb +4 -2
  72. data/spec/api/roles.rb +8 -6
  73. data/spec/api_spec.rb +1 -2
  74. data/spec/cql/context_spec.rb +71 -0
  75. data/spec/cql/samples_spec.rb +154 -0
  76. data/spec/cql/unit_spec.rb +375 -0
  77. data/spec/cql_cql_spec.rb +31 -21
  78. data/spec/cql_mysql_spec.rb +70 -0
  79. data/spec/cql_parse_spec.rb +15 -9
  80. data/spec/cql_ruby_spec.rb +27 -13
  81. data/spec/cql_sql_spec.rb +42 -16
  82. data/spec/cql_symbol_tables_spec.rb +2 -3
  83. data/spec/cqldump_spec.rb +7 -7
  84. data/spec/helpers/file_matcher.rb +39 -0
  85. data/spec/norma_cql_spec.rb +20 -12
  86. data/spec/norma_ruby_spec.rb +6 -3
  87. data/spec/norma_sql_spec.rb +6 -3
  88. data/spec/norma_tables_spec.rb +6 -4
  89. data/spec/spec_helper.rb +27 -8
  90. data/status.html +69 -0
  91. data/why.html +60 -0
  92. metadata +34 -11
  93. data/lib/activefacts/cql/DataTypes.treetop +0 -81
  94. data/spec/cql_unit_spec.rb +0 -330
@@ -0,0 +1,70 @@
1
+ #
2
+ # ActiveFacts tests: Parse all CQL files and check the generated SQL.
3
+ # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
4
+ #
5
+
6
+ require 'spec/spec_helper'
7
+ require 'stringio'
8
+ require 'activefacts/vocabulary'
9
+ require 'activefacts/support'
10
+ require 'activefacts/input/cql'
11
+ require 'activefacts/generate/sql/mysql'
12
+
13
+ include ActiveFacts
14
+ include ActiveFacts::Metamodel
15
+
16
+ describe "CQL Loader with SQL output" do
17
+ cql_failures = {
18
+ "Airline" => "Contains queries, unsupported",
19
+ "CompanyQuery" => "Contains queries, unsupported",
20
+ "OrienteeringER" => "Doesn't parse due to difficult fact type match",
21
+ "ServiceDirector" => "Doesn't parse some constraints due to mis-matched adjectives"
22
+ }
23
+ cql_mysql_failures = {
24
+ "Metamodel" => "An index to enforce uniqueness on the nesting fact type isn't emitted",
25
+ }
26
+
27
+ # Generate and return the SQL for the given vocabulary
28
+ def sql(vocabulary)
29
+ output = StringIO.new
30
+ @dumper = ActiveFacts::Generate::SQL::MYSQL.new(vocabulary.constellation, "norma")
31
+ @dumper.generate(output)
32
+ output.rewind
33
+ output.read
34
+ end
35
+
36
+ pattern = ENV["AFTESTS"] || "*"
37
+ Dir["examples/CQL/#{pattern}.cql"].each do |cql_file|
38
+ actual_file = cql_file.sub(%r{examples/CQL/(.*).cql}, 'spec/actual/\1.my.sql')
39
+ expected_file = cql_file.sub(%r{examples/CQL/(.*).cql\Z}, 'examples/MySQL/\1.sql')
40
+
41
+ it "should load #{cql_file} and dump MySQL matching #{expected_file}" do
42
+ broken = cql_failures[File.basename(cql_file, ".cql")]
43
+ vocabulary = nil
44
+ if broken
45
+ pending(broken) {
46
+ lambda { vocabulary = ActiveFacts::Input::CQL.readfile(cql_file) }.should_not raise_error
47
+ }
48
+ else
49
+ lambda { vocabulary = ActiveFacts::Input::CQL.readfile(cql_file) }.should_not raise_error
50
+ end
51
+
52
+ # Build and save the actual file:
53
+ sql_text = sql(vocabulary)
54
+ File.open(actual_file, "w") { |f| f.write sql_text }
55
+
56
+ pending("expected output file #{expected_file} not found") unless File.exists? expected_file
57
+
58
+ expected_text = File.open(expected_file) {|f| f.read }
59
+ broken = cql_mysql_failures[File.basename(actual_file, ".cql")]
60
+ if broken
61
+ pending(broken) {
62
+ sql_text.should_not differ_from(expected_text)
63
+ }
64
+ else
65
+ sql_text.should_not differ_from(expected_text)
66
+ File.delete(actual_file) # It succeeded, we don't need the file.
67
+ end
68
+ end
69
+ end
70
+ end
@@ -2,7 +2,7 @@
2
2
  # ActiveFacts tests: Parse all NORMA files and check the generated CQL.
3
3
  # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
4
4
  #
5
- require 'rubygems'
5
+
6
6
  require 'stringio'
7
7
  require 'activefacts/vocabulary'
8
8
  require 'activefacts/support'
@@ -12,19 +12,25 @@ require 'activefacts/generate/cql'
12
12
  include ActiveFacts
13
13
 
14
14
  describe "CQL Parser" do
15
- CQLPARSE_FAILURES = %w{
16
- Airline
17
- CompanyQuery
18
- Insurance
19
- OrienteeringER
20
- ServiceDirector
15
+ cql_failures = {
16
+ "Airline" => "Contains queries, unsupported",
17
+ "CompanyQuery" => "Contains queries, unsupported",
18
+ "OrienteeringER" => "Contains a long fact type that can't be matched properly",
19
+ "ServiceDirector" => "Contains constraints with mismatched adjectives",
21
20
  }
22
21
 
23
22
  pattern = ENV["AFTESTS"] || "*"
24
23
  Dir["examples/CQL/#{pattern}.cql"].each do |cql_file|
25
24
  it "should load CQL #{cql_file} without parse errors" do
26
- pending if CQLPARSE_FAILURES.include? File.basename(cql_file, ".cql")
27
- lambda { vocabulary = ActiveFacts::Input::CQL.readfile(cql_file) }.should_not raise_error
25
+ broken = cql_failures[File.basename(cql_file, ".cql")]
26
+
27
+ if broken
28
+ pending(broken) {
29
+ lambda { vocabulary = ActiveFacts::Input::CQL.readfile(cql_file) }.should_not raise_error
30
+ }
31
+ else
32
+ lambda { vocabulary = ActiveFacts::Input::CQL.readfile(cql_file) }.should_not raise_error
33
+ end
28
34
  end
29
35
  end
30
36
  end
@@ -2,7 +2,8 @@
2
2
  # ActiveFacts tests: Parse all CQL files and check the generated Ruby.
3
3
  # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
4
4
  #
5
- require 'rubygems'
5
+
6
+ require 'spec/spec_helper'
6
7
  require 'stringio'
7
8
  require 'activefacts/vocabulary'
8
9
  require 'activefacts/support'
@@ -19,13 +20,11 @@ class String
19
20
  end
20
21
 
21
22
  describe "CQL Loader with Ruby output" do
22
- CQL_RUBY_FAILURES = %w{
23
- Airline
24
- CompanyQuery
25
- Insurance
26
- OrienteeringER
27
- Orienteering
28
- ServiceDirector
23
+ cql_failures = {
24
+ "Airline" => "Contains queries, not supported",
25
+ "CompanyQuery" => "Contains queries, not supported",
26
+ "OrienteeringER" => "Large fact type reading cannot be matched",
27
+ "ServiceDirector" => "Constraints contain adjectives that require looser matching",
29
28
  }
30
29
 
31
30
  # Generate and return the Ruby for the given vocabulary
@@ -43,16 +42,31 @@ describe "CQL Loader with Ruby output" do
43
42
  actual_file = cql_file.sub(%r{examples/CQL/(.*).cql\Z}, 'spec/actual/\1.rb')
44
43
 
45
44
  it "should load #{cql_file} and dump Ruby matching #{expected_file}" do
46
- pending if CQL_RUBY_FAILURES.include? File.basename(cql_file, ".cql")
47
- vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
45
+ vocabulary = nil
46
+ broken = cql_failures[File.basename(cql_file, ".cql")]
47
+ if broken
48
+ pending(broken) {
49
+ vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
50
+ }
51
+ else
52
+ vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
53
+ end
48
54
 
49
55
  # Build and save the actual file:
50
56
  ruby_text = ruby(vocabulary)
51
57
  File.open(actual_file, "w") { |f| f.write ruby_text }
52
58
 
53
- pending unless File.exists? expected_file
54
- ruby_text.should == File.open(expected_file) {|f| f.read }
55
- File.delete(actual_file) # It succeeded, we don't need the file.
59
+ pending("expected output file #{expected_file} not found") unless File.exists? expected_file
60
+
61
+ expected_text = File.open(expected_file) {|f| f.read }
62
+ # if broken
63
+ # pending(broken) {
64
+ # ruby_text.should == File.open(expected_file) {|f| f.read }
65
+ # }
66
+ # else
67
+ ruby_text.should_not differ_from(expected_text)
68
+ File.delete(actual_file) # It succeeded, we don't need the file.
69
+ # end
56
70
  end
57
71
  end
58
72
  end
data/spec/cql_sql_spec.rb CHANGED
@@ -2,7 +2,8 @@
2
2
  # ActiveFacts tests: Parse all CQL files and check the generated SQL.
3
3
  # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
4
4
  #
5
- require 'rubygems'
5
+
6
+ require 'spec/spec_helper'
6
7
  require 'stringio'
7
8
  require 'activefacts/vocabulary'
8
9
  require 'activefacts/support'
@@ -13,16 +14,25 @@ include ActiveFacts
13
14
  include ActiveFacts::Metamodel
14
15
 
15
16
  describe "CQL Loader with SQL output" do
16
- CQL_SQL_FAILURES = %w{
17
- Airline
18
- CompanyDirectorEmployee
19
- CompanyQuery
20
- Insurance
21
- JoinEquality
22
- Marriage
23
- OrienteeringER
24
- ServiceDirector
25
- SimplestUnary
17
+ cql_failures = {
18
+ "Airline" => "Contains unsupported queries",
19
+ "CompanyQuery" => "Contains unsupported queries",
20
+ "OrienteeringER" => "Large fact type reading cannot be matched",
21
+ "ServiceDirector" => "Constraints contain adjectives that require looser matching",
22
+ }
23
+ cql_sql_failures = {
24
+ "Blog" => "Drops uniqueness constraints",
25
+ "CompanyDirectorEmployee" => "Names an index automatically from CQL, but explicitly from NORMA",
26
+ "Insurance" => "CQL doesn't have an option for subtype separation",
27
+ "Metamodel" =>
28
+ "Names an index automatically from CQL, but explicitly from NORMA" + " " +
29
+ "Drops uniqueness constraints",
30
+ "Orienteering" =>
31
+ "Names an index automatically from CQL, but explicitly from NORMA" + " " +
32
+ "Drops uniqueness constraints",
33
+ "RedundantDependency" => "Drops uniqueness constraints",
34
+ "SubtypePI" => "Names an index automatically from CQL, but explicitly from NORMA",
35
+ "Tests.Test5.Load" => "Names an index automatically from CQL, but explicitly from NORMA",
26
36
  }
27
37
 
28
38
  # Generate and return the SQL for the given vocabulary
@@ -40,16 +50,32 @@ describe "CQL Loader with SQL output" do
40
50
  expected_file = cql_file.sub(%r{examples/CQL/(.*).cql\Z}, 'examples/SQL/\1.sql')
41
51
 
42
52
  it "should load #{cql_file} and dump SQL matching #{expected_file}" do
43
- pending if CQL_SQL_FAILURES.include? File.basename(cql_file, ".cql")
44
- vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
53
+ vocabulary = nil
54
+ broken = cql_failures[File.basename(cql_file, ".cql")]
55
+ if broken
56
+ pending(broken) {
57
+ vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
58
+ }
59
+ else
60
+ vocabulary = ActiveFacts::Input::CQL.readfile(cql_file)
61
+ end
45
62
 
46
63
  # Build and save the actual file:
47
64
  sql_text = sql(vocabulary)
48
65
  File.open(actual_file, "w") { |f| f.write sql_text }
49
66
 
50
- pending unless File.exists? expected_file
51
- sql_text.should == File.open(expected_file) {|f| f.read }
52
- File.delete(actual_file) # It succeeded, we don't need the file.
67
+ pending("expected output file #{expected_file} not found") unless File.exists? expected_file
68
+
69
+ expected_text = File.open(expected_file) {|f| f.read }
70
+ broken = cql_sql_failures[File.basename(cql_file, ".cql")]
71
+ if broken
72
+ pending(broken) {
73
+ sql_text.should_not differ_from(expected_text)
74
+ }
75
+ else
76
+ sql_text.should_not differ_from(expected_text)
77
+ File.delete(actual_file) # It succeeded, we don't need the file.
78
+ end
53
79
  end
54
80
  end
55
81
  end
@@ -2,8 +2,7 @@
2
2
  # ActiveFacts tests: Test the CQL parser by looking at its parse trees.
3
3
  # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
4
4
  #
5
- require 'rubygems'
6
- require 'treetop'
5
+
7
6
  require 'activefacts/support'
8
7
  require 'activefacts/api/support'
9
8
  require 'activefacts/input/cql'
@@ -19,7 +18,7 @@ describe "CQL Symbol table" do
19
18
  include ActiveFacts::Input::CQL
20
19
  @constellation = ActiveFacts::API::Constellation.new(ActiveFacts::Metamodel)
21
20
  @vocabulary = @constellation.Vocabulary("Test")
22
- @symbols = ActiveFacts::Input::CQL::SymbolTable.new(@constellation, @vocabulary)
21
+ @symbols = ActiveFacts::CQL::Compiler::SymbolTable.new(@constellation, @vocabulary)
23
22
  end
24
23
 
25
24
  Definitions = [
data/spec/cqldump_spec.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # ActiveFacts tests: Test the generated CQL for some simple cases.
3
3
  # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
4
4
  #
5
- require 'rubygems'
5
+
6
6
  require 'stringio'
7
7
  require 'activefacts/support'
8
8
  require 'activefacts/vocabulary'
@@ -70,8 +70,8 @@ END
70
70
  def one_to_many(one, many, reading)
71
71
  # Join them with a fact type:
72
72
  ft = @constellation.FactType(:new)
73
- role0 = @constellation.Role(ft, 0, one)
74
- role1 = @constellation.Role(ft, 1, many)
73
+ role0 = @constellation.Role(ft, 0, :concept => one)
74
+ role1 = @constellation.Role(ft, 1, :concept => many)
75
75
 
76
76
  # Make a role sequence:
77
77
  rs = @constellation.RoleSequence(:new)
@@ -84,7 +84,7 @@ END
84
84
  pc = @constellation.PresenceConstraint(:new, :is_mandatory => false, :is_preferred_identifier => false, :max_frequency => 1, :min_frequency => 0, :role_sequence => pcrs)
85
85
 
86
86
  # Make a new reading:
87
- reading = @constellation.Reading(ft, ft.all_reading.size, :role_sequence => rs, :reading_text => reading)
87
+ reading = @constellation.Reading(ft, ft.all_reading.size, :role_sequence => rs, :text => reading)
88
88
 
89
89
  ft
90
90
  end
@@ -92,8 +92,8 @@ END
92
92
  def one_to_one(first, second, reading)
93
93
  # Join them with a fact type:
94
94
  ft = @constellation.FactType(:new)
95
- role0 = @constellation.Role(ft, 0, first)
96
- role1 = @constellation.Role(ft, 1, second)
95
+ role0 = @constellation.Role(ft, 0, :concept => first)
96
+ role1 = @constellation.Role(ft, 1, :concept => second)
97
97
 
98
98
  # Make a role sequence for the reading
99
99
  rs = @constellation.RoleSequence(:new)
@@ -101,7 +101,7 @@ END
101
101
  rr1 = @constellation.RoleRef(rs, 1, :role => role1)
102
102
 
103
103
  # Make a new reading:
104
- reading = @constellation.Reading(ft, ft.all_reading.size, :role_sequence => rs, :reading_text => reading)
104
+ reading = @constellation.Reading(ft, ft.all_reading.size, :role_sequence => rs, :text => reading)
105
105
 
106
106
  # Make a uniqueness constraint for the first role
107
107
  first_rs = @constellation.RoleSequence(:new)
@@ -0,0 +1,39 @@
1
+ require 'diff/lcs'
2
+
3
+ module FileMatcher
4
+ class BeDifferent
5
+ def initialize(expected)
6
+ @expected = expected.scan(/[^\n]+/)
7
+ end
8
+
9
+ def matches?(actual)
10
+ actual_lines = actual.scan(/[^\n]+/)
11
+ differences = Diff::LCS::diff(@expected, actual_lines)
12
+ @diff = differences.map do |chunk|
13
+ added_at = (add = chunk.detect{|d| d.action == '+'}) && add.position+1
14
+ removed_at = (remove = chunk.detect{|d| d.action == '-'}) && remove.position+1
15
+ "Line #{added_at}/#{removed_at}:\n"+
16
+ chunk.map do |change|
17
+ "#{change.action} #{change.element}"
18
+ end*"\n"
19
+ end*"\n"
20
+ @diff != ''
21
+ end
22
+
23
+ def failure_message
24
+ "expected a difference, but got none"
25
+ end
26
+
27
+ def negative_failure_message
28
+ "expected no difference, but got:\n#{@diff}"
29
+ end
30
+ end
31
+
32
+ def differ_from(expected)
33
+ BeDifferent.new(expected)
34
+ end
35
+ end
36
+
37
+ Spec::Runner.configure do |config|
38
+ config.include(FileMatcher)
39
+ end
@@ -2,7 +2,8 @@
2
2
  # ActiveFacts tests: Parse all NORMA files and check the generated CQL.
3
3
  # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
4
4
  #
5
- require 'rubygems'
5
+
6
+ require 'spec/spec_helper'
6
7
  require 'stringio'
7
8
  require 'activefacts/vocabulary'
8
9
  require 'activefacts/support'
@@ -12,9 +13,8 @@ require 'activefacts/generate/cql'
12
13
  include ActiveFacts
13
14
 
14
15
  describe "Norma Loader" do
15
- ORM_CQL_FAILURES = %w{
16
- OddIdentifier
17
- ServiceDirector
16
+ orm_cql_failures = {
17
+ # "OddIdentifier" => "Strange identification pattern is incorrectly verbalised to CQL", # Fixed
18
18
  }
19
19
  # Generate and return the CQL for the given vocabulary
20
20
  def cql(vocabulary)
@@ -22,26 +22,34 @@ describe "Norma Loader" do
22
22
  @dumper = ActiveFacts::Generate::CQL.new(vocabulary.constellation)
23
23
  @dumper.generate(output)
24
24
  output.rewind
25
- output.readlines
25
+ output.read
26
26
  end
27
27
 
28
28
  pattern = ENV["AFTESTS"] || "*"
29
29
  Dir["examples/norma/#{pattern}.orm"].each do |orm_file|
30
30
  expected_file = orm_file.sub(%r{/norma/(.*).orm\Z}, '/CQL/\1.cql')
31
-
32
31
  actual_file = orm_file.sub(%r{examples/norma/(.*).orm\Z}, 'spec/actual/\1.cql')
33
32
 
34
33
  it "should load #{orm_file} and dump CQL matching #{expected_file}" do
35
- pending if ORM_CQL_FAILURES.include? File.basename(orm_file, ".orm")
36
34
  vocabulary = ActiveFacts::Input::ORM.readfile(orm_file)
37
35
 
38
- cql = cql(vocabulary)
36
+ cql_text = cql(vocabulary)
39
37
  # Save the actual file:
40
- File.open(actual_file, "w") { |f| f.write cql*"" }
38
+ File.open(actual_file, "w") { |f| f.write cql_text }
39
+
40
+ pending("expected output file #{expected_file} not found") unless File.exists? expected_file
41
+
42
+ expected_text = File.open(expected_file) {|f| f.read }
41
43
 
42
- pending unless File.exists? expected_file
43
- cql.should == File.open(expected_file) {|f| f.readlines}
44
- File.delete(actual_file)
44
+ broken = orm_cql_failures[File.basename(orm_file, ".orm")]
45
+ if broken
46
+ pending(broken) {
47
+ cql_text.should_not differ_from(expected_text)
48
+ }
49
+ else
50
+ cql_text.should_not differ_from(expected_text)
51
+ File.delete(actual_file)
52
+ end
45
53
  end
46
54
  end
47
55
  end
@@ -2,7 +2,8 @@
2
2
  # ActiveFacts tests: Parse all CQL files and check the generated Ruby.
3
3
  # Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
4
4
  #
5
- require 'rubygems'
5
+
6
+ require 'spec/spec_helper'
6
7
  require 'stringio'
7
8
  require 'activefacts/vocabulary'
8
9
  require 'activefacts/support'
@@ -40,8 +41,10 @@ describe "NORMA Loader with Ruby output" do
40
41
  ruby_text = ruby(vocabulary)
41
42
  File.open(actual_file, "w") { |f| f.write ruby_text }
42
43
 
43
- pending unless File.exists? expected_file
44
- ruby_text.should == File.open(expected_file) {|f| f.read }
44
+ pending("expected output file #{expected_file} not found") unless File.exists? expected_file
45
+
46
+ expected_text = File.open(expected_file) {|f| f.read }
47
+ ruby_text.should_not differ_from(expected_text)
45
48
  File.delete(actual_file) # It succeeded, we don't need the file.
46
49
  end
47
50
  end