matest 0.0.3 → 0.1.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: 4928f8622b966f000c3e4a08a0191c4f0be8d79e
4
- data.tar.gz: 926dbbb38e11235127b120ddd21cfcc753311fbc
3
+ metadata.gz: 2f5aa7cbf9baa6a1ecd2ea22af65d958de666e95
4
+ data.tar.gz: 85753ee9e65a6a0141c521a732572bb1bbae86a3
5
5
  SHA512:
6
- metadata.gz: 8a8b9cbc0884cf97d41a250aa7319c94faaf2d727fc39a64a2091af3e4bcc5bea714aa5f2c5f9382d2725eeefddfe0f196585edaaff0416f46d25e9ea9e11311
7
- data.tar.gz: 2d979b53db462b77de5929fcabf067ab110c84fcefb10567682bf4065ee209a1cb9744940a4ce66d814dd5976967af7838314b4767be2fab311643703c771b3f
6
+ metadata.gz: f3b856079130676b3490d263568a1b617937bc9c9a0b172e13ea0a283142ab42bca64a07827d92eef012a5da31afb9b606e0529cb53d41514e02f472661016dc
7
+ data.tar.gz: 181eecd3f1c33a2bdd8b7628eb579805b4a82e241f2b407614d3763526308d0bf60245d1ef53d05dff3d9745cf710ac22001ad60d57980ce5b300382b4ca0585
data/bin/mt CHANGED
@@ -8,18 +8,17 @@ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
8
8
  require "pathname"
9
9
  require "matest"
10
10
 
11
- @RUNNER = Matest::Runner.new
12
-
11
+ runner = Matest::Runner.runner
13
12
  ARGV.each do |file|
14
- @RUNNER.load_file(Pathname(file).expand_path)
13
+ runner.load_file(Pathname(file).expand_path)
15
14
  end
16
15
 
17
- @RUNNER.execute!
16
+ runner.execute!
18
17
 
19
18
  time_elapsed = Time.now - start_time
20
19
 
21
20
  puts
22
- info = @RUNNER.info
21
+ info = runner.info
23
22
 
24
23
  def spec_detail(info)
25
24
  info[:num_specs].map { |name, num|
@@ -10,6 +10,10 @@ module Matest
10
10
  @info = {}
11
11
  end
12
12
 
13
+ def self.runner
14
+ @runner ||= new
15
+ end
16
+
13
17
  def <<(example_group)
14
18
  example_groups << example_group
15
19
  end
@@ -19,15 +23,16 @@ module Matest
19
23
  end
20
24
 
21
25
  def execute!
22
- statuses = []
23
26
  example_groups.each do |current_group|
24
27
  current_group.execute!
25
28
  end
29
+ print_messages
30
+ end
26
31
 
27
- puts
28
- puts
29
- puts "### Messages ###"
32
+ def print_messages
33
+ puts "\n\n### Messages ###"
30
34
 
35
+ statuses = []
31
36
  info[:num_specs] = { total: 0 }
32
37
  example_groups.each do |current_group|
33
38
  current_group.statuses.each do |status|
@@ -35,13 +40,12 @@ module Matest
35
40
 
36
41
  info[:num_specs][status.name] ||= 0
37
42
  info[:num_specs][status.name] += 1
38
-
43
+
39
44
  if status.is_a?(Matest::SpecPassed)
40
45
  else
41
- puts
42
- puts "[#{status.name}] #{status.description}"
46
+ puts "\n[#{status.name}] #{status.description}"
43
47
  if status.is_a?(Matest::NotANaturalAssertion)
44
- puts "RESULT >> #{status.result.inspect}"
48
+ puts " # => #{status.result.inspect}"
45
49
  end
46
50
  if status.is_a?(Matest::ExceptionRaised)
47
51
  puts "EXCEPTION >> #{status.result}"
@@ -50,7 +54,7 @@ module Matest
50
54
  end
51
55
 
52
56
  end
53
- puts " #{status.location}"
57
+ puts " #{status.location}:"
54
58
  end
55
59
  end
56
60
  end
@@ -158,6 +162,21 @@ module Matest
158
162
  alias :"x#{m}" :xspec
159
163
  end
160
164
 
165
+ def self.let(var_name, &block)
166
+ define_method(var_name) do
167
+ instance_variable_set(:"@#{var_name}", block.call)
168
+ end
169
+ end
170
+
171
+ def let(var_name, &block)
172
+ self.class.let(var_name, &block)
173
+ end
174
+
175
+ def let!(var_name, &block)
176
+ self.class.let(var_name, &block)
177
+ send(var_name)
178
+ end
179
+
161
180
  def run_spec(spec, description)
162
181
  status = begin
163
182
  result = spec.call
@@ -183,5 +202,5 @@ module Matest
183
202
  end
184
203
 
185
204
  def scope(description=nil, &block)
186
- (@RUNNER || Matest::Runner.new).example_groups << Matest::ExampleGroup.new(block)
205
+ Matest::Runner.runner << Matest::ExampleGroup.new(block)
187
206
  end
@@ -1,3 +1,3 @@
1
1
  module Matest
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -101,6 +101,12 @@ describe "spec" do
101
101
  end
102
102
  end
103
103
 
104
+ it "exists only inside a scope" do
105
+ spec do
106
+ true
107
+ end
108
+
109
+ end
104
110
  end
105
111
 
106
112
  describe "xspec" do
@@ -6,7 +6,7 @@ scope do
6
6
  spec "I shall fail" do
7
7
  false
8
8
  end
9
-
9
+
10
10
  spec do
11
11
  @hola = 5
12
12
  @hola == 5
@@ -27,10 +27,11 @@ scope do
27
27
  spec "I raise" do
28
28
  raise IndexError
29
29
  end
30
-
30
+
31
31
  spec "I skip"
32
-
32
+
33
33
  xspec "I skip too" do
34
34
  false
35
35
  end
36
36
  end
37
+
@@ -0,0 +1,37 @@
1
+ scope do
2
+ let(:m1) { :m1 }
3
+ let!(:m3) { :m3 }
4
+
5
+ let(:m4) { :m4 }
6
+ let!(:m5) { :m5 }
7
+
8
+ spec do
9
+ m1 == :m1
10
+ end
11
+
12
+ spec do
13
+ ! defined?(m2)
14
+ end
15
+
16
+ spec do
17
+ m3 == :m3
18
+ end
19
+
20
+ spec do
21
+ ! defined?(@m4)
22
+ end
23
+
24
+ spec do
25
+ !! defined?(@m5)
26
+ end
27
+ scope do
28
+ let(:m2) { :m2 }
29
+ spec do
30
+ m1 == :m1
31
+ end
32
+
33
+ spec do
34
+ m2 == :m2
35
+ end
36
+ end
37
+ end
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.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Iachetti
@@ -58,6 +58,7 @@ files:
58
58
  - spec/matest_spec.rb
59
59
  - spec/matest_specs/nested_scopes_spec.rb
60
60
  - spec/matest_specs/scope_spec.rb
61
+ - spec/matest_specs/scoping_stuff_spec.rb
61
62
  - spec/matest_specs/spec_helper.rb
62
63
  - spec/spec_helper.rb
63
64
  homepage: ''
@@ -88,5 +89,6 @@ test_files:
88
89
  - spec/matest_spec.rb
89
90
  - spec/matest_specs/nested_scopes_spec.rb
90
91
  - spec/matest_specs/scope_spec.rb
92
+ - spec/matest_specs/scoping_stuff_spec.rb
91
93
  - spec/matest_specs/spec_helper.rb
92
94
  - spec/spec_helper.rb