pork 2.0.0 → 2.1.1

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
- SHA1:
3
- metadata.gz: 66af2258263479b7c9b46d32d87dab94300c86c7
4
- data.tar.gz: dd01950d9a7026886e35b48054c97c5f69f6e6fa
2
+ SHA256:
3
+ metadata.gz: 596db0c7a57f78124695173043a466b426fe566953ff8e1dadea87a0a2e9f0a3
4
+ data.tar.gz: 5e22ec778834be1ab5181e6ea87bd24ac9c493e6f2d08ff5646de0dbd7b72910
5
5
  SHA512:
6
- metadata.gz: '0584b1e173a3d0190b28ebfddba0475ff9e47e85d51081a8f5401f789f8ee1e7aa3cd1680efd58d0fd44d4e444fecc567fcec86ca13fa66eb6525baeeb29dd58'
7
- data.tar.gz: 5705b43ac037712e230b6249f41f1ff12a1347e23a1bdf84632603878910ecf6f9d9a2e9c9e1c0400ea953453a232874caadb5694c8577b6b3a9220b3f45ee16
6
+ metadata.gz: 3b62085c73fa8b13b6acddc3c0a40ac734dc6b9d358401a8badbc546d56456ccb941f55382b2dca037fa18c5fddfc0b1d40d157a53cf8dc8f1bf1ce84890967b
7
+ data.tar.gz: 8a047f3794853b776eb2d1a31de8d7c2f628bc6c8e09cead7eb76b3352d4c612eb3cd500595f3d6a51d2887a27162cca826e0e93e6774edb7be116578c8ad6cb
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,35 @@
1
+ stages:
2
+ - test
3
+
4
+ .test:
5
+ stage: test
6
+ image: ruby:${RUBY_VERSION}-alpine
7
+ variables:
8
+ GIT_DEPTH: "1"
9
+ GIT_SUBMODULE_STRATEGY: recursive
10
+ GIT_SUBMODULE_PATHS: task
11
+ RUBYOPT: --enable-frozen-string-literal
12
+ before_script:
13
+ - if command -v apk > /dev/null; then apk add --no-cache git diffutils; fi # git for pulling fork for method_source
14
+ - bundle install --retry=3
15
+ - unset CI # Don't run coverage
16
+ script:
17
+ - ruby -vr bundler/setup -S rake test
18
+
19
+ ruby:3.4:
20
+ extends: .test
21
+ variables:
22
+ RUBY_VERSION: '3.4'
23
+
24
+ ruby:4.0:
25
+ extends: .test
26
+ variables:
27
+ RUBY_VERSION: '4.0'
28
+
29
+ jruby:latest:
30
+ extends: .test
31
+ image: jruby:latest
32
+ before_script:
33
+ - apt-get update && apt-get install -y git # git for pulling fork for method_source
34
+ - bundle install --retry=3
35
+ - unset CI # Don't run coverage
data/.gitmodules CHANGED
@@ -1,3 +1,3 @@
1
1
  [submodule "task"]
2
2
  path = task
3
- url = git://github.com/godfat/gemgem.git
3
+ url = https://github.com/godfat/gemgem.git
data/CHANGES.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # CHANGES
2
2
 
3
+ ## Pork 2.1.1 -- 2026-11-23
4
+
5
+ ### Enhancement
6
+
7
+ * Introduced `Pork.I_am_feeling_lucky!` which is `Rainbows! if rand(10) == 0`.
8
+ Just for fun after 4 years!
9
+
10
+ ## Pork 2.1.0 -- 2022-12-28
11
+
12
+ ### Bugs fixed
13
+
14
+ * `Pork.show_source` can work under frozen literal string mode now.
15
+ * Fix picking the right test for the file line number from `ENV['PORK_TEST']`
16
+ (I totally forgot the details for this from 2017, but I think it should
17
+ make it more accurate anyway)
18
+ * Ruby 3.2 compatibility fix. (Removed the use of `Random::DEFAULT`)
19
+
20
+ ### Enhancement
21
+
22
+ * Introduced `Pork::API.around` which will pass the test object to the block,
23
+ and whenever the object is called with `call` it'll run the test. Note that
24
+ if `call` was never called, it'll act like `Pork::API.before` and the test
25
+ will still run unlike RSpec. To skip the test, call `skip` directly.
26
+
3
27
  ## Pork 2.0.0 -- 2016-09-10
4
28
 
5
29
  ### Incompatible changes
data/Gemfile CHANGED
@@ -5,9 +5,6 @@ gemspec
5
5
 
6
6
  gem 'rake'
7
7
 
8
- gem 'simplecov', :require => false if ENV['COV']
9
- gem 'coveralls', :require => false if ENV['CI']
10
-
11
- platform :rbx do
12
- gem 'rubysl-singleton' # used in rake
13
- end
8
+ gem 'method_source',
9
+ git: 'https://github.com/OskarEichler/method_source.git',
10
+ ref: 'codex/prism-hash-literal'
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
- # Pork [![Build Status](https://secure.travis-ci.org/godfat/pork.png?branch=master)](http://travis-ci.org/godfat/pork) [![Coverage Status](https://coveralls.io/repos/godfat/pork/badge.png)](https://coveralls.io/r/godfat/pork) [![Join the chat at https://gitter.im/godfat/pork](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/godfat/pork)
1
+ # Pork [![Pipeline status](https://gitlab.com/godfat/pork/badges/master/pipeline.svg)](https://gitlab.com/godfat/pork/-/pipelines)
2
2
 
3
- by Lin Jen-Shin ([godfat](http://godfat.org))
3
+ by Lin Jen-Shin ([godfat](https://godfat.org))
4
4
 
5
5
  ## LINKS:
6
6
 
7
7
  * [github](https://github.com/godfat/pork)
8
8
  * [rubygems](https://rubygems.org/gems/pork)
9
- * [rdoc](http://rdoc.info/github/godfat/pork)
9
+ * [rdoc](https://rubydoc.info/github/godfat/pork)
10
+ * [issues](https://github.com/godfat/pork/issues) (feel free to ask for support)
10
11
 
11
12
  ## DESCRIPTION:
12
13
 
@@ -147,7 +148,7 @@ end
147
148
 
148
149
  ## REQUIREMENTS:
149
150
 
150
- * Tested with MRI (official CRuby), Rubinius and JRuby.
151
+ * Tested with MRI (official CRuby) and JRuby.
151
152
  * (Optional) [method_source][] if you would like to print the source for the
152
153
  failing tests.
153
154
  * (Optional) [ruby-progressbar][] if you like porgressbar for showing
@@ -365,7 +366,7 @@ With Bash shell:
365
366
  Personally I have a [rake task][gemgem] which would do this for me, so I just
366
367
  run `rake test` to run all the tests.
367
368
 
368
- [Fish shell]: http://fishshell.com/
369
+ [Fish shell]: https://fishshell.com
369
370
  [gemgem]: https://github.com/godfat/gemgem
370
371
 
371
372
  ## The API
@@ -662,6 +663,49 @@ describe do
662
663
  end
663
664
  ```
664
665
 
666
+ ### Pork::API.around
667
+
668
+ Each `around` block would be called before each `would` block (test case),
669
+ and whenever it's called, it can take an argument representing the `would`
670
+ block (test case). Whenever `call` is called on the test case, it will run.
671
+ Essentially it's wrapping around the `would` block.
672
+
673
+ Note that each nested `describe` would also run parents' `around` block,
674
+ following the same order of `before` (in order) and `after` (reverse order).
675
+
676
+ ``` ruby
677
+ require 'pork/auto'
678
+
679
+ describe do
680
+ around do |test|
681
+ @a = 0
682
+
683
+ test.call
684
+
685
+ @a.should.eq 2
686
+ end
687
+
688
+ describe do
689
+ around do |test|
690
+ @a.should.eq 0
691
+ @a += 1
692
+
693
+ test.call
694
+
695
+ @a.should.eq 1
696
+ @a += 1
697
+ end
698
+
699
+ would do
700
+ @a.should.eq 1
701
+ end
702
+ end
703
+ end
704
+ ```
705
+
706
+ Note that if `test.call` was never called, it'll just act like a `before`
707
+ block. All the tests will still run unlike RSpec.
708
+
665
709
  ### Pork::API.copy and Pork::API.paste
666
710
 
667
711
  It could be a bit confusing at first, but just think of `copy` as a way to
@@ -1068,15 +1112,15 @@ Have you seen Rainbows!?
1068
1112
 
1069
1113
  ## LICENSE:
1070
1114
 
1071
- Apache License 2.0
1115
+ Apache License 2.0 (Apache-2.0)
1072
1116
 
1073
- Copyright (c) 2014-2016, Lin Jen-Shin (godfat)
1117
+ Copyright (c) 2014-2026, Lin Jen-Shin (godfat)
1074
1118
 
1075
1119
  Licensed under the Apache License, Version 2.0 (the "License");
1076
1120
  you may not use this file except in compliance with the License.
1077
1121
  You may obtain a copy of the License at
1078
1122
 
1079
- <http://www.apache.org/licenses/LICENSE-2.0>
1123
+ <https://www.apache.org/licenses/LICENSE-2.0>
1080
1124
 
1081
1125
  Unless required by applicable law or agreed to in writing, software
1082
1126
  distributed under the License is distributed on an "AS IS" BASIS,
data/Rakefile CHANGED
@@ -1,16 +1,17 @@
1
1
 
2
2
  begin
3
- require "#{dir = File.dirname(__FILE__)}/task/gemgem"
3
+ require "#{__dir__}/task/gemgem"
4
4
  rescue LoadError
5
- sh 'git submodule update --init'
5
+ sh 'git submodule update --init --recursive'
6
6
  exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
7
7
  end
8
8
 
9
- Gemgem.init(dir) do |s|
9
+ Gemgem.init(__dir__) do |s|
10
10
  require 'pork/version'
11
11
  s.name = 'pork'
12
12
  s.version = Pork::VERSION
13
+ s.files.delete('screenshot.png')
14
+
13
15
  %w[method_source ruby-progressbar].
14
16
  each(&s.method(:add_development_dependency))
15
- s.files.delete('screenshot.png')
16
17
  end
data/TODO.md CHANGED
@@ -1,3 +1,37 @@
1
1
 
2
2
  * introduce configs
3
3
  * executable
4
+ * [BUG] Picking the top-level describe block should pick up tests for nested
5
+ describe block. For the following it should pick all the tests for the
6
+ top level describe.
7
+
8
+ ``` ruby
9
+ describe 'set the same visibility from the original method' do
10
+ copy :test do
11
+ def find_visibilities klass
12
+ %i[public protected private].map do |v|
13
+ klass.send("#{v}_method_defined?", :hello)
14
+ end
15
+ end
16
+
17
+ would do
18
+ visibilities = find_visibilities(klass)
19
+
20
+ stub(klass).hello{ :stub }
21
+
22
+ expect(visibilities).eq find_visibilities(klass)
23
+ end
24
+ end
25
+
26
+ describe 'for direct method' do
27
+ def klass
28
+ @klass ||= Class.new do
29
+ private
30
+ def hello; :hello; end
31
+ end
32
+ end
33
+
34
+ paste :test
35
+ end
36
+ end
37
+ ```
data/lib/pork/api.rb CHANGED
@@ -12,6 +12,10 @@ module Pork
12
12
  Suite.after(&block)
13
13
  end
14
14
 
15
+ def around &block
16
+ Suite.around(&block)
17
+ end
18
+
15
19
  def copy desc=:default, &block
16
20
  Suite.copy(desc, &block)
17
21
  end
@@ -3,12 +3,31 @@ require 'method_source'
3
3
 
4
4
  module Pork
5
5
  module ShowSource
6
+ module FrozenStringFix
7
+ def extract_first_expression(lines, consume=0, &block)
8
+ code = consume.zero? ? [] : lines.slice!(0..(consume - 1))
9
+
10
+ lines.each do |v|
11
+ code << v
12
+
13
+ result = block ? block.call(code.join) : code.join
14
+
15
+ if complete_expression?(result)
16
+ return result
17
+ end
18
+ end
19
+ raise SyntaxError, "unexpected $end"
20
+ end
21
+ end
22
+
23
+ MethodSource.extend(FrozenStringFix)
24
+
6
25
  def show_source test, err
7
26
  source = test.source
8
27
  sopath = "#{test.source_location.first}:"
9
28
  lowers = test.source_location.last
10
29
  uppers = lowers + source.size
11
- lineno = reject_pork(test, err).find do |backtrace|
30
+ lineno = reject_pork(test, err.backtrace).find do |backtrace|
12
31
  # find the line from the test source, exclude everything else
13
32
  next unless backtrace.start_with?(sopath)
14
33
  number = backtrace[/(?<=\.rb:)\d+/].to_i
@@ -28,7 +47,7 @@ module Pork
28
47
  end
29
48
  end.join
30
49
  "\n#{result.chomp}"
31
- rescue SyntaxError => e
50
+ rescue SyntaxError, MethodSource::SourceNotFoundError => e
32
51
  "\nPork bug: Cannot parse the source. Please report: #{e}"
33
52
  end
34
53
  end
data/lib/pork/inspect.rb CHANGED
@@ -33,7 +33,7 @@ module Pork
33
33
  Inspect.new(false).diff_hash(expect, args.first).
34
34
  merge(Inspect.new(true).diff_hash(args.first, expect)))
35
35
  else
36
- with_inline(Hash[expect.sort], msg, [Hash[args.first.sort]], negate)
36
+ with_inline(expect.sort.to_h, msg, [args.first.sort.to_h], negate)
37
37
  end
38
38
 
39
39
  elsif expect.kind_of?(String) && expect.size > 400 &&
data/lib/pork/isolator.rb CHANGED
@@ -68,38 +68,78 @@ module Pork
68
68
 
69
69
  def build_all_tests result={}, path=[]
70
70
  suite.tests.each_with_index.inject(result) do |
71
- r, ((type, imp, test, opts), index)|
71
+ tests, ((type, imp, block, opts), index)|
72
72
  current = path + [index]
73
73
 
74
+ case type
75
+ when :describe, :would
76
+ source_location = expand_source_location(block)
77
+ init_source_store_path(tests, source_location)
78
+ end
79
+
74
80
  case type
75
81
  when :describe
76
- Isolator[imp].build_all_tests(r, current) do |nested|
77
- store_path(r, nested, test, opts[:groups])
82
+ Isolator[imp].build_all_tests(tests, current) do |nested|
83
+ store_path(tests, nested, source_location, opts[:groups])
78
84
  end
79
85
  when :would
80
86
  yield(current) if block_given?
81
- store_path(r, current, test, opts[:groups])
87
+ store_path(tests, current, source_location, opts[:groups])
82
88
  end
83
89
 
84
- r
90
+ tests
85
91
  end
86
92
  end
87
93
 
88
- def store_path tests, path, test, groups
94
+ def expand_source_location block
95
+ file, line = block.source_location
96
+ [File.expand_path(file), line]
97
+ end
98
+
99
+ def init_source_store_path tests, source_location
100
+ source, line = source_location
101
+
102
+ root = tests[:files] ||= {}
103
+ map = root[source] ||= {}
104
+
105
+ # Most of the time, line is always getting larger because we're
106
+ # scanning from top to bottom, and we really need to make sure
107
+ # that the map is sorted because whenever we're looking up which
108
+ # test we want from a particular line, we want to find the closest
109
+ # block rounding up. See Isolator#by_source
110
+ # However, it's not always appending from top to bottom, because
111
+ # we might be adding more tests from Suite#paste, and the original
112
+ # test could be defined in the same file, on previous lines!
113
+ # Because of this, we really need to make sure the map is balanced.
114
+ # If we ever have ordered map in Ruby, we don't have to do this...
115
+ # See the test for Isolator.all_tests (test/test_isolator.rb)
116
+ balanced_append(map, line, [])
117
+ end
118
+
119
+ def store_path tests, path, source_location, groups
89
120
  store_for_groups(tests, path, groups) if groups
90
- store_for_source(tests, path, *test.source_location)
121
+ store_for_source(tests, path, source_location)
91
122
  end
92
123
 
93
124
  def store_for_groups tests, path, groups
94
- r = tests[:groups] ||= {}
125
+ map = tests[:groups] ||= {}
95
126
  groups.each do |g|
96
- (r[g.to_s] ||= []) << path
127
+ (map[g.to_s] ||= []) << path
97
128
  end
98
129
  end
99
130
 
100
- def store_for_source tests, path, file, line
101
- r = tests[:files] ||= {}
102
- ((r[File.expand_path(file)] ||= {})[line] ||= []) << path
131
+ def store_for_source tests, path, source_location
132
+ source, line = source_location
133
+
134
+ tests[:files][source][line] << path
135
+ end
136
+
137
+ def balanced_append map, key, value
138
+ last_key = map.reverse_each.first.first unless map.empty?
139
+
140
+ map[key] ||= []
141
+
142
+ map.replace(Hash[map.sort]) if last_key && key < last_key
103
143
  end
104
144
  end
105
145
  end
@@ -1,7 +1,9 @@
1
1
 
2
2
  module Kernel
3
3
  def should *args, &block
4
- stat = Thread.current.group.list.find{ |t| t[:pork_stat] }[:pork_stat]
4
+ stat = Thread.current.group.list.find do |t|
5
+ t.thread_variable_get(:pork_stat)
6
+ end.thread_variable_get(:pork_stat)
5
7
  Pork::Expect.new(stat, self, *args, &block)
6
8
  end
7
9
  end
@@ -11,12 +13,12 @@ module Pork
11
13
  def execute stat=Stat.new, *args
12
14
  thread = Thread.current
13
15
  original_group, group = thread.group, ThreadGroup.new
14
- original_stat = thread[:pork_stat]
16
+ original_stat = thread.thread_variable_get(:pork_stat)
15
17
  group.add(thread)
16
- thread[:pork_stat] = stat
18
+ thread.thread_variable_set(:pork_stat, stat)
17
19
  super(stat, *args)
18
20
  ensure
19
- thread[:pork_stat] = original_stat
21
+ thread.thread_variable_set(:pork_stat, original_stat)
20
22
  original_group.add(thread)
21
23
  end
22
24
  end
data/lib/pork/report.rb CHANGED
@@ -86,10 +86,16 @@ module Pork
86
86
  end
87
87
 
88
88
  def backtrace test, err
89
- if $VERBOSE
89
+ bt = if $VERBOSE
90
90
  err.backtrace
91
91
  else
92
- strip(reject_pork(test, err))
92
+ strip(reject_pork(test, err.backtrace))
93
+ end
94
+
95
+ if bt.empty?
96
+ ["#{test.source_location.join(':')}:in `block in would'"]
97
+ else
98
+ bt
93
99
  end
94
100
  end
95
101
 
@@ -113,13 +119,8 @@ module Pork
113
119
  "#{err.class}: #{err.message}"
114
120
  end
115
121
 
116
- def reject_pork test, err
117
- bt = err.backtrace.reject{ |l| l =~ %r{/lib/pork(/\w+)*\.rb:\d+} }
118
- if bt.empty?
119
- ["#{test.source_location.join(':')}:in `block in would'"]
120
- else
121
- bt
122
- end
122
+ def reject_pork test, bt
123
+ bt.reject{ |l| l =~ %r{/lib/pork(/\w+)*\.rb:\d+} }
123
124
  end
124
125
 
125
126
  def strip bt
@@ -127,11 +128,13 @@ module Pork
127
128
  end
128
129
 
129
130
  def strip_home bt
130
- bt.map{ |path| path.sub(ENV['HOME'], '~') }
131
+ home = ENV['HOME']
132
+ bt.map{ |path| path.sub(home, '~') }
131
133
  end
132
134
 
133
135
  def strip_cwd bt
134
- bt.map{ |path| path.sub("#{Dir.pwd}/", '') }
136
+ cwd = Dir.pwd
137
+ bt.map{ |path| path.sub("#{cwd}/", '') }
135
138
  end
136
139
 
137
140
  def pork_test source_location
data/lib/pork/runner.rb CHANGED
@@ -5,7 +5,7 @@ module Pork
5
5
  class Runner < Struct.new(:suite, :seed, :stat, :desc, :test, :env)
6
6
  def run
7
7
  assertions = stat.assertions
8
- context = suite.new(stat, desc)
8
+ context = suite.new(stat, desc, [])
9
9
 
10
10
  stat.reporter.case_start(context)
11
11
 
data/lib/pork/suite.rb CHANGED
@@ -1,15 +1,30 @@
1
1
 
2
+ require 'fiber'
3
+
2
4
  require 'pork/runner'
3
5
  require 'pork/context'
4
6
 
5
7
  module Pork
6
- class Suite < Struct.new(:pork_stat, :pork_description)
8
+ class Suite < Struct.new(:pork_stat, :pork_description, :pork_fibers)
7
9
  module Imp
8
10
  attr_reader :desc, :tests
9
11
 
10
12
  def before &block; @tests << [:before, block]; end
11
13
  def after &block; @tests << [:after , block]; end
12
14
 
15
+ def around &block
16
+ before do
17
+ fiber = Fiber.new{ instance_exec(Fiber.method(:yield), &block) }
18
+ pork_fibers << fiber
19
+ fiber.resume
20
+ end
21
+
22
+ after do
23
+ fiber = pork_fibers.pop
24
+ fiber.resume if fiber.alive?
25
+ end
26
+ end
27
+
13
28
  def copy desc=:default, &suite
14
29
  @stash[desc] = suite
15
30
  end
data/lib/pork/test.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  require 'pork/auto'
3
3
 
4
4
  Pork.show_source
5
- Pork.Rainbows! if rand(10) == 0
5
+ Pork.I_am_feeling_lucky!
6
6
 
7
7
  WebMockError = Class.new(Exception)
8
8
  Pork.protected_exceptions << WebMockError
data/lib/pork/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Pork
3
- VERSION = '2.0.0'
3
+ VERSION = '2.1.1'
4
4
  end
data/lib/pork.rb CHANGED
@@ -31,6 +31,10 @@ module Pork
31
31
  @protected_exceptions ||= [Pork::Error, StandardError]
32
32
  end
33
33
 
34
+ def self.I_am_feeling_lucky!
35
+ Rainbows! if rand(10) == 0
36
+ end
37
+
34
38
  def self.Rainbows!
35
39
  require 'pork/extra/rainbows'
36
40
  report_extensions << Rainbows
@@ -46,11 +50,7 @@ module Pork
46
50
  end
47
51
 
48
52
  def self.seed
49
- @seed ||= if Random.const_defined?(:DEFAULT)
50
- Random::DEFAULT.seed
51
- else
52
- Thread.current.randomizer.seed # Rubinius (rbx)
53
- end
53
+ @seed ||= Random.seed
54
54
  end
55
55
 
56
56
  def self.reseed
data/pork.gemspec CHANGED
@@ -1,20 +1,20 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: pork 2.0.0 ruby lib
2
+ # stub: pork 2.1.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "pork".freeze
6
- s.version = "2.0.0"
6
+ s.version = "2.1.1".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Lin Jen-Shin (godfat)".freeze]
11
- s.date = "2016-09-10"
11
+ s.date = "2026-11-23"
12
12
  s.description = "Pork -- Simple and clean and modular testing library.\n\nInspired by [Bacon][].\n\n[Bacon]: https://github.com/chneukirchen/bacon".freeze
13
13
  s.email = ["godfat (XD) godfat.org".freeze]
14
14
  s.files = [
15
15
  ".gitignore".freeze,
16
+ ".gitlab-ci.yml".freeze,
16
17
  ".gitmodules".freeze,
17
- ".travis.yml".freeze,
18
18
  "CHANGES.md".freeze,
19
19
  "Gemfile".freeze,
20
20
  "LICENSE".freeze,
@@ -52,42 +52,38 @@ Gem::Specification.new do |s|
52
52
  "pork.gemspec".freeze,
53
53
  "task/README.md".freeze,
54
54
  "task/gemgem.rb".freeze,
55
+ "test/test_around.rb".freeze,
55
56
  "test/test_bacon.rb".freeze,
56
57
  "test/test_expect.rb".freeze,
57
58
  "test/test_inspect.rb".freeze,
59
+ "test/test_isolator.rb".freeze,
58
60
  "test/test_meta.rb".freeze,
59
61
  "test/test_nested.rb".freeze,
60
62
  "test/test_pork_test.rb".freeze,
61
63
  "test/test_readme.rb".freeze,
62
64
  "test/test_should.rb".freeze,
63
- "test/test_stat.rb".freeze]
65
+ "test/test_stat.rb".freeze,
66
+ "test/test_suite.rb".freeze]
64
67
  s.homepage = "https://github.com/godfat/pork".freeze
65
- s.licenses = ["Apache License 2.0".freeze]
66
- s.rubygems_version = "2.6.6".freeze
68
+ s.licenses = ["Apache-2.0".freeze]
69
+ s.rubygems_version = "4.1.0".freeze
67
70
  s.summary = "Pork -- Simple and clean and modular testing library.".freeze
68
71
  s.test_files = [
72
+ "test/test_around.rb".freeze,
69
73
  "test/test_bacon.rb".freeze,
70
74
  "test/test_expect.rb".freeze,
71
75
  "test/test_inspect.rb".freeze,
76
+ "test/test_isolator.rb".freeze,
72
77
  "test/test_meta.rb".freeze,
73
78
  "test/test_nested.rb".freeze,
74
79
  "test/test_pork_test.rb".freeze,
75
80
  "test/test_readme.rb".freeze,
76
81
  "test/test_should.rb".freeze,
77
- "test/test_stat.rb".freeze]
82
+ "test/test_stat.rb".freeze,
83
+ "test/test_suite.rb".freeze]
78
84
 
79
- if s.respond_to? :specification_version then
80
- s.specification_version = 4
85
+ s.specification_version = 4
81
86
 
82
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
83
- s.add_development_dependency(%q<method_source>.freeze, [">= 0"])
84
- s.add_development_dependency(%q<ruby-progressbar>.freeze, [">= 0"])
85
- else
86
- s.add_dependency(%q<method_source>.freeze, [">= 0"])
87
- s.add_dependency(%q<ruby-progressbar>.freeze, [">= 0"])
88
- end
89
- else
90
- s.add_dependency(%q<method_source>.freeze, [">= 0"])
91
- s.add_dependency(%q<ruby-progressbar>.freeze, [">= 0"])
92
- end
87
+ s.add_development_dependency("method_source".freeze, [">= 0".freeze])
88
+ s.add_development_dependency("ruby-progressbar".freeze, [">= 0".freeze])
93
89
  end
data/task/README.md CHANGED
@@ -4,32 +4,32 @@
4
4
 
5
5
  Provided tasks:
6
6
 
7
- rake clean # Remove ignored files
7
+ rake clean # Trash ignored files
8
8
  rake gem:build # Build gem
9
9
  rake gem:install # Install gem
10
10
  rake gem:release # Release gem
11
11
  rake gem:spec # Generate gemspec
12
- rake test # Run tests in memory
12
+ rake test # Run tests
13
13
 
14
14
  ## REQUIREMENTS:
15
15
 
16
- * Tested with MRI (official CRuby) 1.9.3, 2.0.0, Rubinius and JRuby.
16
+ * Tested with MRI (official CRuby) and JRuby.
17
17
 
18
18
  ## INSTALLATION:
19
19
 
20
- git submodule add git://github.com/godfat/gemgem.git task
20
+ git submodule add https://github.com/godfat/gemgem.git task
21
21
 
22
22
  And in Rakefile:
23
23
 
24
24
  ``` ruby
25
25
  begin
26
- require "#{dir = File.dirname(__FILE__)}/task/gemgem"
26
+ require "#{__dir__}/task/gemgem"
27
27
  rescue LoadError
28
- sh 'git submodule update --init'
28
+ sh 'git submodule update --init --recursive'
29
29
  exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
30
30
  end
31
31
 
32
- Gemgem.init(dir) do |s|
32
+ Gemgem.init(__dir__, :submodules => %w[your-dep]) do |s|
33
33
  s.name = 'your-gem'
34
34
  s.version = '0.1.0'
35
35
  end
@@ -37,15 +37,15 @@ end
37
37
 
38
38
  ## LICENSE:
39
39
 
40
- Apache License 2.0
40
+ Apache License 2.0 (Apache-2.0)
41
41
 
42
- Copyright (c) 2011-2013, Lin Jen-Shin (godfat)
42
+ Copyright (c) 2011-2023, Lin Jen-Shin (godfat)
43
43
 
44
44
  Licensed under the Apache License, Version 2.0 (the "License");
45
45
  you may not use this file except in compliance with the License.
46
46
  You may obtain a copy of the License at
47
47
 
48
- <http://www.apache.org/licenses/LICENSE-2.0>
48
+ <https://www.apache.org/licenses/LICENSE-2.0>
49
49
 
50
50
  Unless required by applicable law or agreed to in writing, software
51
51
  distributed under the License is distributed on an "AS IS" BASIS,
data/task/gemgem.rb CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Gemgem
3
3
  class << self
4
- attr_accessor :dir, :spec, :spec_create
4
+ attr_accessor :dir, :spec, :submodules, :spec_create
5
5
  end
6
6
 
7
7
  module_function
@@ -11,12 +11,14 @@ module Gemgem
11
11
  def pkg_dir ; "#{dir}/pkg" ; end
12
12
  def escaped_dir; @escaped_dir ||= Regexp.escape(dir); end
13
13
 
14
- def init dir, &block
14
+ def init dir, options={}, &block
15
15
  self.dir = dir
16
- $LOAD_PATH.unshift("#{dir}/lib")
17
16
  ENV['RUBYLIB'] = "#{dir}/lib:#{ENV['RUBYLIB']}"
18
17
  ENV['PATH'] = "#{dir}/bin:#{ENV['PATH']}"
18
+ self.submodules = options[:submodules] || []
19
19
  self.spec_create = block
20
+
21
+ $LOAD_PATH.unshift("#{dir}/lib", *submodules_libs)
20
22
  end
21
23
 
22
24
  def create
@@ -26,7 +28,7 @@ module Gemgem
26
28
 
27
29
  s.description = description.join
28
30
  s.summary = description.first
29
- s.license = readme['LICENSE'].sub(/.+\n\n/, '').lines.first.strip
31
+ s.license = license
30
32
 
31
33
  s.date = Time.now.strftime('%Y-%m-%d')
32
34
  s.files = gem_files
@@ -40,6 +42,7 @@ module Gemgem
40
42
 
41
43
  def gem_install
42
44
  require 'rubygems/commands/install_command'
45
+ require 'rubygems/package'
43
46
  # read ~/.gemrc
44
47
  Gem.use_paths(Gem.configuration[:gemhome], Gem.configuration[:gempath])
45
48
  Gem::Command.extra_args = Gem.configuration[:gem]
@@ -49,7 +52,8 @@ module Gemgem
49
52
  cmd.handle_options([])
50
53
 
51
54
  # install
52
- install = Gem::Installer.new(gem_path, cmd.options)
55
+ gem_package = Gem::Package.new(gem_path)
56
+ install = Gem::Installer.new(gem_package, cmd.options)
53
57
  install.install
54
58
  puts "\e[35mGem installed: \e[33m#{strip_path(install.gem_dir)}\e[0m"
55
59
  end
@@ -115,6 +119,7 @@ module Gemgem
115
119
  SimpleCov.start do
116
120
  add_filter('test/')
117
121
  add_filter('test.rb')
122
+ submodules_libs.each(&method(:add_filter))
118
123
  end
119
124
  end
120
125
 
@@ -159,11 +164,15 @@ module Gemgem
159
164
  end
160
165
 
161
166
  def strip_home_path path
162
- path.sub(ENV['HOME'], '~')
167
+ path.sub(/\A#{Regexp.escape(ENV['HOME'])}\//, '~/')
163
168
  end
164
169
 
165
170
  def strip_cwd_path path
166
- path.sub(Dir.pwd, '.')
171
+ path.sub(/\A#{Regexp.escape(Dir.pwd)}\//, '')
172
+ end
173
+
174
+ def submodules_libs
175
+ submodules.map{ |path| "#{dir}/#{path}/lib" }
167
176
  end
168
177
 
169
178
  def git *args
@@ -201,6 +210,11 @@ module Gemgem
201
210
  @description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
202
211
  end
203
212
 
213
+ def license
214
+ readme['LICENSE'].sub(/.+\n\n/, '').lines.first.
215
+ split(/[()]/).map(&:strip).reject(&:empty?).last
216
+ end
217
+
204
218
  def all_files
205
219
  @all_files ||= fold_files(glob).sort
206
220
  end
@@ -221,7 +235,8 @@ module Gemgem
221
235
 
222
236
  def gem_files
223
237
  @gem_files ||= all_files.reject{ |f|
224
- f =~ ignored_pattern && !git_files.include?(f)
238
+ f =~ submodules_pattern ||
239
+ (f =~ ignored_pattern && !git_files.include?(f))
225
240
  }
226
241
  end
227
242
 
@@ -253,6 +268,15 @@ module Gemgem
253
268
  end
254
269
  end
255
270
 
271
+ def submodules_pattern
272
+ @submodules_pattern ||= if submodules.empty?
273
+ /^$/
274
+ else
275
+ Regexp.new(submodules.map{ |path|
276
+ "^#{Regexp.escape(path)}/" }.join('|'))
277
+ end
278
+ end
279
+
256
280
  def expand_patterns pathes
257
281
  # http://git-scm.com/docs/gitignore
258
282
  pathes.flat_map{ |path|
@@ -0,0 +1,64 @@
1
+
2
+ require 'pork/test'
3
+
4
+ describe 'using fibers to simulate around' do
5
+ def a
6
+ @a ||= []
7
+ end
8
+
9
+ def around_me i
10
+ a << "around before #{i}"
11
+ yield
12
+ a << "around after #{i}"
13
+ end
14
+
15
+ before do
16
+ a << :before
17
+ end
18
+
19
+ after do
20
+ expect(a).eq [:before, "around before 0", :nocall, "around before 1",
21
+ :would, :after, "around after 1", "around after 0"]
22
+ end
23
+
24
+ around do |test|
25
+ expect(a).eq [:before]
26
+
27
+ around_me(0) do
28
+ test.call
29
+
30
+ expect(a).eq [:before, "around before 0", :nocall, "around before 1",
31
+ :would, :after, "around after 1"]
32
+ end
33
+ end
34
+
35
+ around do
36
+ expect(a).eq [:before, "around before 0"]
37
+
38
+ a << :nocall
39
+ end
40
+
41
+ around do |test|
42
+ expect(a).eq [:before, "around before 0", :nocall]
43
+
44
+ around_me(1) do
45
+ test.call
46
+
47
+ expect(a).eq [:before, "around before 0", :nocall, "around before 1",
48
+ :would, :after]
49
+ end
50
+ end
51
+
52
+ after do
53
+ expect(a).eq [:before, "around before 0", :nocall, "around before 1",
54
+ :would]
55
+
56
+ a << :after
57
+ end
58
+
59
+ would 'wrap around around' do
60
+ expect(a).eq [:before, "around before 0", :nocall, "around before 1"]
61
+
62
+ a << :would
63
+ end
64
+ end
data/test/test_inspect.rb CHANGED
@@ -3,9 +3,10 @@ require 'pork/test'
3
3
 
4
4
  describe Pork::Inspect do
5
5
  would 'hash' do
6
- Pork::Inspect.with_auto(
7
- {:b => 1, :a => 0}, :==, [{:a => 1, :b => 0}], false).
8
- should.eq '{:a=>0, :b=>1}.==({:a=>1, :b=>0}) to return true'
6
+ a = {:b => 1, :a => 0}
7
+ b = {:a => 1, :b => 0}
8
+ Pork::Inspect.with_auto(a, :==, [b], false).should.
9
+ eq "#{a.sort.to_h.inspect}.==(#{b.sort.to_h.inspect}) to return true"
9
10
  end
10
11
 
11
12
  would 'newline' do
@@ -67,19 +68,23 @@ nil.==(<out-of-bound>) to return true
67
68
  end
68
69
 
69
70
  would '#diff_hash' do
70
- a = {"category_chats"=>[{"category_name"=>"Cat", "experts_url"=>"cat-experts", "chat_list"=>[{"mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "mentor"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}]}], "longterm"=>[{"rate"=>"3.00", "credit"=>"7.00", "valid_from"=>1416148781, "valid_to"=>1416235181, "mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "mentor"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}], "my"=>[], "recent_chats"=>[{"request"=>{}, "type"=>"message", "id"=>"e71bca4b-a617-4edc-9816-7fc3034c64ea", "content"=>"hi", "created_at"=>"2014-11-16T14:39:41Z", "read_at"=>nil, "sender"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "receiver"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}]}
71
+ a_mentor = {"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}
71
72
 
72
- b = {"category_chats"=>[{"category_name"=>"Cat", "experts_url"=>"cat-experts", "chat_list"=>[{"mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}]}], "longterm"=>[{"rate"=>"3.00", "credit"=>"7.00", "valid_from"=>1416148781, "valid_to"=>1416235181, "mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "mentor"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}], "my"=>[{"mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}], "recent_chats"=>[{"request"=>{}, "type"=>"message", "id"=>"e71bca4b-a617-4edc-9816-7fc3034c64ea", "content"=>"hi", "created_at"=>"2014-11-16T14:39:41Z", "read_at"=>nil, "sender"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "receiver"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}]}
73
+ a = {"category_chats"=>[{"category_name"=>"Cat", "experts_url"=>"cat-experts", "chat_list"=>[{"mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "mentor"=>a_mentor, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}]}], "longterm"=>[{"rate"=>"3.00", "credit"=>"7.00", "valid_from"=>1416148781, "valid_to"=>1416235181, "mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "mentor"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}], "my"=>[], "recent_chats"=>[{"request"=>{}, "type"=>"message", "id"=>"e71bca4b-a617-4edc-9816-7fc3034c64ea", "content"=>"hi", "created_at"=>"2014-11-16T14:39:41Z", "read_at"=>nil, "sender"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "receiver"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}]}
74
+
75
+ b_mentee = {"mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}
76
+
77
+ b = {"category_chats"=>[{"category_name"=>"Cat", "experts_url"=>"cat-experts", "chat_list"=>[{"mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}]}], "longterm"=>[{"rate"=>"3.00", "credit"=>"7.00", "valid_from"=>1416148781, "valid_to"=>1416235181, "mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "mentor"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}], "my"=>[b_mentee], "recent_chats"=>[{"request"=>{}, "type"=>"message", "id"=>"e71bca4b-a617-4edc-9816-7fc3034c64ea", "content"=>"hi", "created_at"=>"2014-11-16T14:39:41Z", "read_at"=>nil, "sender"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "receiver"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}]}
73
78
 
74
79
  f = expect.raise(Pork::Failure){ expect(a, 'Additional Message').eq(b) }
75
80
  expect(f.message).eq <<-MSG.sub(/\AExpect/, 'Expect ').chop
76
81
  Expect
77
82
  \tHash with key path: "category_chats"/0/"chat_list"/0/"mentor"
78
- {"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"menmen", "name"=>"Menmen", "level"=>"mentor", "rating"=>0.0, "role"=>"mentor", "avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/556611444ab1143c8ad30206fda3926f?d=mm?s=64&d=mm"}.==(
83
+ #{a_mentor.inspect}.==(
79
84
  <undefined>) to return true
80
85
 
81
86
  \tHash with key path: "my"/0
82
- <out-of-bound>.==({"mentee"=>{"timezone_str"=>"+00:00", "timezone_offset"=>0, "timezone_display"=>"UTC (+00:00)", "username"=>"example", "name"=>"Example", "level"=>"mentor", "rating"=>0.0, "role"=>"user", "avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm", "small_avatar_url"=>"https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mm?s=64&d=mm"}, "chatroom_id"=>"8c3dd9387dd30499a4053e07e4a41be4", "chatroom_firebase_id"=>"49c31f7444e199bdaea610dbe518d329"}) to return true
87
+ <out-of-bound>.==(#{b_mentee.inspect}) to return true
83
88
  Additional Message
84
89
  MSG
85
90
  end
@@ -0,0 +1,29 @@
1
+
2
+ require 'pork/test'
3
+
4
+ describe Pork::Isolator do
5
+ before do
6
+ @suite = Class.new(Pork::Suite){init}
7
+ end
8
+
9
+ describe '.all_tests' do
10
+ would 'have the correct source order' do
11
+ @suite.copy :append do
12
+ would{}
13
+ end
14
+
15
+ @suite.describe do
16
+ describe do
17
+ would{}
18
+ end
19
+
20
+ paste :append
21
+ end
22
+
23
+ Pork::Isolator[@suite].
24
+ all_tests[:files].values.map(&:keys).each do |lines|
25
+ expect(lines).eq lines.sort
26
+ end
27
+ end
28
+ end
29
+ end
data/test/test_nested.rb CHANGED
@@ -14,7 +14,7 @@ describe 'A' do
14
14
 
15
15
  would 'f' do
16
16
  f.should.eq m
17
- f.should.kind_of? Fixnum
17
+ f.should.kind_of? Integer
18
18
  lambda{ f.should.eq '' }.should.raise Pork::Failure
19
19
  end
20
20
 
@@ -0,0 +1,10 @@
1
+
2
+ require 'pork/test'
3
+
4
+ describe Pork::Suite do
5
+ def self.suite_method
6
+ would{ ok }
7
+ end
8
+
9
+ suite_method
10
+ end
metadata CHANGED
@@ -1,43 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pork
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - Lin Jen-Shin (godfat)
8
- autorequire:
7
+ - Lin Jen-Shin (godfat)
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
10
+ date: 2026-11-23 00:00:00.000000000 Z
12
11
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: method_source
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: ruby-progressbar
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
12
+ - !ruby/object:Gem::Dependency
13
+ name: method_source
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ -
17
+ - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: "0"
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ -
25
+ - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: "0"
28
+ - !ruby/object:Gem::Dependency
29
+ name: ruby-progressbar
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ -
33
+ - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ -
41
+ - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
41
44
  description: |-
42
45
  Pork -- Simple and clean and modular testing library.
43
46
 
@@ -45,91 +48,96 @@ description: |-
45
48
 
46
49
  [Bacon]: https://github.com/chneukirchen/bacon
47
50
  email:
48
- - godfat (XD) godfat.org
51
+ - godfat (XD) godfat.org
49
52
  executables: []
50
53
  extensions: []
51
54
  extra_rdoc_files: []
52
55
  files:
53
- - ".gitignore"
54
- - ".gitmodules"
55
- - ".travis.yml"
56
- - CHANGES.md
57
- - Gemfile
58
- - LICENSE
59
- - README.md
60
- - Rakefile
61
- - TODO.md
62
- - lib/pork.rb
63
- - lib/pork/api.rb
64
- - lib/pork/auto.rb
65
- - lib/pork/context.rb
66
- - lib/pork/env.rb
67
- - lib/pork/error.rb
68
- - lib/pork/executor.rb
69
- - lib/pork/expect.rb
70
- - lib/pork/extra/rainbows.rb
71
- - lib/pork/extra/show_source.rb
72
- - lib/pork/inspect.rb
73
- - lib/pork/isolator.rb
74
- - lib/pork/mode/parallel.rb
75
- - lib/pork/mode/sequential.rb
76
- - lib/pork/mode/shuffled.rb
77
- - lib/pork/more.rb
78
- - lib/pork/more/bottomup_backtrace.rb
79
- - lib/pork/more/color.rb
80
- - lib/pork/more/should.rb
81
- - lib/pork/report.rb
82
- - lib/pork/report/description.rb
83
- - lib/pork/report/dot.rb
84
- - lib/pork/report/progressbar.rb
85
- - lib/pork/runner.rb
86
- - lib/pork/stat.rb
87
- - lib/pork/suite.rb
88
- - lib/pork/test.rb
89
- - lib/pork/version.rb
90
- - pork.gemspec
91
- - task/README.md
92
- - task/gemgem.rb
93
- - test/test_bacon.rb
94
- - test/test_expect.rb
95
- - test/test_inspect.rb
96
- - test/test_meta.rb
97
- - test/test_nested.rb
98
- - test/test_pork_test.rb
99
- - test/test_readme.rb
100
- - test/test_should.rb
101
- - test/test_stat.rb
102
- homepage: https://github.com/godfat/pork
56
+ - .gitignore
57
+ - .gitlab-ci.yml
58
+ - .gitmodules
59
+ - CHANGES.md
60
+ - Gemfile
61
+ - LICENSE
62
+ - README.md
63
+ - Rakefile
64
+ - TODO.md
65
+ - lib/pork.rb
66
+ - lib/pork/api.rb
67
+ - lib/pork/auto.rb
68
+ - lib/pork/context.rb
69
+ - lib/pork/env.rb
70
+ - lib/pork/error.rb
71
+ - lib/pork/executor.rb
72
+ - lib/pork/expect.rb
73
+ - lib/pork/extra/rainbows.rb
74
+ - lib/pork/extra/show_source.rb
75
+ - lib/pork/inspect.rb
76
+ - lib/pork/isolator.rb
77
+ - lib/pork/mode/parallel.rb
78
+ - lib/pork/mode/sequential.rb
79
+ - lib/pork/mode/shuffled.rb
80
+ - lib/pork/more.rb
81
+ - lib/pork/more/bottomup_backtrace.rb
82
+ - lib/pork/more/color.rb
83
+ - lib/pork/more/should.rb
84
+ - lib/pork/report.rb
85
+ - lib/pork/report/description.rb
86
+ - lib/pork/report/dot.rb
87
+ - lib/pork/report/progressbar.rb
88
+ - lib/pork/runner.rb
89
+ - lib/pork/stat.rb
90
+ - lib/pork/suite.rb
91
+ - lib/pork/test.rb
92
+ - lib/pork/version.rb
93
+ - pork.gemspec
94
+ - task/README.md
95
+ - task/gemgem.rb
96
+ - test/test_around.rb
97
+ - test/test_bacon.rb
98
+ - test/test_expect.rb
99
+ - test/test_inspect.rb
100
+ - test/test_isolator.rb
101
+ - test/test_meta.rb
102
+ - test/test_nested.rb
103
+ - test/test_pork_test.rb
104
+ - test/test_readme.rb
105
+ - test/test_should.rb
106
+ - test/test_stat.rb
107
+ - test/test_suite.rb
108
+ homepage: "https://github.com/godfat/pork"
103
109
  licenses:
104
- - Apache License 2.0
110
+ - Apache-2.0
105
111
  metadata: {}
106
- post_install_message:
107
112
  rdoc_options: []
108
113
  require_paths:
109
- - lib
114
+ - lib
110
115
  required_ruby_version: !ruby/object:Gem::Requirement
111
116
  requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: '0'
117
+ -
118
+ - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: "0"
115
121
  required_rubygems_version: !ruby/object:Gem::Requirement
116
122
  requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: '0'
123
+ -
124
+ - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: "0"
120
127
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.6.6
123
- signing_key:
128
+ rubygems_version: 4.1.0
124
129
  specification_version: 4
125
130
  summary: Pork -- Simple and clean and modular testing library.
126
131
  test_files:
127
- - test/test_bacon.rb
128
- - test/test_expect.rb
129
- - test/test_inspect.rb
130
- - test/test_meta.rb
131
- - test/test_nested.rb
132
- - test/test_pork_test.rb
133
- - test/test_readme.rb
134
- - test/test_should.rb
135
- - test/test_stat.rb
132
+ - test/test_around.rb
133
+ - test/test_bacon.rb
134
+ - test/test_expect.rb
135
+ - test/test_inspect.rb
136
+ - test/test_isolator.rb
137
+ - test/test_meta.rb
138
+ - test/test_nested.rb
139
+ - test/test_pork_test.rb
140
+ - test/test_readme.rb
141
+ - test/test_should.rb
142
+ - test/test_stat.rb
143
+ - test/test_suite.rb
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.2.5
5
- - 2.3.1
6
- - rbx
7
- - jruby-9
8
-
9
- before_install:
10
- - rvm get head
11
- - rvm reload
12
- - rvm use --install $TRAVIS_RUBY_VERSION --binary --latest
13
- install: 'gem install bundler; bundle install --retry=3'
14
- script: 'ruby -r bundler/setup -S rake test'