riot 0.12.1 → 0.12.2

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 (62) hide show
  1. data/.gitignore +10 -0
  2. data/.yardopts +6 -0
  3. data/CHANGELOG +58 -46
  4. data/Gemfile +4 -0
  5. data/README.markdown +322 -85
  6. data/Rakefile +3 -38
  7. data/lib/riot.rb +74 -11
  8. data/lib/riot/assertion.rb +32 -1
  9. data/lib/riot/assertion_macro.rb +57 -10
  10. data/lib/riot/assertion_macros/any.rb +4 -2
  11. data/lib/riot/assertion_macros/assigns.rb +18 -4
  12. data/lib/riot/assertion_macros/empty.rb +2 -0
  13. data/lib/riot/assertion_macros/equals.rb +4 -0
  14. data/lib/riot/assertion_macros/equivalent_to.rb +5 -1
  15. data/lib/riot/assertion_macros/exists.rb +4 -2
  16. data/lib/riot/assertion_macros/includes.rb +5 -1
  17. data/lib/riot/assertion_macros/kind_of.rb +5 -1
  18. data/lib/riot/assertion_macros/matches.rb +5 -1
  19. data/lib/riot/assertion_macros/nil.rb +3 -1
  20. data/lib/riot/assertion_macros/not_borat.rb +6 -0
  21. data/lib/riot/assertion_macros/raises.rb +13 -7
  22. data/lib/riot/assertion_macros/respond_to.rb +5 -1
  23. data/lib/riot/assertion_macros/same_elements.rb +6 -2
  24. data/lib/riot/assertion_macros/size.rb +5 -1
  25. data/lib/riot/context.rb +58 -10
  26. data/lib/riot/context_helpers.rb +20 -4
  27. data/lib/riot/context_options.rb +14 -4
  28. data/lib/riot/message.rb +87 -6
  29. data/lib/riot/middleware.rb +69 -4
  30. data/lib/riot/reporter.rb +71 -110
  31. data/lib/riot/reporter/dot_matrix.rb +49 -0
  32. data/lib/riot/reporter/io.rb +85 -0
  33. data/lib/riot/reporter/pretty_dot_matrix.rb +38 -0
  34. data/lib/riot/reporter/silent.rb +18 -0
  35. data/lib/riot/reporter/story.rb +52 -0
  36. data/lib/riot/rr.rb +28 -4
  37. data/lib/riot/runnable.rb +53 -0
  38. data/lib/riot/situation.rb +45 -0
  39. data/lib/riot/version.rb +4 -0
  40. data/riot.gemspec +14 -155
  41. data/test/core/assertion_macros/any_test.rb +10 -10
  42. data/test/core/assertion_macros/assigns_test.rb +7 -7
  43. data/test/core/assertion_macros/equivalent_to_test.rb +3 -3
  44. data/test/core/assertion_macros/exists_test.rb +4 -4
  45. data/test/core/assertion_macros/includes_test.rb +2 -2
  46. data/test/core/assertion_macros/kind_of_test.rb +3 -3
  47. data/test/core/assertion_macros/matches_test.rb +2 -2
  48. data/test/core/assertion_macros/nil_test.rb +2 -2
  49. data/test/core/assertion_macros/raises_test.rb +10 -10
  50. data/test/core/assertion_macros/respond_to_test.rb +2 -2
  51. data/test/core/assertion_macros/same_elements_test.rb +4 -4
  52. data/test/core/assertion_macros/size_test.rb +6 -6
  53. data/test/core/context/asserts_with_arguments_test.rb +12 -0
  54. data/test/core/context/using_describe_in_a_test.rb +1 -1
  55. data/test/core/report_test.rb +9 -5
  56. data/test/core/runnable/message_test.rb +10 -6
  57. data/test/teststrap.rb +0 -6
  58. metadata +20 -33
  59. data/TODO.markdown +0 -14
  60. data/VERSION +0 -1
  61. data/test.watchr +0 -70
  62. data/test/benchmark/colorize.rb +0 -39
@@ -52,10 +52,10 @@ context "A negative size assertion macro" do
52
52
  deny_size("washington", 9..12)
53
53
  end
54
54
 
55
- assertion_test_passes("when string's size is not as expected", 'is not size 11') do
55
+ assertion_test_passes("when string's size is not as expected", 'is size 11') do
56
56
  deny_size("washington", 11)
57
57
  end
58
- assertion_test_passes("when string's size is out of range", 'is not size 11..13') do
58
+ assertion_test_passes("when string's size is out of range", 'is size 11..13') do
59
59
  deny_size("washington", 11..13)
60
60
  end
61
61
 
@@ -65,10 +65,10 @@ context "A negative size assertion macro" do
65
65
  assertion_test_fails("when an array's size is in given range", 'expected size of [1, 2, 3] to not be 3..4, not 3') do
66
66
  deny_size([1, 2, 3], 3..4)
67
67
  end
68
- assertion_test_passes("when an array's size is not as expected", "is not size 2") do
68
+ assertion_test_passes("when an array's size is not as expected", "is size 2") do
69
69
  deny_size([1, 2, 3], 2)
70
70
  end
71
- assertion_test_passes("when an array's size is out of range", "is not size 4..6") do
71
+ assertion_test_passes("when an array's size is out of range", "is size 4..6") do
72
72
  deny_size([1, 2, 3], 4..6)
73
73
  end
74
74
 
@@ -78,10 +78,10 @@ context "A negative size assertion macro" do
78
78
  assertion_test_fails("when a hash size is in range", 'expected size of {:a=>"b"} to not be 1...3, not 1') do
79
79
  deny_size({:a => 'b'}, 1...3)
80
80
  end
81
- assertion_test_passes("when a hash size is not as expected", "is not size 2") do
81
+ assertion_test_passes("when a hash size is not as expected", "is size 2") do
82
82
  deny_size({}, 2)
83
83
  end
84
- assertion_test_passes("when a hash size is out of range", "is not size 2...4") do
84
+ assertion_test_passes("when a hash size is out of range", "is size 2...4") do
85
85
  deny_size({}, 2...4)
86
86
  end
87
87
  end
@@ -0,0 +1,12 @@
1
+ require 'teststrap'
2
+
3
+ context "an assertion made with arguments" do
4
+ setup do
5
+ Riot::Context.new("foo") {}.asserts([:[], 0])
6
+ end
7
+
8
+ should("pass its argument to send, with the first argument as method name") do
9
+ (situation = Riot::Situation.new).instance_variable_set(:@_topic, [1, 2])
10
+ topic.equals(1).run(situation).first
11
+ end.equals(:pass)
12
+ end # assertion made with arguments
@@ -21,7 +21,7 @@ context "Using a describe sub-context" do
21
21
  setup { "another thing is my" }
22
22
  asserts_topic.kind_of(String)
23
23
  end
24
- end.run(Riot::Reporter.new)
24
+ end.run(Riot::SilentReporter.new)
25
25
  end
26
26
 
27
27
  asserts("current context description") do
@@ -73,14 +73,18 @@ context "StoryReporter" do
73
73
 
74
74
  asserts("success message is stripped if nil") do
75
75
  topic.pass("foo", nil)
76
- ColorHelper.uncolored(@out.string)
77
- end.equals(" + foo\n")
76
+ @out.string
77
+ # ColorHelper.uncolored(@out.string)
78
+ end.matches(/\+ \e\[32mfoo\e\[0m\n/)
79
+ # end.equals(" + foo\n")
78
80
 
79
81
  asserts("failure message excludes line info if none provided") do
80
82
  @out.rewind
81
83
  topic.fail("foo", "bar", nil, nil)
82
- ColorHelper.uncolored(@out.string)
83
- end.equals(" - foo: bar\n")
84
+ @out.string
85
+ # ColorHelper.uncolored(@out.string)
86
+ end.matches(/\- \e\[33mfoo: bar\e\[0m\n/)
87
+ # end.equals(" - foo: bar\n")
84
88
 
85
89
  context 'reporting on an empty context' do
86
90
  setup do
@@ -149,6 +153,6 @@ context "DotMatrixReporter" do
149
153
  asserts_topic('puts the full context + assertion name').matches('whatever asserts bang')
150
154
  asserts_topic('puts the exception message').matches('BOOM')
151
155
  # <file path>:<one or more number><two newlines><anything till end of line><newline> is the last thing in the stack trace
152
- asserts_topic('puts the filtered exception backtrace').matches(/#{__FILE__}:\d+\n\n.*$\n\z/)
156
+ asserts_topic('puts the filtered exception backtrace').matches(/#{__FILE__}:\d+:[^\n]*\n\n.*$\n\z/)
153
157
  end
154
158
  end
@@ -5,21 +5,21 @@ context "A message object" do
5
5
 
6
6
  asserts("opening phrase has inspected values") do
7
7
  Riot::Message.new("bar", nil, {:a => 2}).to_s
8
- end.equals(%q["bar" nil {:a=>2}])
9
-
10
- asserts("+ pushes phrase onto string") do
11
- Riot::Message.new.mommy.push("dearest").to_s
12
- end.equals(%q[mommy dearest])
8
+ end.equals(%q["bar", nil, {:a=>2}])
13
9
 
14
10
  context "receiving calls for unbound methods" do
15
11
  asserts("message") do
16
12
  Riot::Message.new.bar.to_s
17
13
  end.equals(%q[bar])
18
14
 
19
- asserts("message with args") do
15
+ asserts("message with an arguments") do
20
16
  Riot::Message.new("Foo").bar("baz").to_s
21
17
  end.equals(%q["Foo" bar "baz"])
22
18
 
19
+ asserts("message with multiple arguments") do
20
+ Riot::Message.new("Foo").bar("baz", "boo", [1,2,3]).to_s
21
+ end.equals(%q{"Foo" bar "baz", "boo", [1, 2, 3]})
22
+
23
23
  asserts("in a long chain with underscored words") do
24
24
  Riot::Message.new.bar.baz.your_mom.to_s
25
25
  end.equals(%q[bar baz your mom])
@@ -32,4 +32,8 @@ context "A message object" do
32
32
 
33
33
  asserts("#not") { Riot::Message.new.not.to_s }.equals(", not")
34
34
  asserts("#not with message") { Riot::Message.new("Foo").not("a").to_s }.equals(%q["Foo", not "a"])
35
+
36
+ asserts("calling with inspect") do
37
+ Riot::Message.new.happy_nappy.inspect.to_s
38
+ end.equals("happy nappy")
35
39
  end # A message object
@@ -35,9 +35,3 @@ class MockReporter < Riot::Reporter
35
35
  def error(description, e); end
36
36
  def results; end
37
37
  end
38
-
39
- class ColorHelper
40
- require 'rubygems'
41
- require 'term/ansicolor'
42
- extend Term::ANSIColor
43
- end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riot
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 12
8
- - 1
9
- version: 0.12.1
4
+ prerelease:
5
+ version: 0.12.2
10
6
  platform: ruby
11
7
  authors:
12
8
  - Justin 'Gus' Knowlden
@@ -14,48 +10,36 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-01-14 00:00:00 -06:00
13
+ date: 2011-02-27 00:00:00 -06:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
21
17
  name: rr
22
18
  prerelease: false
23
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
24
21
  requirements:
25
22
  - - ">="
26
23
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
24
  version: "0"
30
25
  type: :runtime
31
26
  version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
33
- name: term-ansicolor
34
- prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
42
- type: :runtime
43
- version_requirements: *id002
44
27
  description: An extremely fast, expressive, and context-driven unit-testing framework. A replacement for all other testing frameworks. Protest the slow test.
45
28
  email: gus@gusg.us
46
29
  executables: []
47
30
 
48
31
  extensions: []
49
32
 
50
- extra_rdoc_files:
51
- - README.markdown
33
+ extra_rdoc_files: []
34
+
52
35
  files:
36
+ - .gitignore
37
+ - .yardopts
53
38
  - CHANGELOG
39
+ - Gemfile
54
40
  - MIT-LICENSE
55
41
  - README.markdown
56
42
  - Rakefile
57
- - TODO.markdown
58
- - VERSION
59
43
  - lib/riot.rb
60
44
  - lib/riot/assertion.rb
61
45
  - lib/riot/assertion_macro.rb
@@ -80,12 +64,16 @@ files:
80
64
  - lib/riot/message.rb
81
65
  - lib/riot/middleware.rb
82
66
  - lib/riot/reporter.rb
67
+ - lib/riot/reporter/dot_matrix.rb
68
+ - lib/riot/reporter/io.rb
69
+ - lib/riot/reporter/pretty_dot_matrix.rb
70
+ - lib/riot/reporter/silent.rb
71
+ - lib/riot/reporter/story.rb
83
72
  - lib/riot/rr.rb
84
73
  - lib/riot/runnable.rb
85
74
  - lib/riot/situation.rb
75
+ - lib/riot/version.rb
86
76
  - riot.gemspec
87
- - test.watchr
88
- - test/benchmark/colorize.rb
89
77
  - test/benchmark/message_concatenation.rb
90
78
  - test/benchmark/riot_vs_minitest.rb
91
79
  - test/benchmark/same_elements_vs_set.rb
@@ -106,6 +94,7 @@ files:
106
94
  - test/core/assertion_macros/same_elements_test.rb
107
95
  - test/core/assertion_macros/size_test.rb
108
96
  - test/core/context/asserts_topic_test.rb
97
+ - test/core/context/asserts_with_arguments_test.rb
109
98
  - test/core/context/context_test.rb
110
99
  - test/core/context/context_with_options_test.rb
111
100
  - test/core/context/deny_test.rb
@@ -137,28 +126,25 @@ rdoc_options: []
137
126
  require_paths:
138
127
  - lib
139
128
  required_ruby_version: !ruby/object:Gem::Requirement
129
+ none: false
140
130
  requirements:
141
131
  - - ">="
142
132
  - !ruby/object:Gem::Version
143
- segments:
144
- - 0
145
133
  version: "0"
146
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
+ none: false
147
136
  requirements:
148
137
  - - ">="
149
138
  - !ruby/object:Gem::Version
150
- segments:
151
- - 0
152
139
  version: "0"
153
140
  requirements: []
154
141
 
155
142
  rubyforge_project:
156
- rubygems_version: 1.3.6
143
+ rubygems_version: 1.5.2
157
144
  signing_key:
158
145
  specification_version: 3
159
146
  summary: An extremely fast, expressive, and context-driven unit-testing framework. Protest the slow test.
160
147
  test_files:
161
- - test/benchmark/colorize.rb
162
148
  - test/benchmark/message_concatenation.rb
163
149
  - test/benchmark/riot_vs_minitest.rb
164
150
  - test/benchmark/same_elements_vs_set.rb
@@ -179,6 +165,7 @@ test_files:
179
165
  - test/core/assertion_macros/same_elements_test.rb
180
166
  - test/core/assertion_macros/size_test.rb
181
167
  - test/core/context/asserts_topic_test.rb
168
+ - test/core/context/asserts_with_arguments_test.rb
182
169
  - test/core/context/context_test.rb
183
170
  - test/core/context/context_with_options_test.rb
184
171
  - test/core/context/deny_test.rb
@@ -1,14 +0,0 @@
1
- - Documentation
2
- - Introduction
3
- - overall example
4
- - Assertion
5
- - scope
6
- - extensions (e.g. rack/test)
7
- - Yard
8
- - use yard to document the #assertion method used to define new assertions so the defined assertions will show up in the docs ( http://gnuu.org/2009/11/18/customizing-yard-templates/ )
9
-
10
- - Assertion Macros
11
- - include/any/contains (array,hash, maybe string?)
12
- - perhaps able to take an enumerable and compare...
13
- { [1,2,3] }.contains(2,3)
14
- { "the song that never ends" }.contains("never","ends")
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.12.1
@@ -1,70 +0,0 @@
1
- ENV["WATCHR"] = "1"
2
- system 'clear'
3
-
4
- def growl(message)
5
- growlnotify = `which growlnotify`.chomp
6
- title = "Watchr Test Results"
7
- image = message.include?('0 failures, 0 errors') ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
8
- options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
9
- system %(#{growlnotify} #{options} &)
10
- end
11
-
12
- def run(cmd)
13
- puts(cmd)
14
- `#{cmd}`
15
- end
16
-
17
- def run_test_file(file)
18
- system('clear')
19
- result = run(%Q(ruby -I"lib:test" -rubygems #{file}))
20
- growl result.split("\n").last rescue nil
21
- puts result
22
- end
23
-
24
- def run_all_tests
25
- system('clear')
26
- result = run "rake test:all"
27
- growl result.split("\n").last rescue nil
28
- puts result
29
- end
30
-
31
- def run_all_features
32
- system('clear')
33
- run "cucumber"
34
- end
35
-
36
- def related_test_files(path)
37
- Dir['test/**/*.rb'].select { |file| file =~ /#{File.basename(path).split(".").first}_test.rb/ }
38
- end
39
-
40
- def run_suite
41
- run_all_tests
42
- # run_all_features
43
- end
44
-
45
- watch('test/teststrap\.rb') { run_all_tests }
46
- watch('test/(.*).*_test\.rb') { |m| run_test_file(m[0]) }
47
- watch('lib/.*/.*\.rb') { |m| related_test_files(m[0]).map {|tf| run_test_file(tf) } }
48
- # watch('features/.*/.*\.feature') { run_all_features }
49
-
50
- # Ctrl-\
51
- Signal.trap 'QUIT' do
52
- puts " --- Running all tests ---\n\n"
53
- run_all_tests
54
- end
55
-
56
- @interrupted = false
57
-
58
- # Ctrl-C
59
- Signal.trap 'INT' do
60
- if @interrupted then
61
- @wants_to_quit = true
62
- abort("\n")
63
- else
64
- puts "Interrupt a second time to quit"
65
- @interrupted = true
66
- Kernel.sleep 1.5
67
- # raise Interrupt, nil # let the run loop catch it
68
- run_suite
69
- end
70
- end
@@ -1,39 +0,0 @@
1
- require 'rubygems'
2
- require 'benchmark'
3
- require 'colorize'
4
- require 'term/ansicolor'
5
-
6
- class MyString < String
7
- include ::Term::ANSIColor
8
- end
9
-
10
- colorize = String.new
11
- term_ansicolor = MyString.new
12
-
13
- n = 50_000
14
-
15
- Benchmark.bmbm do |x|
16
- x.report("colorize") do
17
- n.times do
18
- colorize.green
19
- colorize.yellow
20
- colorize.red
21
- end
22
- end
23
- x.report("term-ansicolor") do
24
- n.times do
25
- term_ansicolor.green
26
- term_ansicolor.yellow
27
- term_ansicolor.red
28
- end
29
- end
30
- end
31
-
32
- # Rehearsal --------------------------------------------------
33
- # colorize 4.140000 0.160000 4.300000 ( 4.375765)
34
- # term-ansicolor 0.720000 0.000000 0.720000 ( 0.730665)
35
- # ----------------------------------------- total: 5.020000sec
36
- #
37
- # user system total real
38
- # colorize 4.070000 0.170000 4.240000 ( 4.459804)
39
- # term-ansicolor 0.700000 0.000000 0.700000 ( 0.728494)