attestify 0.1.0.pre.3 → 0.1.1

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: 7277786172463a5c2d2b1e37dcb5d9336e69465f
4
- data.tar.gz: 3b2bdd5dbcf9cc1cad6d36f23fc2e13bce86e84d
3
+ metadata.gz: cfc95cc88519939c004c7c90f2e80563801003b8
4
+ data.tar.gz: dbd105d4e73d1c631de20b06e4ce9bd8f00dc515
5
5
  SHA512:
6
- metadata.gz: 1da0ce79a1f218b79f81f1d299957657f6a8b7308896ecdc59dfc1e4450e55e50a03ed3d3882e2f8fc3a0664ffb0e7af7cad70fbeb75567936a9190dee559213
7
- data.tar.gz: eba4dafcd0f9bc8cafde2366fdf478af5a72e0490f136389083c2bbd16474b3418e7aaed97835920cb7447193f5e15d8ca2c7b6be743b5e371be9b4938b76879
6
+ metadata.gz: eb7b2c51b0430c92fca3792a3a5a6cacdd6947fdb1ab1170ba7cac2cded802844b9c94a60f1b1b3ff6bc732c2a1e95d4e949fd3e9cdcb0b3c9a8850e2ffc6d29
7
+ data.tar.gz: ef760b541c9077a24a632236bbe98fecd6f9193446ba3966fb341ec2b0da6da1c5617baa68add856cbb3217b89917a84fdcf67b9cf8df6168b5c286b6a162dc7
@@ -5,6 +5,9 @@ AllCops:
5
5
  - vendor/**/*
6
6
  DisplayCopNames: true
7
7
 
8
+ Layout/SpaceInsideBlockBraces:
9
+ EnforcedStyleForEmptyBraces: space
10
+
8
11
  Metrics/AbcSize:
9
12
  Exclude:
10
13
  - test/**/*_test.rb
@@ -27,9 +30,6 @@ Style/ClassAndModuleChildren:
27
30
  Style/SignalException:
28
31
  EnforcedStyle: only_raise
29
32
 
30
- Style/SpaceInsideBlockBraces:
31
- EnforcedStyleForEmptyBraces: space
32
-
33
33
  Style/StringLiterals:
34
34
  EnforcedStyle: double_quotes
35
35
 
data/Rakefile CHANGED
@@ -2,4 +2,4 @@ require "bundler/gem_tasks"
2
2
  require "rubocop/rake_task"
3
3
  RuboCop::RakeTask.new(:rubocop)
4
4
  Attestify::RakeTask.new(:test)
5
- task default: [:rubocop, :test]
5
+ task default: %i[rubocop test]
@@ -1,5 +1,4 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "attestify"
5
4
 
@@ -22,5 +21,5 @@ Gem::Specification.new do |spec|
22
21
 
23
22
  spec.add_development_dependency "bundler", "~> 1.12"
24
23
  spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rubocop", "0.40.0"
24
+ spec.add_development_dependency "rubocop", "0.55.0"
26
25
  end
@@ -17,7 +17,7 @@ module Attestify
17
17
  autoload :VERSION, "attestify/version"
18
18
 
19
19
  def self.root
20
- @root ||= File.realpath(File.expand_path("../..", __FILE__)).freeze
20
+ @root ||= File.realpath(File.expand_path("..", __dir__)).freeze
21
21
  end
22
22
 
23
23
  def self.disable_autorun
@@ -76,10 +76,10 @@ module Attestify
76
76
  result.pop while !result.empty? && !location_in_attestify?(result.last)
77
77
  result.pop while !result.empty? && location_in_attestify?(result.last)
78
78
  result
79
- rescue
79
+ rescue StandardError
80
80
  # In case of a disaster, use the original locations, otherwise
81
81
  # tests that should fail would seem to succeed.
82
- return backtrace_locations
82
+ backtrace_locations
83
83
  end
84
84
 
85
85
  def location_in_attestify?(location)
@@ -109,13 +109,13 @@ module Attestify
109
109
  exceptions = [StandardError] if exceptions.empty?
110
110
  yield
111
111
  record_assert(false, message) { "Expected one of: #{exceptions.inspect} to be raised, but nothing was raised" }
112
- return nil
113
- rescue => e
112
+ nil
113
+ rescue StandardError => e
114
114
  record_assert(exceptions.any? { |x| e.is_a?(x) }, message) do
115
115
  "Expected one of: #{exceptions.inspect} to be raised, but instead got: #{e.class.name}"
116
116
  end
117
117
 
118
- return e
118
+ e
119
119
  end
120
120
 
121
121
  def assert_respond_to(object, method, message = nil)
@@ -149,7 +149,7 @@ module Attestify
149
149
  if expected.is_a?(Numeric)
150
150
  expected == 42
151
151
  elsif expected.is_a?(String)
152
- expected == "42" || expected.casecmp("forty-two") == 0
152
+ expected == "42" || expected.casecmp("forty-two").zero?
153
153
  elsif expected.respond_to?("42?")
154
154
  expected.send("42?")
155
155
  elsif expected.respond_to?(:forty_two?)
@@ -263,7 +263,7 @@ module Attestify
263
263
  end
264
264
 
265
265
  def refute_match(matcher, object, message = nil)
