scampi 0.1.2 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ab326398426699068726dee799fa312709c6d44bfffb607de4c467d0a52a2ad
4
- data.tar.gz: e3937c018adbf534d156bffc262001cee773ac741abb5a0b7d950b075e125153
3
+ metadata.gz: 82b9fac36711a5125614536636294d45b5d94a013894a7de447e131cf46f6cc8
4
+ data.tar.gz: 4ba5a553e3f7d94ce7c53c8f331af6646aaf06f18b5ef88838b4585c33987e40
5
5
  SHA512:
6
- metadata.gz: 719acff10a6ca528087b0b5dde1b375e85c33c9c9aa16a1eab184cd26073f845d1c3a4a96c2dcdaf71d5480e74ccd8a8c7c3feeaed9bf908f7442d380bd15af9
7
- data.tar.gz: 5a23a60fae7c9181bb425799ce76f5c9555739ad2748270ec3a1066fbed54ccdaf424f0aa100813eaa93cbab03a8ade669d8fbeb0ddb109dfcd95851ea4a5fee
6
+ metadata.gz: 55a95005509df9d72b5cf3ccf1e1dbcae5f71f67cb6cc697a63e874e3e23d175b2fef36c73a726f902da8b83c9676207a261f4c5438e4a65d01c37c736d04691
7
+ data.tar.gz: 252ca9f7c5f9fb2b8837bb1c1201054372455f2c7740500f9ba8e2a8234aad2f48c44e27b46faec49124329729d2adb2ff4b2dc017d4bd9198b9d9000de8de00
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scampi (0.1.2)
4
+ scampi (0.1.4)
5
5
  colorize-extended
6
6
 
7
7
  GEM
@@ -22,7 +22,7 @@ DEPENDENCIES
22
22
  CHECKSUMS
23
23
  colorize (1.1.0) sha256=30b5237f0603f6662ab8d1fc2bd4a96142b806c6415d79e45ef5fdc6a0cfc837
24
24
  colorize-extended (0.1.0) sha256=e8c39986e41ee2e14623c8fa02cf851ef4b83d2fe1392daa2b4d81f0df7bedc9
25
- scampi (0.1.2)
25
+ scampi (0.1.4)
26
26
 
27
27
  BUNDLED WITH
28
28
  4.0.7
data/exe/scampi CHANGED
@@ -7,7 +7,7 @@ require 'scampi'
7
7
  ENV["TEST"] = "true"
8
8
 
9
9
  files = if ARGV.empty?
10
- `rg -l "^test do$" test`.split("\n")
10
+ `rg -l "^test do$" .`.split("\n")
11
11
  else
12
12
  ARGV.flat_map { |pattern| Dir.glob(pattern) }
13
13
  end
@@ -60,14 +60,9 @@ module Kernel
60
60
  end
61
61
 
62
62
  # Allow `it` at the top level (outside a describe block).
63
- # Wraps the spec in an anonymous context derived from the caller's filename.
63
+ # Stored as a raw spec only `describe` creates subtests.
64
64
  def it(description, &block)
65
- loc = caller_locations(1, 1).first
66
- file = loc.path || loc.absolute_path || "(unknown)"
67
- ctx_name = File.basename(file, File.extname(file))
68
- ctx = Scampi::Context.new(ctx_name) {}
69
- ctx.it(description, &block)
70
- ctx.register
71
- Scampi.queue << ctx
65
+ block ||= proc { should.flunk "not implemented" }
66
+ Scampi.queue << [:spec, description, block]
72
67
  end
73
68
  end
@@ -1,5 +1,5 @@
1
1
  module Scampi
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
4
4
 
5
5
  require_relative '../rubygems_plugin'
data/lib/scampi.rb CHANGED
@@ -35,20 +35,26 @@ module Scampi
35
35
  @ran = true
36
36
 
37
37
  # Register: evaluate all describe blocks to discover specs
38
- @queue.each(&:register)
38
+ @queue.each { |item| item.register if item.is_a?(Context) }
39
39
 
40
- # TAP version + plan (one entry per top-level describe)
40
+ # TAP version + plan
41
41
  puts "TAP version 14"
42
42
  puts "1..#{@queue.size}"
43
43
 
44
- # Execute all specs as subtests
45
- @queue.each_with_index do |context, i|
46
- passed = context.execute(0)
44
+ # Execute: contexts become subtests, raw specs become flat lines
45
+ @queue.each_with_index do |item, i|
47
46
  n = i + 1
48
- if passed
49
- puts "#{"ok".green} #{n} - #{context.name}"
47
+ if item.is_a?(Context)
48
+ passed = item.execute(0)
49
+ if passed
50
+ puts "#{"ok".green} #{n} - #{item.name}"
51
+ else
52
+ puts "#{"not ok".red} #{n} - #{item.name}"
53
+ end
50
54
  else
51
- puts "#{"not ok".red} #{n} - #{context.name}"
55
+ _, description, block = item
56
+ Counter[:specifications] += 1
57
+ passed = run_bare_spec(description, block, n)
52
58
  end
53
59
  end
54
60
 
@@ -88,6 +94,47 @@ module Scampi
88
94
  false
89
95
  end
90
96
  end
97
+
98
+ def self.run_bare_spec(description, block, n)
99
+ handle_requirement(description, 0, n) do
100
+ begin
101
+ Counter[:depth] += 1
102
+ rescued = false
103
+ begin
104
+ prev_req = Counter[:requirements]
105
+ block.call
106
+ rescue Object => e
107
+ rescued = true
108
+ raise e
109
+ ensure
110
+ if Counter[:requirements] == prev_req and not rescued
111
+ raise Error.new(:missing, "empty specification: #{description}")
112
+ end
113
+ end
114
+ rescue SystemExit, Interrupt
115
+ raise
116
+ rescue Object => e
117
+ ErrorLog << "#{e.class}: #{e.message}\n"
118
+ e.backtrace.find_all { |line| line !~ /bin\/scampi|\/scampi\.rb:\d+/ }.
119
+ each_with_index { |line, i|
120
+ ErrorLog << "\t#{line}#{i==0 ? ": #{description}" : ""}\n"
121
+ }
122
+ ErrorLog << "\n"
123
+
124
+ if e.kind_of? Error
125
+ Counter[e.count_as] += 1
126
+ e.count_as.to_s.upcase
127
+ else
128
+ Counter[:errors] += 1
129
+ "ERROR: #{e.class}"
130
+ end
131
+ else
132
+ ""
133
+ ensure
134
+ Counter[:depth] -= 1
135
+ end
136
+ end
137
+ end
91
138
  end
92
139
 
93
140
  require_relative 'scampi/error'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scampi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan K