docspec 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: 8fc481249428391d949022fed23e05a8224e589c9f1fdbaa1382ebe6e4eb29db
4
- data.tar.gz: 20dd556c92ecf92e0b414444be5a7df12e209f6eafacf0e00a8ca19941303603
3
+ metadata.gz: b8a5c9b5152aec40381604f7b29473d9df865cba3cd650cd1b70dda2115e9165
4
+ data.tar.gz: 618428c8f9733ee701f6e2fb4babd5c1da39e85c0db601ae8b0f07e9f942e864
5
5
  SHA512:
6
- metadata.gz: 1757b04031643e80ec5e92062e86ba3dd117a670470563dbcb1981dc69cae785e38062740c1b150a517ae34ce14f6d44e97cd48a3a8455ccebbf584e236a5a0e
7
- data.tar.gz: 0df7cd6b9195b9bf5841ea1ab864bf88a1f2476e8add73dc0d49dac6197d88b96cc33d68d35d467e214b946740ce7b18da902754f024579089739b92fabffb13
6
+ metadata.gz: 2a2eacb5a463a059419863bf58676146b73e9398c5ec94563e444525865764bf2ba1814bc4cdb9980983a1314d7c8951c3be0b23f7cb3a6a4b7e312d46761164
7
+ data.tar.gz: 5de5e31541b08ba45594da601462db482b6c677eae357026b75678fb0d50dbaad861f4e86e339f2dbcdd5760fc13ae22f47d4577e39e604be83e971ef598e75a
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
- Docspec
2
- ==================================================
1
+ # Docspec
3
2
 
4
3
  [![Gem Version](https://badge.fury.io/rb/docspec.svg)](https://badge.fury.io/rb/docspec)
5
- [![Build Status](https://travis-ci.com/DannyBen/docspec.svg?branch=master)](https://travis-ci.com/DannyBen/docspec)
4
+ [![Build Status](https://github.com/DannyBen/docspec/workflows/Test/badge.svg)](https://github.com/DannyBen/docspec/actions?query=workflow%3ATest)
6
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/e0c15c1f33fa4aa45f70/maintainability)](https://codeclimate.com/github/DannyBen/docspec/maintainability)
7
6
 
8
7
  Docspec lets you reuse your Markdown documents as the unit tests for your
@@ -11,30 +10,29 @@ Ruby library.
11
10
  ---
12
11
 
13
12
 
14
- Installation
15
- --------------------------------------------------
13
+ ## Installation
16
14
 
17
- $ gem install docspec
15
+ ```
16
+ $ gem install docspec
17
+ ```
18
18
 
19
19
 
20
- Demo
21
- --------------------------------------------------
20
+ ## Demo
22
21
 
23
- ![Demo](demo/cast.svg)
22
+ ![Demo](demo/cast.gif)
24
23
 
25
24
 
26
- Usage
27
- --------------------------------------------------
25
+ ## Usage
28
26
 
29
27
  Docspec expects one or more Markdown files with embedded code snippets to
30
28
  test.
31
29
 
32
30
  Code snippets should be enclosed in a `ruby` or `shell` code fence:
33
31
 
34
- ```ruby
35
- puts "code to test (should output something)"
36
- #=> code to test (should output something)
37
- ```
32
+ ```ruby
33
+ puts "code to test (should output something)"
34
+ #=> code to test (should output something)
35
+ ```
38
36
 
39
37
  This document itself serves as the test suite for this gem, so you can take a
40
38
  look at its source.
@@ -98,8 +96,7 @@ success = runner.run
98
96
 
99
97
 
100
98
 
101
- Examples
102
- --------------------------------------------------
99
+ ## Examples
103
100
 
104
101
  Code examples that you want to test, should output something to stdout.
105
102
  Specify the expected output by prefixing it with `#=>`:
@@ -218,4 +215,3 @@ SOME_ENV_VAR=yes
218
215
  echo $SOME_ENV_VAR
219
216
  #=> yes
220
217
  ```
221
-
data/bin/docspec CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- if Gem.loaded_specs.has_key?('simplecov') and !ENV['DISABLE_SIMPLECOV']
2
+ if Gem.loaded_specs.has_key?('simplecov') && !ENV['DISABLE_SIMPLECOV']
3
3
  require 'simplecov'
4
4
  SimpleCov.configure do
5
5
  command_name ENV['SIMPLECOV_COMMAND'] || 'Docspec'
data/lib/docspec/cli.rb CHANGED
@@ -5,7 +5,7 @@ module Docspec
5
5
  class CLI
6
6
  attr_reader :target, :exit_code, :total_examples, :failed_examples
7
7
 
8
- def initialize(target=nil)
8
+ def initialize(target = nil)
9
9
  @target = target || 'README.md'
10
10
  end
11
11
 
@@ -33,9 +33,9 @@ module Docspec
33
33
 
34
34
  def run_dir
35
35
  all_success = true
36
- Dir["#{target}/**/*.md"].each do |file|
36
+ Dir["#{target}/**/*.md"].sort.each do |file|
37
37
  say ''
38
- say "!txtcyn!file : #{file}"
38
+ say "c`file : #{file}`"
39
39
  success = run_file file
40
40
  all_success = false unless success
41
41
  end
@@ -45,27 +45,23 @@ module Docspec
45
45
  def run_file(file)
46
46
  document = Docspec::Document.from_file file
47
47
  document.test
48
-
48
+
49
49
  @failed_examples += document.failed_examples.count
50
50
  @total_examples += document.examples.count
51
-
51
+
52
52
  document.success?
53
53
  end
54
54
 
55
55
  def show_footer
56
56
  say ''
57
57
 
58
- if failed_examples == 0
59
- say "!txtgrn!#{total_examples} tests, #{failed_examples} failed\n"
58
+ if failed_examples.zero?
59
+ say "g`#{total_examples} tests, #{failed_examples} failed`\n"
60
60
  true
61
61
  else
62
- say "!txtred!#{total_examples} tests, #{failed_examples} failed\n"
62
+ say "r`#{total_examples} tests, #{failed_examples} failed`\n"
63
63
  false
64
64
  end
65
65
  end
66
-
67
66
  end
68
67
  end
69
-
70
-
71
-
@@ -25,16 +25,15 @@ module Docspec
25
25
  result = []
26
26
  markdown.scan(/```(ruby|shell)\s*\n(.*?)```/m) do |type, code|
27
27
  example = Example.new(type: type, code: code, before: before[type])
28
-
28
+
29
29
  next if example.skip?
30
30
 
31
31
  before[type] ||= []
32
32
  before[type] << example.code if example.empty?
33
-
33
+
34
34
  result << example
35
35
  end
36
36
  result
37
37
  end
38
-
39
38
  end
40
39
  end
@@ -6,7 +6,9 @@ module Docspec
6
6
  attr_reader :code, :type, :before
7
7
 
8
8
  def initialize(type:, code:, before: nil)
9
- @code, @type, @before = code, type, before
9
+ @code = code
10
+ @type = type
11
+ @before = before
10
12
  end
11
13
 
12
14
  def actual
@@ -76,12 +78,12 @@ module Docspec
76
78
 
77
79
  def full_code!
78
80
  return code unless before
81
+
79
82
  [before.join("\n\n"), code].join "\n"
80
83
  end
81
84
 
82
85
  def label!
83
86
  first_line.gsub(/^#\s*/, '').strip
84
87
  end
85
-
86
88
  end
87
89
  end
@@ -5,7 +5,7 @@ module Docspec
5
5
  include Colsole
6
6
 
7
7
  def success?
8
- failed_examples.count == 0
8
+ failed_examples.count.zero?
9
9
  end
10
10
 
11
11
  def failed_examples
@@ -15,18 +15,16 @@ module Docspec
15
15
  def test
16
16
  examples.each do |example|
17
17
  if example.empty?
18
- say "!txtpur!void :!txtrst! #{example.label}"
18
+ say "m`void :` #{example.label}"
19
19
  elsif example.success?
20
- say "!txtgrn!pass :!txtrst! #{example.label}"
20
+ say "g`pass :` #{example.label}"
21
21
  else
22
- say "!txtred!FAIL : #{example.label}"
23
- say "---"
22
+ say "r`FAIL : #{example.label}`"
23
+ say '---'
24
24
  puts example.diff
25
- say "---"
25
+ say '---'
26
26
  end
27
27
  end
28
28
  end
29
-
30
29
  end
31
30
  end
32
-
@@ -1,3 +1,3 @@
1
1
  module Docspec
2
- VERSION = "0.1.2"
3
- end
2
+ VERSION = '0.1.3'
3
+ end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-16 00:00:00.000000000 Z
11
+ date: 2023-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.1
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '0.5'
22
+ version: '2.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.1
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '0.5'
32
+ version: '2.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: diffy
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -57,7 +63,8 @@ files:
57
63
  homepage: https://github.com/dannyben/docspec
58
64
  licenses:
59
65
  - MIT
60
- metadata: {}
66
+ metadata:
67
+ rubygems_mfa_required: 'true'
61
68
  post_install_message:
62
69
  rdoc_options: []
63
70
  require_paths:
@@ -66,14 +73,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
73
  requirements:
67
74
  - - ">="
68
75
  - !ruby/object:Gem::Version
69
- version: 2.3.0
76
+ version: '2.7'
70
77
  required_rubygems_version: !ruby/object:Gem::Requirement
71
78
  requirements:
72
79
  - - ">="
73
80
  - !ruby/object:Gem::Version
74
81
  version: '0'
75
82
  requirements: []
76
- rubygems_version: 3.0.3
83
+ rubygems_version: 3.4.8
77
84
  signing_key:
78
85
  specification_version: 4
79
86
  summary: Embedded tests in Markdown documents