power_assert 0.2.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4114043b958f530bf1b005c95b52c283e196b2dd
4
- data.tar.gz: ca1573692d996d86479bdbfd412071543074a4d0
3
+ metadata.gz: a902091c15113d1e53c83c802c83aaace2909d74
4
+ data.tar.gz: 91fe2642654933cf173c6ccc664a6ed7b1636eef
5
5
  SHA512:
6
- metadata.gz: 2dad87631bbcfe83d491276b325d85f9a6f3ff9a23f4057c8a0aaec7b00fc24b512db5a095b7092e79aa3e672e542670b407acf8772f3303dd70598adb702c89
7
- data.tar.gz: c454a8d8a07e2eca899c3e43b4a895de55680cf4de23dde7eb92a49ace1fe4f10e4bcc7eb0f8403894cacfd539db4a09994c01ba26a7b4df17835ee0d0d9255c
6
+ metadata.gz: b8a0d4cd96d4bda4fa4dbb6ad0eeb2c615027c9ff0db84a81aa84ed411aa24b279ab9c4c12820dbcac5da98033d3b5872274d93193517abf789da0371f2076c8
7
+ data.tar.gz: ff1b2d59a8fea2eac2f26994a649330efc69fa57b18a1fbe755fdf4c539e8b4bab2c092a920d9c1e95534ed63155755659035213a81e8eaf7fdfa8e1d889844a
data/.travis.yml CHANGED
@@ -2,4 +2,8 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 2.1
5
+ - 2.2
5
6
  - ruby-head
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: ruby-head
data/BSDL CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2014 Kazuki Tsujimoto, All rights reserved.
1
+ Copyright (C) 2014-2015 Kazuki Tsujimoto, All rights reserved.
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions
data/COPYING CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2014 Kazuki Tsujimoto, All rights reserved.
1
+ Copyright (C) 2014-2015 Kazuki Tsujimoto, All rights reserved.
2
2
 
3
3
  You can redistribute it and/or modify it under either the terms of the
4
4
  2-clause BSDL (see the file BSDL), or the conditions below:
data/README.rdoc CHANGED
@@ -10,6 +10,9 @@ Power Assert for Ruby.
10
10
  * {rspec-power_assert}[https://github.com/joker1007/rspec-power_assert]
11
11
  * {power_p}[https://github.com/k-tsj/power_p]
12
12
 
13
+ == Requirement
14
+ * CRuby 2.0.0 or later
15
+
13
16
  == Reference
14
17
  * {Power Assert in Ruby (at RubyKaigi 2014) // Speaker Deck}[https://speakerdeck.com/k_tsj/power-assert-in-ruby]
15
18
 
data/lib/power_assert.rb CHANGED
@@ -1,9 +1,16 @@
1
1
  # power_assert.rb
2
2
  #
3
- # Copyright (C) 2014 Kazuki Tsujimoto, All rights reserved.
3
+ # Copyright (C) 2014-2015 Kazuki Tsujimoto, All rights reserved.
4
4
 
5
5
  begin
6
- TracePoint.new(:return, :c_return) {}
6
+ captured = false
7
+ TracePoint.new(:return, :c_return) do |tp|
8
+ captured = true
9
+ unless tp.binding and tp.return_value
10
+ raise
11
+ end
12
+ end.enable { __id__ }
13
+ raise unless captured
7
14
  rescue
8
15
  raise LoadError, 'Fully compatible TracePoint API required'
9
16
  end
@@ -31,11 +38,9 @@ module PowerAssert
31
38
 
32
39
  private
33
40
 
34
- if defined?(RubyVM) and respond_to?(:using, true)
41
+ if defined?(RubyVM)
35
42
  def clear_global_method_cache
36
- class << Object.new
37
- using Empty
38
- end
43
+ eval('using PowerAssert.const_get(:Empty)', TOPLEVEL_BINDING)
39
44
  end
40
45
  end
41
46
  end
@@ -113,6 +118,7 @@ module PowerAssert
113
118
  target_thread = Thread.current
114
119
  @trace = TracePoint.new(:return, :c_return) do |tp|
115
120
  next if method_ids and ! method_ids.include?(tp.method_id)
121
+ next unless tp.binding # workaround for ruby 2.2
116
122
  locs = tp.binding.eval('::Kernel.caller_locations')
117
123
  current_diff = locs.length - @base_caller_length
118
124
  target_diff = TARGET_CALLER_DIFF[tp.event]
@@ -141,6 +147,10 @@ module PowerAssert
141
147
  do_yield(&@assertion_proc)
142
148
  end
143
149
 
150
+ def message
151
+ @message_proc.()
152
+ end
153
+
144
154
  private
145
155
 
146
156
  def do_yield
@@ -1,3 +1,3 @@
1
1
  module PowerAssert
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/power_assert.gemspec CHANGED
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency 'simplecov'
20
20
  s.extra_rdoc_files = ['README.rdoc']
21
21
  s.rdoc_options = ['--main', 'README.rdoc']
22
+ s.licenses = ['2-clause BSDL', "Ruby's"]
22
23
  end
@@ -133,14 +133,14 @@ class TestPowerAssert < Test::Unit::TestCase
133
133
  def assertion_message(source = nil, source_binding = TOPLEVEL_BINDING, &blk)
134
134
  ::PowerAssert.start(source || blk, assertion_method: __callee__, source_binding: source_binding) do |pa|
135
135
  pa.yield
136
- pa.message_proc.()
136
+ pa.message
137
137
  end
138
138
  end
139
139
 
140
140
  def Assertion(&blk)
141
141
  ::PowerAssert.start(blk, assertion_method: __callee__) do |pa|
142
142
  pa.yield
143
- pa.message_proc.()
143
+ pa.message
144
144
  end
145
145
  end
146
146
 
@@ -413,4 +413,10 @@ END
413
413
  String(a) + String(@b) + String(@@c) + String($d)
414
414
  END
415
415
  end
416
+
417
+ def test_workaround_for_ruby_2_2
418
+ assert_nothing_raised do
419
+ assertion_message { Thread.new {}.join }
420
+ end
421
+ end
416
422
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_assert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuki Tsujimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-22 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
@@ -77,7 +77,9 @@ files:
77
77
  - test/helper.rb
78
78
  - test/test_power_assert.rb
79
79
  homepage: https://github.com/k-tsj/power_assert
80
- licenses: []
80
+ licenses:
81
+ - 2-clause BSDL
82
+ - Ruby's
81
83
  metadata: {}
82
84
  post_install_message:
83
85
  rdoc_options:
@@ -97,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
99
  version: '0'
98
100
  requirements: []
99
101
  rubyforge_project:
100
- rubygems_version: 2.2.2
102
+ rubygems_version: 2.4.6
101
103
  signing_key:
102
104
  specification_version: 4
103
105
  summary: Power Assert for Ruby