matest 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f5aa7cbf9baa6a1ecd2ea22af65d958de666e95
4
- data.tar.gz: 85753ee9e65a6a0141c521a732572bb1bbae86a3
3
+ metadata.gz: 7e6e7d1a7872997bc4b3fad1f258f0093f9f32ea
4
+ data.tar.gz: 78015cdf727f064505dbba282a5e008bdf8ecf1b
5
5
  SHA512:
6
- metadata.gz: f3b856079130676b3490d263568a1b617937bc9c9a0b172e13ea0a283142ab42bca64a07827d92eef012a5da31afb9b606e0529cb53d41514e02f472661016dc
7
- data.tar.gz: 181eecd3f1c33a2bdd8b7628eb579805b4a82e241f2b407614d3763526308d0bf60245d1ef53d05dff3d9745cf710ac22001ad60d57980ce5b300382b4ca0585
6
+ metadata.gz: 05aaa86b1200e3dc2b973ceab2efd6e0f5c78dbbdd1addcfc974f77131819ec89bdb97a160d0b61290fc5629ae8d85f57e5cdc40e4043774a3730c54c714d8e3
7
+ data.tar.gz: 627b3b5a0a537325677319564fd80f3de92a99acbdfc95f981b51535d2e9c06f3d0aba7921c623ed76014303787fcf6165be6aa2b1226bb8a6c1c090ef29065a
data/README.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Matest
2
2
 
3
- Tests Gasoleros (Cheap tests)
3
+ Tests Gasoleros (Very cheap tests)
4
+
5
+ ## Description
6
+
7
+ Matest is a very small testing library.
8
+
9
+ It doesn't use the usual assertion style (`assert(1, 1)`) nor the rspec style(`1.should == 1` or `1.must_equal(1)`).
10
+
11
+ It uses natural assertions.
12
+
13
+ This means that:
14
+ - A test will pass if it returns true
15
+ - A test will fail if it returns false
4
16
 
5
17
  ## Installation
6
18
 
@@ -20,7 +32,134 @@ Or install it yourself as:
20
32
 
21
33
  ## Usage
22
34
 
23
- TODO: Write usage instructions here
35
+ To run Matest, you just need to execute the `mt` command, passing as arguments the desired test files.
36
+
37
+ ```bash
38
+ $ mt spec/my_spec.rb
39
+ ```
40
+
41
+ You can also use wildcards.
42
+
43
+ For example, to run all the specs in a directory:
44
+ ```bash
45
+ $ mt spec/*_spec.rb
46
+ ```
47
+
48
+ Or to run recursively
49
+ ```bash
50
+ $ mt spec/**/*_spec.rb
51
+ ```
52
+
53
+ ## Specs
54
+
55
+ To define a test, first you need to set a scope, and inside it, define your spec.
56
+ ```ruby
57
+ scope do
58
+ spec do
59
+ true
60
+ end
61
+ end
62
+ ```
63
+
64
+ If the return value of the `spec` block is `true`, the spec will pass and if it's false it will `fail`.
65
+
66
+ If you return anithing else, you'll get a `NOT A NATURAL ASSERTION` status.
67
+
68
+ You can also add descriptions to either the `scope` or the `spec` blocks:
69
+
70
+ ```ruby
71
+ scope "a description" do
72
+ spec "another description" do
73
+ true
74
+ end
75
+ end
76
+ ```
77
+
78
+ ## Raising Errors
79
+
80
+ If your test raises an error during the run, youll get an `ERROR` status and you'll see the backtrace.
81
+
82
+ ## Skipping
83
+
84
+ You can skip a test in two possible ways: You can declare a spec whithout a block or use the `xspec` method.
85
+
86
+ ```ruby
87
+ scope do
88
+ xspec "I'll be skipped" do
89
+ true
90
+ end
91
+ spec "I'll be skipped too"
92
+ end
93
+ ```
94
+
95
+ This will skip you spec and inform you when you run.
96
+
97
+ You can skip the whole scope by using `xscope` instead of `scope`.
98
+
99
+ Take into account that `xscope` is a no-op so you won't be informed when you skip a scope.
100
+
101
+ ## Let and let!
102
+
103
+ Matest steals the `let` and `let!` features from `RSpec` and `Minitest`.
104
+
105
+ With `let` you can declare a lazy variable valid on the current scope and all sub-scopes.
106
+
107
+ Here are some examples of what you can do with them:
108
+
109
+ ```ruby
110
+ scope do
111
+ let(:m1) { :m1 }
112
+ let!(:m3) { :m3 }
113
+
114
+ let(:m4) { :m4 }
115
+ let!(:m5) { :m5 }
116
+
117
+ spec do
118
+ m1 == :m1
119
+ end
120
+
121
+ spec do
122
+ ! defined?(m2)
123
+ end
124
+
125
+ spec do
126
+ m3 == :m3
127
+ end
128
+
129
+ spec do
130
+ ! defined?(@m4)
131
+ end
132
+
133
+ spec do
134
+ !! defined?(@m5)
135
+ end
136
+
137
+ scope do
138
+ let(:m2) { :m2 }
139
+ spec do
140
+ m1 == :m1
141
+ end
142
+
143
+ spec do
144
+ m2 == :m2
145
+ end
146
+ end
147
+ end
148
+ ```
149
+
150
+ ## Aliases
151
+
152
+ You may be used to other keywords provenient from different testing frameworks. Matest has a couple of alias that you may use indistinctly to fit your style.
153
+
154
+ `scope` has the following aliases:
155
+ - `context` (and `xcontext`)
156
+ - `describe` (and `xdescribe`)
157
+ - `group` (and `xgroup`)
158
+
159
+ `spec` has the following aliases:
160
+ - `it` (and `xit`)
161
+ - `test` (and `xtest`)
162
+ - `example` (and `xexample`)
24
163
 
25
164
  ## Contributing
26
165
 
@@ -157,8 +157,8 @@ module Matest
157
157
  spec(description)
158
158
  end
159
159
 
160
- [:it, :spec, :test, :example].each do |m|
161
- alias m :spec
160
+ [:it, :test, :example].each do |m|
161
+ alias :"#{m}" :spec
162
162
  alias :"x#{m}" :xspec
163
163
  end
164
164
 
@@ -204,3 +204,12 @@ end
204
204
  def scope(description=nil, &block)
205
205
  Matest::Runner.runner << Matest::ExampleGroup.new(block)
206
206
  end
207
+
208
+ def xscope(description=nil, &block)
209
+ # no-op
210
+ end
211
+
212
+ [:describe, :context, :group].each do |m|
213
+ alias :"#{m}" :scope
214
+ alias :"x#{m}" :xscope
215
+ end
@@ -1,3 +1,3 @@
1
1
  module Matest
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -102,10 +102,11 @@ describe "spec" do
102
102
  end
103
103
 
104
104
  it "exists only inside a scope" do
105
- spec do
105
+ -> {
106
+ spec do
106
107
  true
107
- end
108
-
108
+ end
109
+ }.must_raise(NoMethodError)
109
110
  end
110
111
  end
111
112
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Iachetti