266
- record_assert(!(matcher =~ object), message) { "Expected not #{matcher.inspect} =~ #{object.inspect}" }
266
+ record_assert(matcher !~ object, message) { "Expected not #{matcher.inspect} =~ #{object.inspect}" }
267
267
  end
268
268
 
269
269
  def refute_nil(object, message = nil)
@@ -1,7 +1,7 @@
1
1
  module Attestify
2
2
  # Simple class for mocking objects.
3
3
  class Mock
4
- def initialize(test_or_assertions)
4
+ def initialize(test_or_assertions = Attestify::Test.current_test)
5
5
  @assertions = test_or_assertions
6
6
  @assertions = test_or_assertions.assertions if test_or_assertions.respond_to?(:assertions)
7
7
  @expectations_hash = Hash.new { |hash, key| hash[key] = [] }
@@ -22,7 +22,12 @@ module Attestify
22
22
  @expectations.reject(&:called?).each { |x| x.verify(@assertions) }
23
23
  end
24
24
 
25
- def method_missing(method, *args, &block)
25
+ def respond_to_missing?(method, include_all = false)
26
+ return true if @expectations_hash.include?(method)
27
+ super
28
+ end
29
+
30
+ def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissing
26
31
  expectation =
27
32
  if @expectations_hash[method].empty?
28
33
  UnexpectedCall.new(method, args, block)
@@ -78,7 +83,7 @@ module Attestify
78
83
 
79
84
  def verify(assertions)
80
85
  if !called?
81
- assertions.record(false, "Missing expected call to mock: #{self}", @caller_locations)
86
+ assertions.record(false, "Missing expected call to mock: #{self}", caller_locations(4))
82
87
  elsif !arguments_valid?
83
88
  assertions.record(false, "Expected call to mock: #{self}, but got: #{to_s(:actual)}", @caller_locations)
84
89
  else
@@ -16,7 +16,7 @@ module Attestify
16
16
  end
17
17
 
18
18
  def passed?
19
- @total_failures + @total_errors == 0
19
+ (@total_failures + @total_errors).zero?
20
20
  end
21
21
 
22
22
  def record(result)
@@ -24,20 +24,29 @@ module Attestify
24
24
  end
25
25
  end
26
26
 
27
+ def self.current_test
28
+ Thread.current[:Attestify_Test_CurrentTest]
29
+ end
30
+
27
31
  def self.run_one_method(test_class, method, reporter, filter = nil)
28
32
  return if filter && !filter.run?(test_class, method)
29
- reporter.record test_class.new(method).run
33
+
34
+ begin
35
+ test = test_class.new(method)
36
+ Thread.current[:Attestify_Test_CurrentTest] = test
37
+ reporter.record test.run
38
+ ensure
39
+ Thread.current[:Attestify_Test_CurrentTest] = nil
40
+ end
30
41
  end
31
42
 
32
43
  def self.runnable_methods
33
44
  instance_methods.select { |method| method.to_s.start_with?("test_") }
34
45
  end
35
46
 
36
- def setup
37
- end
47
+ def setup; end
38
48
 
39
- def teardown
40
- end
49
+ def teardown; end
41
50
 
42
51
  def assertions
43
52
  @_assertions
@@ -88,7 +97,7 @@ module Attestify
88
97
  ensure
89
98
  teardown
90
99
  end
91
- rescue => e
100
+ rescue StandardError => e
92
101
  assertions.error = e
93
102
  ensure
94
103
  return self # rubocop:disable Lint/EnsureReturn
@@ -10,7 +10,7 @@ module Attestify
10
10
  before_exec
11
11
  @exit_code = true
12
12
  timer = Attestify::Timer.time { run }
13
- rescue => e
13
+ rescue StandardError => e
14
14
  @exit_code = 2
15
15
  STDERR.puts("Error running tests: #{e}\n #{e.backtrace.join("\n ")}")
16
16
  ensure
@@ -30,17 +30,13 @@ module Attestify
30
30
 
31
31
  attr_reader :exit_code
32
32
 
33
- def before_run
34
- end
33
+ def before_run; end
35
34
 
36
- def after_run
37
- end
35
+ def after_run; end
38
36
 
39
- def before_exec
40
- end
37
+ def before_exec; end
41
38
 
42
- def after_exec
43
- end
39
+ def after_exec; end
44
40
 
45
41
  def report?
46
42
  true
@@ -1,7 +1,7 @@
1
1
  module Attestify
2
2
  # Holds the tests that will be loaded for a test run.
3
3
  class TestList
4
- attr_reader :dir, :test_helper_file
4
+ attr_reader :dir
5
5
 
6
6
  def initialize(files = nil, dir: nil)
7
7
  @dir = dir || "./test"
@@ -1,3 +1,3 @@
1
1
  module Attestify
2
- VERSION = "0.1.0.pre.3".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attestify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.3
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Virata-Stone
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2018-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.40.0
47
+ version: 0.55.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.40.0
54
+ version: 0.55.0
55
55
  description: A small framework for testing your code. It keeps track of assertion
56
56
  failures as well as test failures.
57
57
  email:
@@ -105,12 +105,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 1.3.1
110
+ version: '0'
111
111
  requirements: []
112
112
  rubyforge_project:
113
- rubygems_version: 2.4.8
113
+ rubygems_version: 2.6.14.1
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: A new way to test your code