alf 0.9.2 → 0.9.3

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 (187) hide show
  1. data/CHANGELOG.md +89 -0
  2. data/Gemfile.lock +6 -1
  3. data/README.md +35 -21
  4. data/TODO.md +0 -5
  5. data/alf.gemspec +2 -0
  6. data/alf.noespec +6 -4
  7. data/bin/alf +9 -13
  8. data/examples/{autonum.alf → operators/autonum.alf} +0 -0
  9. data/examples/{cities.rash → operators/cities.rash} +0 -0
  10. data/examples/{clip.alf → operators/clip.alf} +0 -0
  11. data/examples/{compact.alf → operators/compact.alf} +0 -0
  12. data/examples/{database.alf → operators/database.alf} +1 -1
  13. data/examples/{defaults.alf → operators/defaults.alf} +0 -0
  14. data/examples/{extend.alf → operators/extend.alf} +0 -0
  15. data/examples/{group.alf → operators/group.alf} +0 -0
  16. data/examples/{intersect.alf → operators/intersect.alf} +0 -0
  17. data/examples/{join.alf → operators/join.alf} +0 -0
  18. data/examples/operators/matching.alf +2 -0
  19. data/examples/{minus.alf → operators/minus.alf} +0 -0
  20. data/examples/operators/not_matching.alf +2 -0
  21. data/examples/{nulls.rash → operators/nulls.rash} +0 -0
  22. data/examples/{parts.rash → operators/parts.rash} +0 -0
  23. data/examples/{project.alf → operators/project.alf} +0 -0
  24. data/examples/{pseudo-with.alf → operators/pseudo-with.alf} +0 -0
  25. data/examples/{quota.alf → operators/quota.alf} +0 -0
  26. data/examples/operators/rank.alf +4 -0
  27. data/examples/{rename.alf → operators/rename.alf} +0 -0
  28. data/examples/{restrict.alf → operators/restrict.alf} +0 -0
  29. data/examples/{schema.yaml → operators/schema.yaml} +0 -0
  30. data/examples/{sort.alf → operators/sort.alf} +0 -0
  31. data/examples/{summarize.alf → operators/summarize.alf} +0 -0
  32. data/examples/{suppliers.rash → operators/suppliers.rash} +0 -0
  33. data/examples/{supplies.rash → operators/supplies.rash} +0 -0
  34. data/examples/{ungroup.alf → operators/ungroup.alf} +0 -0
  35. data/examples/{union.alf → operators/union.alf} +0 -0
  36. data/examples/{unwrap.alf → operators/unwrap.alf} +0 -0
  37. data/examples/{wrap.alf → operators/wrap.alf} +0 -0
  38. data/lib/alf.rb +837 -62
  39. data/lib/alf/loader.rb +2 -1
  40. data/lib/alf/text.rb +160 -0
  41. data/lib/alf/version.rb +1 -1
  42. data/lib/alf/yaml.rb +24 -0
  43. data/spec/integration/__database__/group.alf +3 -0
  44. data/spec/integration/__database__/parts.rash +6 -0
  45. data/spec/integration/__database__/suppliers.rash +5 -0
  46. data/spec/integration/__database__/supplies.rash +12 -0
  47. data/spec/integration/command/alf/alf_e.cmd +1 -0
  48. data/spec/integration/command/alf/alf_e.stdout +4 -0
  49. data/spec/integration/command/alf/alf_env.cmd +1 -0
  50. data/spec/integration/command/alf/alf_env.stdout +5 -0
  51. data/spec/integration/command/alf/alf_implicit.alf +1 -0
  52. data/spec/integration/command/alf/alf_implicit_exec.cmd +1 -0
  53. data/spec/integration/command/alf/alf_implicit_exec.stdout +4 -0
  54. data/spec/integration/command/alf/alf_r.cmd +1 -0
  55. data/spec/integration/command/alf/alf_r.stdout +5 -0
  56. data/spec/integration/command/alf/alf_version.cmd +1 -0
  57. data/spec/integration/command/alf/alf_version.stdout +2 -0
  58. data/spec/integration/command/alf/alf_yaml.cmd +1 -0
  59. data/spec/integration/command/alf/alf_yaml.stdout +22 -0
  60. data/spec/integration/command/alf/rel.rash +1 -0
  61. data/spec/integration/command/autonum/autonum_0.cmd +1 -0
  62. data/spec/integration/command/autonum/autonum_0.stdout +9 -0
  63. data/spec/integration/command/autonum/autonum_1.cmd +1 -0
  64. data/spec/integration/command/autonum/autonum_1.stdout +9 -0
  65. data/spec/integration/command/clip/clip_0.cmd +1 -0
  66. data/spec/integration/command/clip/clip_0.stdout +9 -0
  67. data/spec/integration/command/clip/clip_1.cmd +1 -0
  68. data/spec/integration/command/clip/clip_1.stdout +9 -0
  69. data/spec/integration/command/compact/compact_0.cmd +1 -0
  70. data/spec/integration/command/compact/compact_0.stdout +9 -0
  71. data/spec/integration/command/defaults/defaults_0.cmd +1 -0
  72. data/spec/integration/command/defaults/defaults_0.stdout +9 -0
  73. data/spec/integration/command/defaults/defaults_1.cmd +1 -0
  74. data/spec/integration/command/defaults/defaults_1.stdout +9 -0
  75. data/spec/integration/command/extend/extend_0.cmd +1 -0
  76. data/spec/integration/command/extend/extend_0.stdout +16 -0
  77. data/spec/integration/command/group/group_0.cmd +1 -0
  78. data/spec/integration/command/group/group_0.stdout +32 -0
  79. data/spec/integration/command/group/group_1.cmd +1 -0
  80. data/spec/integration/command/group/group_1.stdout +32 -0
  81. data/spec/integration/command/intersect/intersect_0.cmd +1 -0
  82. data/spec/integration/command/intersect/intersect_0.stdout +9 -0
  83. data/spec/integration/command/join/join_0.cmd +1 -0
  84. data/spec/integration/command/join/join_0.stdout +16 -0
  85. data/spec/integration/command/matching/matching_0.cmd +1 -0
  86. data/spec/integration/command/matching/matching_0.stdout +8 -0
  87. data/spec/integration/command/minus/minus_0.cmd +1 -0
  88. data/spec/integration/command/minus/minus_0.stdout +4 -0
  89. data/spec/integration/command/not-matching/not-matching_0.cmd +1 -0
  90. data/spec/integration/command/not-matching/not-matching_0.stdout +5 -0
  91. data/spec/integration/command/project/project_0.cmd +1 -0
  92. data/spec/integration/command/project/project_0.stdout +9 -0
  93. data/spec/integration/command/project/project_1.cmd +1 -0
  94. data/spec/integration/command/project/project_1.stdout +9 -0
  95. data/spec/integration/command/quota/quota_0.cmd +1 -0
  96. data/spec/integration/command/quota/quota_0.stdout +16 -0
  97. data/spec/integration/command/rank/rank_1.cmd +1 -0
  98. data/spec/integration/command/rank/rank_1.stdout +10 -0
  99. data/spec/integration/command/rank/rank_2.cmd +1 -0
  100. data/spec/integration/command/rank/rank_2.stdout +10 -0
  101. data/spec/integration/command/rank/rank_3.cmd +1 -0
  102. data/spec/integration/command/rank/rank_3.stdout +10 -0
  103. data/spec/integration/command/rank/rank_4.cmd +1 -0
  104. data/spec/integration/command/rank/rank_4.stdout +6 -0
  105. data/spec/integration/command/rank/rank_5.cmd +1 -0
  106. data/spec/integration/command/rank/rank_5.stdout +6 -0
  107. data/spec/integration/command/rename/rename_0.cmd +1 -0
  108. data/spec/integration/command/rename/rename_0.stdout +9 -0
  109. data/spec/integration/command/restrict/restrict_0.cmd +1 -0
  110. data/spec/integration/command/restrict/restrict_0.stdout +6 -0
  111. data/spec/integration/command/restrict/restrict_1.cmd +1 -0
  112. data/spec/integration/command/restrict/restrict_1.stdout +6 -0
  113. data/spec/integration/command/show/show_base.cmd +1 -0
  114. data/spec/integration/command/show/show_base.stdout +9 -0
  115. data/spec/integration/command/show/show_conflictual.cmd +1 -0
  116. data/spec/integration/command/show/show_conflictual.stdout +5 -0
  117. data/spec/integration/command/show/show_rash.cmd +1 -0
  118. data/spec/integration/command/show/show_rash.stdout +5 -0
  119. data/spec/integration/command/show/show_rash_2.cmd +1 -0
  120. data/spec/integration/command/show/show_rash_2.stdout +5 -0
  121. data/spec/integration/command/show/show_yaml.cmd +1 -0
  122. data/spec/integration/command/show/show_yaml.stdout +22 -0
  123. data/spec/integration/command/sort/sort_0.cmd +1 -0
  124. data/spec/integration/command/sort/sort_0.stdout +9 -0
  125. data/spec/integration/command/sort/sort_1.cmd +1 -0
  126. data/spec/integration/command/sort/sort_1.stdout +9 -0
  127. data/spec/integration/command/summarize/summarize_0.cmd +1 -0
  128. data/spec/integration/command/summarize/summarize_0.stdout +8 -0
  129. data/spec/integration/command/ungroup/ungroup_0.cmd +1 -0
  130. data/spec/integration/command/ungroup/ungroup_0.stdout +16 -0
  131. data/spec/integration/command/union/union_0.cmd +1 -0
  132. data/spec/integration/command/union/union_0.stdout +9 -0
  133. data/spec/integration/command/unwrap/unwrap_0.cmd +1 -0
  134. data/spec/integration/command/unwrap/unwrap_0.stdout +9 -0
  135. data/spec/integration/command/wrap/wrap_0.cmd +1 -0
  136. data/spec/integration/command/wrap/wrap_0.stdout +9 -0
  137. data/spec/integration/semantics/test_join.alf +9 -0
  138. data/spec/integration/{src → semantics}/test_minus.alf +0 -0
  139. data/spec/integration/{src → semantics}/test_project.alf +0 -0
  140. data/spec/integration/semantics/test_rank.alf +34 -0
  141. data/spec/integration/test_command.rb +36 -0
  142. data/spec/integration/test_examples.rb +11 -22
  143. data/spec/integration/test_semantics.rb +40 -0
  144. data/spec/regression/alf_file/__FILE__.alf +2 -0
  145. data/spec/regression/alf_file/suppliers.rash +5 -0
  146. data/spec/regression/alf_file/test___FILE__.rb +17 -0
  147. data/spec/regression/heading/test_heading_with_date.rb +12 -0
  148. data/spec/regression/lispy/test_compile.rb +14 -0
  149. data/spec/regression/relation/test_relation_with_date.rb +12 -0
  150. data/spec/regression/restrict/test_restrict_with_keywords.rb +17 -0
  151. data/spec/shared/a_value.rb +12 -0
  152. data/spec/shared/an_operator_class.rb +35 -0
  153. data/spec/spec_helper.rb +12 -34
  154. data/spec/unit/assumptions/test_file.rb +17 -0
  155. data/spec/unit/{test_assumptions.rb → assumptions/test_instance_eval.rb} +1 -1
  156. data/spec/unit/assumptions/test_scoping.rb +29 -0
  157. data/spec/unit/environment/test_folder.rb +6 -1
  158. data/spec/unit/operator/relational/matching/test_hash_based.rb +60 -0
  159. data/spec/unit/operator/relational/not_matching/test_hash_based.rb +37 -0
  160. data/spec/unit/operator/relational/test_rank.rb +50 -0
  161. data/spec/unit/operator/test_relational.rb +3 -0
  162. data/spec/unit/reader/test_alf_file.rb +7 -4
  163. data/spec/unit/reader/test_initialize.rb +60 -0
  164. data/spec/unit/relation/test_relops.rb +4 -0
  165. data/spec/unit/relation/test_to_a.rb +41 -0
  166. data/spec/unit/renderer/test_initialize.rb +60 -0
  167. data/spec/unit/test_environment.rb +38 -0
  168. data/spec/unit/test_heading.rb +38 -0
  169. data/spec/unit/test_reader.rb +5 -0
  170. data/spec/unit/test_relation.rb +31 -1
  171. data/spec/unit/test_renderer.rb +1 -1
  172. data/spec/unit/{renderer/text → text}/test_cell.rb +1 -1
  173. data/spec/unit/{renderer/text → text}/test_row.rb +1 -1
  174. data/spec/unit/{renderer/text → text}/test_table.rb +1 -1
  175. data/spec/unit/tools/test_ordering_key.rb +13 -0
  176. data/spec/unit/tools/test_parse_commandline_args.rb +47 -0
  177. data/spec/unit/tools/test_tuple_handle.rb +34 -2
  178. data/spec/unit/tools/test_varargs.rb +16 -0
  179. data/tasks/{spec_test.rake → integration_test.rake} +4 -32
  180. data/tasks/regression_test.rake +52 -0
  181. data/tasks/unit_test.rake +33 -58
  182. metadata +326 -66
  183. data/examples/runall.sh +0 -26
  184. data/lib/alf/relation.rb +0 -118
  185. data/lib/alf/renderer/text.rb +0 -153
  186. data/lib/alf/renderer/yaml.rb +0 -22
  187. data/spec/integration/test_alf_specs.rb +0 -37
