crspec 0.1.2 → 0.1.3
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 +4 -4
- data/CHANGELOG.md +86 -0
- data/README.md +1 -1
- data/lib/crspec/cli.rb +86 -5
- data/lib/crspec/configuration.rb +62 -9
- data/lib/crspec/dsl.rb +66 -2
- data/lib/crspec/example.rb +60 -6
- data/lib/crspec/example_group.rb +363 -63
- data/lib/crspec/execution_context.rb +10 -6
- data/lib/crspec/expectations.rb +62 -2
- data/lib/crspec/file_fixtures.rb +18 -0
- data/lib/crspec/formatters/progress_formatter.rb +37 -14
- data/lib/crspec/matchers.rb +642 -0
- data/lib/crspec/mock/argument_matchers.rb +157 -0
- data/lib/crspec/mock/double.rb +246 -13
- data/lib/crspec/mock/interceptor.rb +32 -9
- data/lib/crspec/mock/space.rb +14 -0
- data/lib/crspec/process_runner.rb +332 -0
- data/lib/crspec/rails/assets_shim.rb +33 -0
- data/lib/crspec/rails/database_isolation.rb +179 -8
- data/lib/crspec/rails/parallel.rb +29 -29
- data/lib/crspec/rails/request_helpers.rb +70 -14
- data/lib/crspec/rails/system_server.rb +7 -0
- data/lib/crspec/rails/warden_shim.rb +18 -0
- data/lib/crspec/runner.rb +143 -29
- data/lib/crspec/shared_examples.rb +70 -0
- data/lib/crspec/status_persistence.rb +46 -0
- data/lib/crspec/transpiler/cli.rb +106 -15
- data/lib/crspec/transpiler/rewriter.rb +179 -25
- data/lib/crspec/version.rb +1 -1
- data/lib/crspec.rb +6 -0
- data/lib/rspec/core.rb +2 -0
- data/lib/rspec/expectations.rb +2 -0
- data/lib/rspec/mocks.rb +2 -0
- data/lib/rspec/rails.rb +2 -0
- data/lib/rspec.rb +2 -0
- metadata +27 -1
|
@@ -3,39 +3,62 @@
|
|
|
3
3
|
module Crspec
|
|
4
4
|
module Formatters
|
|
5
5
|
class ProgressFormatter
|
|
6
|
+
FLUSH_THRESHOLD = 64
|
|
7
|
+
FLUSH_INTERVAL = 0.2
|
|
8
|
+
|
|
6
9
|
def initialize(output = $stdout, color: output.respond_to?(:tty?) && output.tty?)
|
|
7
10
|
@output = output
|
|
8
11
|
@color = color
|
|
9
12
|
@mutex = Mutex.new
|
|
13
|
+
@buffer = +""
|
|
14
|
+
@last_flush = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
10
15
|
end
|
|
11
16
|
|
|
12
17
|
def example_passed(_example)
|
|
13
|
-
@
|
|
14
|
-
@output.print @color ? "\e[32m.\e[0m" : "."
|
|
15
|
-
@output.flush
|
|
16
|
-
end
|
|
18
|
+
record(@color ? "\e[32m.\e[0m" : ".")
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def example_failed(_example)
|
|
20
|
-
@
|
|
21
|
-
@output.print @color ? "\e[31mF\e[0m" : "F"
|
|
22
|
-
@output.flush
|
|
23
|
-
end
|
|
22
|
+
record(@color ? "\e[31mF\e[0m" : "F")
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
def example_pending(_example)
|
|
27
|
-
@
|
|
28
|
-
@output.print @color ? "\e[33m*\e[0m" : "*"
|
|
29
|
-
@output.flush
|
|
30
|
-
end
|
|
26
|
+
record(@color ? "\e[33m*\e[0m" : "*")
|
|
31
27
|
end
|
|
32
28
|
|
|
33
|
-
def start
|
|
29
|
+
def start
|
|
30
|
+
@last_flush = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
31
|
+
end
|
|
34
32
|
|
|
35
33
|
def finish
|
|
34
|
+
chunk = @mutex.synchronize { swap_buffer }
|
|
35
|
+
@output.print(chunk) unless chunk.empty?
|
|
36
|
+
@output.puts
|
|
37
|
+
@output.flush
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def record(token)
|
|
43
|
+
chunk = nil
|
|
36
44
|
@mutex.synchronize do
|
|
37
|
-
@
|
|
45
|
+
@buffer << token
|
|
46
|
+
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
47
|
+
if @buffer.size >= FLUSH_THRESHOLD || now - @last_flush >= FLUSH_INTERVAL
|
|
48
|
+
@last_flush = now
|
|
49
|
+
chunk = swap_buffer
|
|
50
|
+
end
|
|
38
51
|
end
|
|
52
|
+
return unless chunk
|
|
53
|
+
|
|
54
|
+
@output.print(chunk)
|
|
55
|
+
@output.flush
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def swap_buffer
|
|
59
|
+
chunk = @buffer
|
|
60
|
+
@buffer = +""
|
|
61
|
+
chunk
|
|
39
62
|
end
|
|
40
63
|
end
|
|
41
64
|
|