gabrielg-oughta 0.0.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -1
- data/VERSION.yml +4 -0
- data/lib/thumblemonks/oughta/macro_macros.rb +34 -0
- metadata +2 -1
data/README.rdoc
CHANGED
data/VERSION.yml
ADDED
@@ -3,12 +3,46 @@ module Thumblemonks
|
|
3
3
|
module MacroMacros
|
4
4
|
module ClassMethods
|
5
5
|
|
6
|
+
# Defines a macro for use in a TestCase or Context with the given name and block.
|
7
|
+
# For example, this defines a macro called :should_be_cool
|
8
|
+
#
|
9
|
+
# macro :should_be_cool do
|
10
|
+
#
|
11
|
+
# should("be true") { assert(true) }
|
12
|
+
# should("be cool") { assert_equal("cool", @message) }
|
13
|
+
# should_eventually "do something else"
|
14
|
+
#
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# To then use this macro, see the documentation for use_macro
|
18
|
+
#
|
6
19
|
def macro(name, &block)
|
7
20
|
(class << self; self; end).instance_eval do
|
8
21
|
define_method(:"Macro: #{name}") { |context| context.instance_eval(&block) }
|
9
22
|
end
|
10
23
|
end
|
11
24
|
|
25
|
+
# Uses a macro defined using the macro method. For example:
|
26
|
+
#
|
27
|
+
# class TooLazyToSubmitPatchesToThoughtbotTest < Test::Unit::TestCase
|
28
|
+
#
|
29
|
+
# macro :should_be_cool do
|
30
|
+
# should("be cool") { assert_equal("cool", @message) }
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# def setup
|
34
|
+
# @message = "cool"
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# use_macro :should_be_cool
|
38
|
+
#
|
39
|
+
# context "intentionally fails" do
|
40
|
+
# setup { @message = "not cool yo" }
|
41
|
+
# use_macro :should_be_cool
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# end
|
45
|
+
#
|
12
46
|
def use_macro(name)
|
13
47
|
send(:"Macro: #{name}", Shoulda.current_context || self)
|
14
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gabrielg-oughta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Gironda
|
@@ -24,6 +24,7 @@ extra_rdoc_files:
|
|
24
24
|
- LICENSE
|
25
25
|
files:
|
26
26
|
- README.rdoc
|
27
|
+
- VERSION.yml
|
27
28
|
- lib/oughta.rb
|
28
29
|
- lib/thumblemonks
|
29
30
|
- lib/thumblemonks/oughta
|