riot 0.10.12.pre → 0.10.12

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 (35) hide show
  1. data/CHANGELOG +5 -7
  2. data/Rakefile +22 -18
  3. data/VERSION +1 -1
  4. data/lib/riot/assertion.rb +4 -2
  5. data/lib/riot/assertion_macro.rb +3 -1
  6. data/lib/riot/message.rb +1 -1
  7. data/lib/riot/reporter.rb +20 -8
  8. data/riot.gemspec +50 -50
  9. data/test/benchmark/message_concatenation.rb +1 -1
  10. data/test/{assertion_macro_test.rb → core/assertion_macro_test.rb} +16 -0
  11. data/test/{assertion_macros → core/assertion_macros}/any_test.rb +0 -0
  12. data/test/{assertion_macros → core/assertion_macros}/assigns_test.rb +0 -0
  13. data/test/{assertion_macros → core/assertion_macros}/empty_test.rb +0 -0
  14. data/test/{assertion_macros → core/assertion_macros}/equals_test.rb +3 -3
  15. data/test/{assertion_macros → core/assertion_macros}/equivalent_to_test.rb +2 -2
  16. data/test/{assertion_macros → core/assertion_macros}/exists_test.rb +1 -1
  17. data/test/{assertion_macros → core/assertion_macros}/includes_test.rb +0 -0
  18. data/test/core/assertion_macros/kind_of_test.rb +15 -0
  19. data/test/{assertion_macros → core/assertion_macros}/matching_test.rb +0 -0
  20. data/test/{assertion_macros → core/assertion_macros}/nil_test.rb +1 -1
  21. data/test/{assertion_macros → core/assertion_macros}/not_borat_test.rb +0 -0
  22. data/test/{assertion_macros → core/assertion_macros}/raises_test.rb +0 -0
  23. data/test/{assertion_macros → core/assertion_macros}/respond_to_test.rb +0 -0
  24. data/test/{assertion_macros → core/assertion_macros}/same_elements_test.rb +0 -0
  25. data/test/{assertion_macros → core/assertion_macros}/size_test.rb +0 -0
  26. data/test/{assertion_test.rb → core/assertion_test.rb} +2 -2
  27. data/test/{context_test.rb → core/context_test.rb} +0 -0
  28. data/test/{message_test.rb → core/message_test.rb} +0 -0
  29. data/test/{report_test.rb → core/report_test.rb} +10 -4
  30. data/test/{setup_test.rb → core/setup_test.rb} +0 -0
  31. data/test/{situation_test.rb → core/situation_test.rb} +0 -0
  32. data/test/{teardown_test.rb → core/teardown_test.rb} +0 -0
  33. data/test/teststrap.rb +2 -2
  34. metadata +50 -50
  35. data/test/assertion_macros/kind_of_test.rb +0 -17
data/CHANGELOG CHANGED
@@ -1,18 +1,16 @@
1
- *0.10.12.pre*
1
+ *0.10.12*
2
+
3
+ * Recognizing file and line number of an assertion declaration on failure [vandrijevik]
2
4
 
3
5
  * RR support in Riot [vandrijevik,jaknowlden]
4
6
 
5
7
  # teststrap.rb
6
8
  require 'riot'
7
- Riot.rr
9
+ require 'riot/rr'
8
10
 
9
11
  # your-test.rb
10
12
  context "foo" do
11
- setup do
12
- mock!.hello {"world"}
13
- end
14
-
15
- asserts("failure due to not calling hello") { true } # actually fails
13
+ asserts("failure due to not calling hello") { mock!.hello {"world"} } # actually fails
16
14
  end
17
15
 
18
16
  * Added Riot::Message to make messages in macros easier to write [jaknowlden]
data/Rakefile CHANGED
@@ -1,20 +1,13 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- task :default => ["test:core", "test:assertion_macros"]
5
- task "test:all" => ["test:core", "test:assertion_macros", "test:extensions"]
4
+ task :default => ["test:core"]
5
+ task "test:all" => ["test:core", "test:extensions"]
6
6
 
7
7
  require 'rake/testtask'
8
8
  Rake::TestTask.new("test:core") do |test|
9
9
  test.libs << 'test'