@@ -25,6 +25,11 @@ module Alf
25
25
  Reader.reader($stdin).should be_a(Reader::Rash)
26
26
  end
27
27
 
28
+ specify "with options" do
29
+ r = Reader.reader('suppliers.rash', {:hello => "world"})
30
+ r.options.should == {:hello => "world"}
31
+ end
32
+
28
33
  end
29
34
 
30
35
  end
@@ -12,10 +12,15 @@ module Alf
12
12
  let(:rel1){ Relation.new(tuples.to_set) }
13
13
  let(:rel2){ Relation.new(tuples2.to_set) }
14
14
  let(:rel3){ Relation.new(tuples[0..1].to_set) }
15
-
15
+
16
16
  it "should have a cardinality method" do
17
17
  rel1.cardinality.should == 3
18
18
  end
19
+
20
+ it "should have an empty? method" do
21
+ Alf::Relation[].should be_empty
22
+ rel1.should_not be_empty
23
+ end
19
24
 
20
25
  it "should define == correctly" do
21
26
  rel1.should == rel2
@@ -35,6 +40,31 @@ module Alf
35
40
  it "should be enumerable" do
36
41
  rel1.to_a.sort{|t1,t2| t1[:sid] <=> t2[:sid]}.should == tuples
37
42
  end