10
- test.pattern = 'test/*_test.rb'
11
- test.warning = true
12
- test.verbose = false
13
- end
14
-
15
- Rake::TestTask.new("test:assertion_macros") do |test|
16
- test.libs << 'test'
17
- test.pattern = 'test/assertion_macros/*_test.rb'
10
+ test.pattern = 'test/core/**/*_test.rb'
18
11
  test.warning = true
19
12
  test.verbose = false
20
13
  end
@@ -26,6 +19,25 @@ Rake::TestTask.new("test:extensions") do |test|
26
19
  test.verbose = false
27
20
  end
28
21
 
22
+ #
23
+ # Benchmarks
24
+
25
+ def run_benchmarks(bin)
26
+ Dir["test/benchmark/*.rb"].each do |file|
27
+ puts ">> Running #{file}"
28
+ puts %x[#{bin} #{file}]
29
+ end
30
+ end
31
+
32
+ desc "Run all of them fancy benchmarks, Howard!"
33
+ task("test:benchmarks") { run_benchmarks("ruby") }
34
+
35
+ desc "Run all of them fancy benchmarks in ruby-1.9, Steve!"
36
+ task("test:benchmarks:1.9") { run_benchmarks("ruby1.9") }
37
+
38
+ #
39
+ # YARDie
40
+
29
41
  begin
30
42
  require 'yard'
31
43
  require 'yard/rake/yardoc_task'
@@ -38,14 +50,6 @@ rescue LoadError
38
50
  # YARD isn't installed
39
51
  end
40
52
 
41
- desc "Run all of them fancy benchmarks, Howard!"
42
- task :benchmarks do
43
- Dir["test/benchmark/*.rb"].each do |file|
44
- puts ">> Running #{file}"
45
- puts %x[ruby #{file}]
46
- end
47
- end
48
-
49
53
  #
50
54
  # Some monks like diamonds. I like gems.
51
55
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.12.pre
1
+ 0.10.12
@@ -4,7 +4,7 @@ module Riot
4
4
  def macros; @@macros ||= {}; end
5
5
 
6
6
  def register_macro(name, assertion_macro, expect_exception=false)
7
- macros[name.to_s] = assertion_macro.new
7
+ macros[name.to_s] = assertion_macro
8
8
  end
9
9
  end
10
10
 
@@ -23,8 +23,10 @@ module Riot
23
23
  end
24
24
  private
25
25
  def enhance_with_macro(name, *expectings, &expectation_block)
26
- @macro, @expectings, @expectation_block = self.class.macros[name.to_s], expectings, expectation_block
26
+ @expectings, @expectation_block = expectings, expectation_block
27
+ @macro = self.class.macros[name.to_s].new
27
28
  raise(NoMethodError, name) unless @macro
29
+ @macro.file, @macro.line = caller.first.match(/(.*):(\d+)/)[1..2]
28
30
  self
29
31
  end
30
32
  alias :method_missing :enhance_with_macro
@@ -47,8 +47,10 @@ module Riot
47
47
  end
48
48
  end
49
49
 
50
+ attr_accessor :line, :file
51
+
50
52
  def pass(message=nil) [:pass, message.to_s]; end
51
- def fail(message) [:fail, message.to_s]; end
53
+ def fail(message) [:fail, message.to_s, line, file]; end
52
54
  def error(e) [:error, e]; end
53
55
 
54
56
  def expects_exception?; self.class.expects_exception; end
@@ -1,5 +1,5 @@
1
1
  class BlankSlate
2
- instance_methods.each { |meth| undef_method(meth) unless meth =~ /^__/ }
2
+ instance_methods.each { |meth| undef_method(meth) unless meth.to_s =~ /^(__|object_id)/ }
3
3
  end
4
4
 
5
5
  module Riot
@@ -24,7 +24,8 @@ module Riot
24
24
  pass(description, result)
25
25
  when :fail then
26
26
  @failures += 1
27
- fail(description, result)
27
+ message, line, file = *response[1..-1]
28
+ fail(description, message, line, file)
28
29
  when :error then
29
30
  @errors += 1
30
31
  error(description, result)
@@ -44,6 +45,10 @@ module Riot
44
45
  def puts(message) @writer.puts(message); end
45
46
  def print(message) @writer.print(message); end
46
47
 
48
+ def line_info(line, file)
49
+ line ? "(on line #{line} in #{file})" : ""
50
+ end
51
+
47
52
  def results(time_taken)
48
53
  values = [passes, failures, errors, ("%0.6f" % time_taken)]
49
54
  puts "\n%d passes, %d failures, %d errors in %s seconds" % values
@@ -76,7 +81,11 @@ module Riot
76
81
  puts context.description
77
82
  end
78
83
  def pass(description, message) puts " + " + green("#{description} #{message}".strip); end
79
- def fail(description, message) puts " - " + yellow("#{description}: #{message}"); end
84
+
85
+ def fail(description, message, line, file)
86
+ puts " - " + yellow("#{description}: #{message} #{line_info(line, file)}".strip)
87
+ end
88
+
80
89
  def error(description, e) puts " ! " + red("#{description}: #{e.message}"); end
81
90
  end
82
91
 
@@ -97,26 +106,29 @@ module Riot
97
106
  print green(".")
98
107
  end
99
108
 
100
- def fail(description, message)
109
+ def fail(description, message, line, file)
101
110
  print yellow("F")
102
- @details << "FAILURE - #{current_context.description} #{description} => #{message}"
111
+ @details << "FAILURE - #{test_detail(description, message)} #{line_info(line, file)}".strip
103
112
  end
104
113
 
105
114
  def error(description, e)
106
115
  print red("E")
107
- @details << "ERROR - #{current_context.description} #{description} => #{format_error(e)}"
116
+ @details << "ERROR - #{test_detail(description, format_error(e))}"
108
117
  end
109
118
 
110
119
  def results(time_taken)
111
- puts "\n" unless @details.empty?
112
- @details.each { |detail| puts detail }
120
+ puts "\n#{@details.join("\n\n")}" unless @details.empty?
113
121
  super
114
122
  end
123
+ private
124
+ def test_detail(description, message)
125
+ "#{current_context.description} #{description} => #{message}"
126
+ end
115
127
  end
116
128
 
117
129
  class SilentReporter < Reporter
118
130
  def pass(description, message); end
119
- def fail(description, message); end
131
+ def fail(description, message, line, file); end
120
132
  def error(description, e); end
121
133
  def results(time_taken); end
122
134
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{riot}
8
- s.version = "0.10.12.pre"
8
+ s.version = "0.10.12"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin 'Gus' Knowlden"]
12
- s.date = %q{2010-02-09}
12
+ s.date = %q{2010-02-11}
13
13
  s.description = %q{An extremely fast, expressive, and context-driven unit-testing framework. A replacement for all other testing frameworks. Protest the slow test.}
14
14
  s.email = %q{gus@gusg.us}
15
15
  s.extra_rdoc_files = [
@@ -48,35 +48,35 @@ Gem::Specification.new do |s|
48
48
  "lib/riot/runnable.rb",
49
49
  "lib/riot/situation.rb",
50
50
  "riot.gemspec",
51
- "test/assertion_macro_test.rb",
52
- "test/assertion_macros/any_test.rb",
53
- "test/assertion_macros/assigns_test.rb",
54
- "test/assertion_macros/empty_test.rb",
55
- "test/assertion_macros/equals_test.rb",
56
- "test/assertion_macros/equivalent_to_test.rb",
57
- "test/assertion_macros/exists_test.rb",
58
- "test/assertion_macros/includes_test.rb",
59
- "test/assertion_macros/kind_of_test.rb",
60
- "test/assertion_macros/matching_test.rb",
61
- "test/assertion_macros/nil_test.rb",
62
- "test/assertion_macros/not_borat_test.rb",
63
- "test/assertion_macros/raises_test.rb",
64
- "test/assertion_macros/respond_to_test.rb",
65
- "test/assertion_macros/same_elements_test.rb",
66
- "test/assertion_macros/size_test.rb",
67
- "test/assertion_test.rb",
68
51
  "test/benchmark/colorize.rb",
69
52
  "test/benchmark/message_concatenation.rb",
70
53
  "test/benchmark/riot_vs_minitest.rb",
71
54
  "test/benchmark/same_elements_vs_set.rb",
72
55
  "test/benchmark/simple_context_and_assertions.rb",
73
- "test/context_test.rb",
56
+ "test/core/assertion_macro_test.rb",
57
+ "test/core/assertion_macros/any_test.rb",
58
+ "test/core/assertion_macros/assigns_test.rb",
59
+ "test/core/assertion_macros/empty_test.rb",
60
+ "test/core/assertion_macros/equals_test.rb",
61
+ "test/core/assertion_macros/equivalent_to_test.rb",
62
+ "test/core/assertion_macros/exists_test.rb",
63
+ "test/core/assertion_macros/includes_test.rb",
64
+ "test/core/assertion_macros/kind_of_test.rb",
65
+ "test/core/assertion_macros/matching_test.rb",
66
+ "test/core/assertion_macros/nil_test.rb",
67
+ "test/core/assertion_macros/not_borat_test.rb",
68
+ "test/core/assertion_macros/raises_test.rb",
69
+ "test/core/assertion_macros/respond_to_test.rb",
70
+ "test/core/assertion_macros/same_elements_test.rb",
71
+ "test/core/assertion_macros/size_test.rb",
72
+ "test/core/assertion_test.rb",
73
+ "test/core/context_test.rb",
74
+ "test/core/message_test.rb",
75
+ "test/core/report_test.rb",
76
+ "test/core/setup_test.rb",
77
+ "test/core/situation_test.rb",
78
+ "test/core/teardown_test.rb",
74
79
  "test/extensions/rrriot_test.rb",
75
- "test/message_test.rb",
76
- "test/report_test.rb",
77
- "test/setup_test.rb",
78
- "test/situation_test.rb",
79
- "test/teardown_test.rb",
80
80
  "test/teststrap.rb"
81
81
  ]
82
82
  s.homepage = %q{http://github.com/thumblemonks/riot}
@@ -85,35 +85,35 @@ Gem::Specification.new do |s|
85
85
  s.rubygems_version = %q{1.3.5}
86
86
  s.summary = %q{An extremely fast, expressive, and context-driven unit-testing framework. Protest the slow test.}
87
87
  s.test_files = [
88
- "test/assertion_macro_test.rb",
89
- "test/assertion_macros/any_test.rb",
90
- "test/assertion_macros/assigns_test.rb",
91
- "test/assertion_macros/empty_test.rb",
92
- "test/assertion_macros/equals_test.rb",
93
- "test/assertion_macros/equivalent_to_test.rb",
94
- "test/assertion_macros/exists_test.rb",
95
- "test/assertion_macros/includes_test.rb",
96
- "test/assertion_macros/kind_of_test.rb",
97
- "test/assertion_macros/matching_test.rb",
98
- "test/assertion_macros/nil_test.rb",
99
- "test/assertion_macros/not_borat_test.rb",
100
- "test/assertion_macros/raises_test.rb",
101
- "test/assertion_macros/respond_to_test.rb",
102
- "test/assertion_macros/same_elements_test.rb",
103
- "test/assertion_macros/size_test.rb",
104
- "test/assertion_test.rb",
105
- "test/benchmark/colorize.rb",
88
+ "test/benchmark/colorize.rb",
106
89
  "test/benchmark/message_concatenation.rb",
107
90
  "test/benchmark/riot_vs_minitest.rb",
108
91
  "test/benchmark/same_elements_vs_set.rb",
109
92
  "test/benchmark/simple_context_and_assertions.rb",
110
- "test/context_test.rb",
93
+ "test/core/assertion_macro_test.rb",
94
+ "test/core/assertion_macros/any_test.rb",
95
+ "test/core/assertion_macros/assigns_test.rb",
96
+ "test/core/assertion_macros/empty_test.rb",
97
+ "test/core/assertion_macros/equals_test.rb",
98
+ "test/core/assertion_macros/equivalent_to_test.rb",
99
+ "test/core/assertion_macros/exists_test.rb",
100
+ "test/core/assertion_macros/includes_test.rb",
101
+ "test/core/assertion_macros/kind_of_test.rb",
102
+ "test/core/assertion_macros/matching_test.rb",
103
+ "test/core/assertion_macros/nil_test.rb",
104
+ "test/core/assertion_macros/not_borat_test.rb",
105
+ "test/core/assertion_macros/raises_test.rb",
106
+ "test/core/assertion_macros/respond_to_test.rb",
107
+ "test/core/assertion_macros/same_elements_test.rb",
108
+ "test/core/assertion_macros/size_test.rb",
109
+ "test/core/assertion_test.rb",
110
+ "test/core/context_test.rb",
111
+ "test/core/message_test.rb",
112
+ "test/core/report_test.rb",
113
+ "test/core/setup_test.rb",
114
+ "test/core/situation_test.rb",
115
+ "test/core/teardown_test.rb",
111
116
  "test/extensions/rrriot_test.rb",
112
- "test/message_test.rb",
113
- "test/report_test.rb",
114
- "test/setup_test.rb",
115
- "test/situation_test.rb",
116
- "test/teardown_test.rb",
117
117
  "test/teststrap.rb"
118
118
  ]
119
119
 
@@ -1,7 +1,7 @@
1
1
  require 'benchmark'
2
2
 
3
3
  class BlankSlate
4
- instance_methods.each { |meth| undef_method(meth) unless meth =~ /^__/ }
4
+ instance_methods.each { |meth| undef_method(meth) unless meth.to_s =~ /^(__|object_id)/ }
5
5
  end
6
6
 
7
7
  class NormalMessage < BlankSlate
@@ -6,6 +6,10 @@ context "An AssertionMacro instance" do
6
6
  asserts_topic.responds_to(:new_message)
7
7
  asserts_topic.responds_to(:expected_message)
8
8
  asserts_topic.responds_to(:should_have_message)
9
+ asserts_topic.responds_to(:line)
10
+ asserts_topic.responds_to(:line=)
11
+ asserts_topic.responds_to(:file)
12
+ asserts_topic.responds_to(:file=)
9
13
 
10
14
  context "receiving #new_message" do
11
15
  setup { topic.new_message("hope") }
@@ -28,3 +32,15 @@ context "An AssertionMacro instance" do
28
32
  asserts(:to_s).equals(%q[expected "hope"])
29
33
  end
30
34
  end # An AssertionMacro instance
35
+
36
+ context "AssertionMacro#fail" do
37
+ setup do
38
+ macro = Riot::AssertionMacro.new
39
+ macro.line = 5
40
+ macro.file = "foo"
41
+ macro.fail("")
42
+ end
43
+
44
+ asserts_topic.includes(5)
45
+ asserts_topic.includes("foo")
46
+ end # AssertionMacro#fail
@@ -16,7 +16,7 @@ context "An equals assertion macro" do
16
16
  setup { topic.equals("bar").run(Riot::Situation.new) }
17
17
 
18
18
  asserts(":fail") { topic.first == :fail }
19
- asserts("message") { topic.last == %Q{expected "bar", not "foo"} }
19
+ asserts("message") { topic[1] == %Q{expected "bar", not "foo"} }
20
20
  end # that is failing
21
21
 
22
22
  context "with numeric topic" do
@@ -25,7 +25,7 @@ context "An equals assertion macro" do
25
25
  end
26
26
 
27
27
  asserts("failure") do
28
- topic.equals(30000..32000).run(Riot::Situation.new) == [:fail, "expected 30000..32000, not 31415"]
28
+ topic.equals(30000..32000).run(Riot::Situation.new)[0..1] == [:fail, "expected 30000..32000, not 31415"]
29
29
  end
30
30
  end # with numeric topic
31
31
 
@@ -35,7 +35,7 @@ context "An equals assertion macro" do
35
35
  end.equals([:pass, %Q{is equal to "foo"}])
36
36
 
37
37
  asserts(":fail with message when block expectation not met") do
38
- topic.equals { "bar" }.run(Riot::Situation.new)
38
+ topic.equals { "bar" }.run(Riot::Situation.new)[0..1]
39
39
  end.equals([:fail, %Q{expected "bar", not "foo"}])
40
40
  end # with block as the expectation
41
41
 
@@ -13,7 +13,7 @@ context "An equivalent_to assertion macro" do
13
13
  end
14
14
 
15
15
  asserts("an array is not equivalent to 'what'") do
16
- topic.equivalent_to([]).run(Riot::Situation.new) == [:fail, %Q{expected "what" to be equivalent to []}]
16
+ topic.equivalent_to([]).run(Riot::Situation.new)[0..1] == [:fail, %Q{expected "what" to be equivalent to []}]
17
17
  end
18
18
 
19
19
  context "with numeric topic" do
@@ -29,7 +29,7 @@ context "An equivalent_to assertion macro" do
29
29
  setup { topic.equivalent_to(32000..33000).run(Riot::Situation.new) }
30
30
 
31
31
  asserts(":fail") { topic.first == :fail }
32
- asserts("message") { topic.last == %Q{expected 31413 to be equivalent to 32000..33000} }
32
+ asserts("message") { topic[1] == %Q{expected 31413 to be equivalent to 32000..33000} }
33
33
  end
34
34
  end # with numeric topic
35
35
 
@@ -12,6 +12,6 @@ context "An exists assertion macro" do
12
12
  end.equals([:pass, "is not nil"])
13
13
 
14
14
  asserts(":fail with message when value is nil") do
15
- Riot::Assertion.new("foo") { nil }.exists.run(topic)
15
+ Riot::Assertion.new("foo") { nil }.exists.run(topic)[0..1]
16
16
  end.equals([:fail, "expected a non-nil value"])
17
17
  end # An exists assertion macro
@@ -0,0 +1,15 @@
1
+ require 'teststrap'
2
+
3
+ context "A kind_of assertion macro" do
4
+ assertion_test_passes(":pass when specific result is a kind of String", "is a kind of String") do
5
+ Riot::Assertion.new("foo") { "a" }.kind_of(String)
6
+ end
7
+
8
+ assertion_test_fails(":fail when not a kind of String", "expected kind of String, not Fixnum") do
9
+ Riot::Assertion.new("foo") { 0 }.kind_of(String)
10
+ end
11
+
12
+ assertion_test_fails(":fail when nil", "expected kind of String, not NilClass") do
13
+ Riot::Assertion.new("foo") { }.kind_of(String)
14
+ end
15
+ end # A kind_of assertion macro
@@ -8,6 +8,6 @@ context "A nil assertion macro" do
8
8
  end.equals([:pass, "is nil"])
9
9
 
10
10
  asserts(":fail with message") do
11
- Riot::Assertion.new("foo") { "a" }.nil.run(topic)
11
+ Riot::Assertion.new("foo") { "a" }.nil.run(topic)[0..1]
12
12
  end.equals([:fail, %Q{expected nil, not "a"}])
13
13
  end # A nil assertion macro
@@ -15,8 +15,8 @@ context "An assertion" do
15
15
  asserts("to_s") { topic.to_s == "foo" }
16
16
 
17
17
  asserts(":fail and message are evaluated") do
18
- topic.run(Riot::Situation.new) == [:fail, "Expected non-false but got nil instead"]
19
- end
18
+ topic.run(Riot::Situation.new)[0..1]
19
+ end.equals([:fail, "Expected non-false but got nil instead"])
20
20
  end # that is failing
21
21
 
22
22
  context "that is erroring" do
@@ -4,7 +4,7 @@ context "A reporter" do
4
4
  setup do
5
5
  Class.new(Riot::Reporter) do
6
6
  def pass(d, message) "passed(#{d}, #{message.inspect})"; end
7
- def fail(d, message) "failed(#{d}, #{message})"; end
7
+ def fail(d, message, line, file) "failed(#{d}, #{message} on line #{line} in file #{file})"; end
8
8
  def error(d, e) "errored(#{d}, #{e})"; end
9
9
  def results(time); end
10
10
  end.new
@@ -28,9 +28,9 @@ context "A reporter" do
28
28
  topic.failures
29
29
  end.equals(1)
30
30
 
31
- asserts("description and message sent to #fail") do
32
- topic.report("hi mom", [:fail, "how are you"])
33
- end.equals("failed(hi mom, how are you)")
31
+ asserts("description, message, line and file sent to #fail") do
32
+ topic.report("hi mom", [:fail, "how are you", 4, "foo"])
33
+ end.equals("failed(hi mom, how are you on line 4 in file foo)")
34
34
 
35
35
  # error
36
36
 
@@ -76,6 +76,12 @@ context "StoryReporter" do
76
76
  ColorHelper.uncolored(@out.string)
77
77
  end.equals(" + foo\n")
78
78
 
79
+ asserts("failure message excludes line info if none provided") do
80
+ @out.rewind
81
+ topic.fail("foo", "bar", nil, nil)
82
+ ColorHelper.uncolored(@out.string)
83
+ end.equals(" - foo: bar\n")
84
+
79
85
  context 'reporting on an empty context' do
80
86
  setup do
81
87
  context = Riot::Context.new('empty context') do
@@ -20,7 +20,7 @@ module Riot
20
20
  context(description) do
21
21
  setup(&block)
22
22
  asserts("failure") { topic.run(Riot::Situation.new).first }.equals(:fail)
23
- asserts("failure message") { topic.run(Riot::Situation.new).last }.equals(failure_message)
23
+ asserts("failure message") { topic.run(Riot::Situation.new)[1] }.equals(failure_message)
24
24
  end
25
25
  end
26
26
 
@@ -31,7 +31,7 @@ Riot::Context.instance_eval { include Riot::AssertionTestContextMacros }
31
31
 
32
32
  class MockReporter < Riot::Reporter
33
33
  def pass(description, message); end
34
- def fail(description, message); end
34
+ def fail(description, message, line, file); end
35
35
  def error(description, e); end
36
36
  def results; end
37
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.12.pre
4
+ version: 0.10.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin 'Gus' Knowlden
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-09 00:00:00 -06:00
12
+ date: 2010-02-11 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -73,35 +73,35 @@ files:
73
73
  - lib/riot/runnable.rb
74
74
  - lib/riot/situation.rb
75
75
  - riot.gemspec
76
- - test/assertion_macro_test.rb
77
- - test/assertion_macros/any_test.rb
78
- - test/assertion_macros/assigns_test.rb
79
- - test/assertion_macros/empty_test.rb
80
- - test/assertion_macros/equals_test.rb
81
- - test/assertion_macros/equivalent_to_test.rb
82
- - test/assertion_macros/exists_test.rb
83
- - test/assertion_macros/includes_test.rb
84
- - test/assertion_macros/kind_of_test.rb
85
- - test/assertion_macros/matching_test.rb
86
- - test/assertion_macros/nil_test.rb
87
- - test/assertion_macros/not_borat_test.rb
88
- - test/assertion_macros/raises_test.rb
89
- - test/assertion_macros/respond_to_test.rb
90
- - test/assertion_macros/same_elements_test.rb
91
- - test/assertion_macros/size_test.rb
92
- - test/assertion_test.rb
93
76
  - test/benchmark/colorize.rb
94
77
  - test/benchmark/message_concatenation.rb
95
78
  - test/benchmark/riot_vs_minitest.rb
96
79
  - test/benchmark/same_elements_vs_set.rb
97
80
  - test/benchmark/simple_context_and_assertions.rb
98
- - test/context_test.rb
81
+ - test/core/assertion_macro_test.rb
82
+ - test/core/assertion_macros/any_test.rb
83
+ - test/core/assertion_macros/assigns_test.rb
84
+ - test/core/assertion_macros/empty_test.rb
85
+ - test/core/assertion_macros/equals_test.rb
86
+ - test/core/assertion_macros/equivalent_to_test.rb
87
+ - test/core/assertion_macros/exists_test.rb
88
+ - test/core/assertion_macros/includes_test.rb
89
+ - test/core/assertion_macros/kind_of_test.rb
90
+ - test/core/assertion_macros/matching_test.rb
91
+ - test/core/assertion_macros/nil_test.rb
92
+ - test/core/assertion_macros/not_borat_test.rb
93
+ - test/core/assertion_macros/raises_test.rb
94
+ - test/core/assertion_macros/respond_to_test.rb
95
+ - test/core/assertion_macros/same_elements_test.rb
96
+ - test/core/assertion_macros/size_test.rb
97
+ - test/core/assertion_test.rb
98
+ - test/core/context_test.rb
99
+ - test/core/message_test.rb
100
+ - test/core/report_test.rb
101
+ - test/core/setup_test.rb
102
+ - test/core/situation_test.rb
103
+ - test/core/teardown_test.rb
99
104
  - test/extensions/rrriot_test.rb
100
- - test/message_test.rb
101
- - test/report_test.rb
102
- - test/setup_test.rb
103
- - test/situation_test.rb
104
- - test/teardown_test.rb
105
105
  - test/teststrap.rb
106
106
  has_rdoc: true
107
107
  homepage: http://github.com/thumblemonks/riot
@@ -120,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
120
  version:
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ">"
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
- version: 1.3.1
125
+ version: "0"
126
126
  version:
127
127
  requirements: []
128
128
 
@@ -132,33 +132,33 @@ signing_key:
132
132
  specification_version: 3
133
133
  summary: An extremely fast, expressive, and context-driven unit-testing framework. Protest the slow test.
134
134
  test_files:
135
- - test/assertion_macro_test.rb
136
- - test/assertion_macros/any_test.rb
137
- - test/assertion_macros/assigns_test.rb
138
- - test/assertion_macros/empty_test.rb
139
- - test/assertion_macros/equals_test.rb
140
- - test/assertion_macros/equivalent_to_test.rb
141
- - test/assertion_macros/exists_test.rb
142
- - test/assertion_macros/includes_test.rb
143
- - test/assertion_macros/kind_of_test.rb
144
- - test/assertion_macros/matching_test.rb
145
- - test/assertion_macros/nil_test.rb
146
- - test/assertion_macros/not_borat_test.rb
147
- - test/assertion_macros/raises_test.rb
148
- - test/assertion_macros/respond_to_test.rb
149
- - test/assertion_macros/same_elements_test.rb
150
- - test/assertion_macros/size_test.rb
151
- - test/assertion_test.rb
152
135
  - test/benchmark/colorize.rb
153
136
  - test/benchmark/message_concatenation.rb
154
137
  - test/benchmark/riot_vs_minitest.rb
155
138
  - test/benchmark/same_elements_vs_set.rb
156
139
  - test/benchmark/simple_context_and_assertions.rb
157
- - test/context_test.rb
140
+ - test/core/assertion_macro_test.rb
141
+ - test/core/assertion_macros/any_test.rb
142
+ - test/core/assertion_macros/assigns_test.rb
143
+ - test/core/assertion_macros/empty_test.rb
144
+ - test/core/assertion_macros/equals_test.rb
145
+ - test/core/assertion_macros/equivalent_to_test.rb
146
+ - test/core/assertion_macros/exists_test.rb
147
+ - test/core/assertion_macros/includes_test.rb
148
+ - test/core/assertion_macros/kind_of_test.rb
149
+ - test/core/assertion_macros/matching_test.rb
150
+ - test/core/assertion_macros/nil_test.rb
151
+ - test/core/assertion_macros/not_borat_test.rb
152
+ - test/core/assertion_macros/raises_test.rb
153
+ - test/core/assertion_macros/respond_to_test.rb
154
+ - test/core/assertion_macros/same_elements_test.rb
155
+ - test/core/assertion_macros/size_test.rb
156
+ - test/core/assertion_test.rb
157
+ - test/core/context_test.rb
158
+ - test/core/message_test.rb
159
+ - test/core/report_test.rb
160
+ - test/core/setup_test.rb
161
+ - test/core/situation_test.rb
162
+ - test/core/teardown_test.rb
158
163
  - test/extensions/rrriot_test.rb
159
- - test/message_test.rb
160
- - test/report_test.rb
161
- - test/setup_test.rb
162
- - test/situation_test.rb
163
- - test/teardown_test.rb
164
164
  - test/teststrap.rb
@@ -1,17 +0,0 @@
1
- require 'teststrap'
2
-
3
- context "A kind_of assertion macro" do
4
- setup { Riot::Situation.new }
5
-
6
- asserts ":pass when specific result is a kind of String" do
7
- Riot::Assertion.new("foo") { "a" }.kind_of(String).run(topic)
8
- end.equals([:pass, %Q{is a kind of String}])
9
-
10
- asserts ":fail when not a kind of String" do
11
- Riot::Assertion.new("foo") { 0 }.kind_of(String).run(topic)
12
- end.equals([:fail, %Q{expected kind of String, not Fixnum}])
13
-
14
- asserts ":fail when nil" do
15
- Riot::Assertion.new("foo") { }.kind_of(String).run(topic)
16
- end.equals([:fail, %Q{expected kind of String, not NilClass}])
17
- end # A kind_of assertion macro