43
+
44
+ describe "rel1" do
45
+ subject{ rel1 }
46
+ it_should_behave_like "A value"
47
+ end
48
+
49
+ describe "DUM" do
50
+ subject{ Relation::DUM }
51
+ it_should_behave_like "A value"
52
+ specify{
53
+ subject.cardinality.should == 0
54
+ subject.to_a.should == []
55
+ subject.should be_empty
56
+ }
57
+ end
58
+
59
+ describe "DEE" do
60
+ subject{ Relation::DEE }
61
+ it_should_behave_like "A value"
62
+ specify{
63
+ subject.cardinality.should == 1
64
+ subject.to_a.should == [{}]
65
+ subject.should_not be_empty
66
+ }
67
+ end
38
68
 
39
69
  end
40
70
  end
@@ -15,7 +15,7 @@ module Alf
15
15
  subject{ Renderer.rash(input) }
16
16
  let(:input){ [{:a => 1}] }
17
17
  let(:output){ "" }
18
- let(:expected){ "{:a=>1}\n" }
18
+ let(:expected){ "{:a => 1}\n" }
19
19
  specify{
20
20
  subject.should be_a(Renderer)
21
21
  subject.execute(output).should == expected
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  module Alf
3
- class Renderer::Text
3
+ class Text::Renderer
4
4
  describe Cell do
5
5
 
6
6
  let(:f){ Cell.new }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  module Alf
3
- class Renderer::Text
3
+ class Text::Renderer
4
4
  describe Row do
5
5
 
6
6
  let(:row){ Row.new(values) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  module Alf
3
- class Renderer::Text
3
+ class Text::Renderer
4
4
  describe Table do
5
5
 
6
6
  let(:columns){ [ :method, :total ] }
@@ -19,6 +19,19 @@ module Alf
19
19
  key.order_of(:b).should == :asc
20
20
  end
21
21
 
22
+ specify "when passed a single array with asc and desc (1)" do
23
+ key = OrderingKey.coerce [:a, :asc]
24
+ key.attributes.should == [:a]
25
+ key.order_of(:a).should == :asc
26
+ end
27
+
28
+ specify "when passed a single array with asc and desc (1)" do
29
+ key = OrderingKey.coerce [:a, :asc, :b, :desc]
30
+ key.attributes.should == [:a, :b]
31
+ key.order_of(:a).should == :asc
32
+ key.order_of(:b).should == :desc
33
+ end
34
+
22
35
  specify "when passed an ordering key" do
23
36
  key = OrderingKey.coerce [:a, :b]
24
37
  key2 = OrderingKey.coerce key
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ module Alf
3
+ describe "Tools#parse_commandline_args" do
4
+
5
+ subject{ Tools.parse_commandline_args(args) }
6
+
7
+ describe "on empty string" do
8
+ let(:args){ "" }
9
+ it { should eq([]) }
10
+ end
11
+
12
+ describe "on pseudo empty string" do
13
+ let(:args){ " " }
14
+ it { should eq([]) }
15
+ end
16
+
17
+ describe "on a single arg" do
18
+ let(:args){ "--text" }
19
+ it { should eq(["--text"]) }
20
+ end
21
+
22
+ describe "on a multiple args" do
23
+ let(:args){ "--text --size=10" }
24
+ it { should eq(["--text", "--size=10"]) }
25
+ end
26
+
27
+ describe "on single quoted arg" do
28
+ let(:args){ "'hello'" }
29
+ it { should eq(["hello"]) }
30
+ end
31
+
32
+ describe "on single quoted arg with spacing" do
33
+ let(:args){ "'hello the world'" }
34
+ it { should eq(["hello the world"]) }
35
+ end
36
+
37
+ describe "on double quoted arg" do
38
+ let(:args){ '"hello"' }
39
+ it { should eq(["hello"]) }
40
+ end
41
+
42
+ describe "on double quoted arg with spacing" do
43
+ let(:args){ "'hello the world'" }
44
+ it { should eq(['hello the world']) }
45
+ end
46
+ end
47
+ end
@@ -11,7 +11,7 @@ module Alf
11
11
  handle.should respond_to(:world)
12
12
  end
13
13
 
14
- it "installed methods should behave correctly" do
14
+ it "should behave correctly" do
15
15
  handle.set(:hello => "a", :world => "b")
16
16
  handle.hello.should == "a"
17
17
  handle.world.should == "b"
@@ -20,11 +20,16 @@ module Alf
20
20
  handle.world.should == "d"
21
21
  end
22
22
 
23
- it "should allow instance evaluatin on exprs" do
23
+ it "should allow instance evaluating on exprs" do
24
24
  handle.set(:tested => 1)
25
25
  handle.instance_eval{ tested < 1 }.should be_false
26
26
  end
27
27
 
28
+ it "should support an attribute called :path" do
29
+ handle.set(:path => 1)
30
+ handle.instance_eval{ path < 1 }.should be_false
31
+ end
32
+
28
33
  describe "compile" do
29
34
 
30
35
  it "should return a Proc when passed a string" do
@@ -35,6 +40,33 @@ module Alf
35
40
  x = lambda{ true }
36
41
  TupleHandle.compile(x).should == x
37
42
  end
43
+
44
+ it "should support an empty Hash" do
45
+ pred = TupleHandle.compile({})
46
+ pred.call.should be_true
47
+ end
48
+
49
+ it "should support a Hash" do
50
+ pred = TupleHandle.compile({:status => 10})
51
+ handle = TupleHandle.new
52
+ handle.set({:status => 20}).evaluate(pred).should be_false
53
+ handle.set({:status => 10}).evaluate(pred).should be_true
54
+ end
55
+
56
+ it "should support a Hash using keywords as attribute names" do
57
+ pred = TupleHandle.compile({:when => 10})
58
+ handle = TupleHandle.new
59
+ handle.set({:when => 20}).evaluate(pred).should be_false
60
+ handle.set({:when => 10}).evaluate(pred).should be_true
61
+ end
62
+
63
+ it "should support a Hash containing a Date" do
64
+ today = Date.today
65
+ pred = TupleHandle.compile({:at => today})
66
+ handle = TupleHandle.new
67
+ handle.set({:at => today}).evaluate(pred).should be_true
68
+ handle.set({:at => today+1}).evaluate(pred).should be_false
69
+ end
38
70
 
39
71
  end
40
72
 
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ module Alf
3
+ describe "Tools#varargs" do
4
+
5
+ specify "with exact args" do
6
+ Tools.varargs([1, "hello"], [Integer, String]).should eq([1, "hello"])
7
+ end
8
+
9
+ specify "with missing args" do
10
+ Tools.varargs(["hello"], [Integer, String]).should eq([nil, "hello"])
11
+ Tools.varargs([], [Integer, String]).should eq([nil, nil])
12
+ Tools.varargs([1, 2], [Integer, String, Integer]).should eq([1, nil, 2])
13
+ end
14
+
15
+ end
16
+ end
@@ -1,36 +1,9 @@
1
- # Installs a rake task for for running examples written using rspec.
2
- #
3
- # This file installs the 'rake spec_test' (aliased as 'rake spec') as well as
4
- # extends 'rake test' to run spec tests, if any. It is automatically generated
5
- # by Noe from your .noespec file, and should therefore be configured there,
6
- # under the variables/rake_tasks/spec_test entry, as illustrated below:
7
- #
8
- # variables:
9
- # rake_tasks:
10
- # spec_test:
11
- # pattern: spec/**/*_spec.rb
12
- # verbose: true
13
- # rspec_opts: [--color, --backtrace]
14
- # ...
15
- #
16
- # If you have specific needs requiring manual intervention on this file,
17
- # don't forget to set safe-override to false in your noe specification:
18
- #
19
- # template-info:
20
- # manifest:
21
- # tasks/spec_test.rake:
22
- # safe-override: false
23
- #
24
- # This file has been written to conform to RSpec v2.4.0. More information about
25
- # rspec and options of the rake task defined below can be found on
26
- # http://relishapp.com/rspec
27
- #
28
1
  begin
29
2
  require "rspec/core/rake_task"
30
3
  desc "Run RSpec code examples"
31
- RSpec::Core::RakeTask.new(:spec_test) do |t|
4
+ RSpec::Core::RakeTask.new(:integration_test) do |t|
32
5
  # Glob pattern to match files.
33
- t.pattern = "spec/**/test_*.rb"
6
+ t.pattern = "spec/integration/**/test_*.rb"
34
7
 
35
8
  # By default, if there is a Gemfile, the generated command will include
36
9
  # 'bundle exec'. Set this to true to ignore the presence of a Gemfile,
@@ -70,10 +43,9 @@ begin
70
43
  t.rspec_opts = ["--color", "--backtrace"]
71
44
  end
72
45
  rescue LoadError => ex
73
- task :spec_test do
46
+ task :integration_test do
74
47
  abort 'rspec is not available. In order to run spec, you must: gem install rspec'
75
48
  end
76
49
  ensure
77
- task :spec => [:spec_test]
78
- task :test => [:spec_test]
50
+ task :test => [:integration_test]
79
51
  end
@@ -0,0 +1,52 @@
1
+ begin
2
+ require "rspec/core/rake_task"
3
+ desc "Run RSpec code examples"
4
+ RSpec::Core::RakeTask.new(:regression_test) do |t|
5
+ # Glob pattern to match files.
6
+ t.pattern = "spec/regression/**/test_*.rb"
7
+
8
+ # By default, if there is a Gemfile, the generated command will include
9
+ # 'bundle exec'. Set this to true to ignore the presence of a Gemfile,
10
+ # and not add 'bundle exec' to the command.
11
+ t.skip_bundler = false
12
+
13
+ # Name of Gemfile to use
14
+ t.gemfile = "Gemfile"
15
+
16
+ # Whether or not to fail Rake when an error occurs (typically when
17
+ # examples fail).
18
+ t.fail_on_error = true
19
+
20
+ # A message to print to stderr when there are failures.
21
+ t.failure_message = nil
22
+
23
+ # Use verbose output. If this is set to true, the task will print the
24
+ # executed spec command to stdout.
25
+ t.verbose = true
26
+
27
+ # Use rcov for code coverage?
28
+ t.rcov = false
29
+
30
+ # Path to rcov.
31
+ t.rcov_path = "rcov"
32
+
33
+ # Command line options to pass to rcov. See 'rcov --help' about this
34
+ t.rcov_opts = []
35
+
36
+ # Command line options to pass to ruby. See 'ruby --help' about this
37
+ t.ruby_opts = []
38
+
39
+ # Path to rspec
40
+ t.rspec_path = "rspec"
41
+
42
+ # Command line options to pass to rspec. See 'rspec --help' about this
43
+ t.rspec_opts = ["--color", "--backtrace"]
44
+ end
45
+ rescue LoadError => ex
46
+ task :regression_test do
47
+ abort 'rspec is not available. In order to run spec, you must: gem install rspec'
48
+ end
49
+ ensure
50
+ task :spec => [:regression_test]
51
+ task :test => [:regression_test]
52
+ end
data/tasks/unit_test.rake CHANGED
@@ -1,77 +1,52 @@
1
- # Installs a rake task for for running unit tests.
2
- #
3
- # This file installs the 'rake unit_test' and extends 'rake test' to run unit
4
- # tests, if any. It is automatically generated by Noe from your .noespec file,
5
- # and should therefore be configured there, under the variables/rake_tasks/unit_test
6
- # entry, as illustrated below:
7
- #
8
- # variables:
9
- # rake_tasks:
10
- # unit_test:
11
- # pattern: test/test*.rb
12
- # verbose: false
13
- # warning: false
14
- # ...
15
- #
16
- # If you have specific needs requiring manual intervention on this file,
17
- # don't forget to set safe-override to false in your noe specification:
18
- #
19
- # template-info:
20
- # manifest:
21
- # tasks/unit_test.rake:
22
- # safe-override: false
23
- #
24
- # More info about the TestTask and its options can be found on
25
- # http://rake.rubyforge.org/classes/Rake/TestTask.html
26
- #
27
1
  begin
28
- require 'rake/testtask'
29
- desc "Run unit tests"
30
- Rake::TestTask.new(:unit_test) do |t|
2
+ require "rspec/core/rake_task"
3
+ desc "Run RSpec code examples"
4
+ RSpec::Core::RakeTask.new(:unit_test) do |t|
5
+ # Glob pattern to match files.
6
+ t.pattern = "spec/unit/**/test_*.rb"
31
7
 
32
- # List of directories to added to $LOAD_PATH before running the
33
- # tests. (default is 'lib')
34
- t.libs = ["lib"]
8
+ # By default, if there is a Gemfile, the generated command will include
9
+ # 'bundle exec'. Set this to true to ignore the presence of a Gemfile,
10
+ # and not add 'bundle exec' to the command.
11
+ t.skip_bundler = false
35
12
 
36
- # True if verbose test output desired. (default is false)
37
- t.verbose = false
13
+ # Name of Gemfile to use
14
+ t.gemfile = "Gemfile"
38
15
 
39
- # Test options passed to the test suite. An explicit TESTOPTS=opts
40
- # on the command line will override this. (default is NONE)
41
- t.options = nil
16
+ # Whether or not to fail Rake when an error occurs (typically when
17
+ # examples fail).
18
+ t.fail_on_error = true
42
19
 
43
- # Request that the tests be run with the warning flag set.
44
- # E.g. warning=true implies "ruby -w" used to run the tests.
45
- t.warning = false
20
+ # A message to print to stderr when there are failures.
21
+ t.failure_message = nil
46
22
 
47
- # Glob pattern to match test files. (default is 'test/test*.rb')
48
- t.pattern = "test/test*.rb"
23
+ # Use verbose output. If this is set to true, the task will print the
24
+ # executed spec command to stdout.
25
+ t.verbose = true
49
26
 
50
- # Style of test loader to use. Options are:
51
- #
52
- # * :rake -- Rake provided test loading script (default).
53
- # * :testrb -- Ruby provided test loading script.
54
- # * :direct -- Load tests using command line loader.
55
- #
56
- t.loader = :rake
27
+ # Use rcov for code coverage?
28
+ t.rcov = false
57
29
 
58
- # Array of commandline options to pass to ruby when running test
59
- # loader.
30
+ # Path to rcov.
31
+ t.rcov_path = "rcov"
32
+
33
+ # Command line options to pass to rcov. See 'rcov --help' about this
34
+ t.rcov_opts = []
35
+
36
+ # Command line options to pass to ruby. See 'ruby --help' about this
60
37
  t.ruby_opts = []
61
38
 
62
- # Explicitly define the list of test files to be included in a
63
- # test. +list+ is expected to be an array of file names (a
64
- # FileList is acceptable). If both +pattern+ and +test_files+ are
65
- # used, then the list of test files is the union of the two.
66
- t.test_files = nil
39
+ # Path to rspec
40
+ t.rspec_path = "rspec"
67
41
 
42
+ # Command line options to pass to rspec. See 'rspec --help' about this
43
+ t.rspec_opts = ["--color", "--backtrace"]
68
44
  end
69
45
  rescue LoadError => ex
70
46
  task :unit_test do
71
47
  abort 'rspec is not available. In order to run spec, you must: gem install rspec'
72
48
  end
73
49
  ensure
74
- desc "Run all tests"
50
+ task :spec => [:unit_test]
75
51
  task :test => [:unit_test]
76
52
  end
77
-