assert_same 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/assert_same.gemspec +1 -1
  2. data/lib/assert_same.rb +6 -7
  3. metadata +2 -2
data/assert_same.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  SPEC = Gem::Specification.new do |s|
4
4
  s.name = "assert_same"
5
- s.version = "0.7.2"
5
+ s.version = "0.7.3"
6
6
  s.author = "Pluron, Inc."
7
7
  s.email = "support@pluron.com"
8
8
  s.homepage = "http://github.com/acunote/assert_same"
data/lib/assert_same.rb CHANGED
@@ -66,10 +66,9 @@ end
66
66
 
67
67
  test_unit_module.module_eval do
68
68
 
69
- #Hash[filename][line_number] = offset
70
- #For each line in the original file we store its offset (+N or -N lines)
71
- #relative to the actual file
72
- class_variable_set(:@@file_offsets, Hash.new { |hash, key| hash[key] = {} })
69
+ def file_offsets
70
+ @file_offsets ||= Hash.new { |hash, key| hash[key] = {} }
71
+ end
73
72
 
74
73
  # assert_same: assert which checks that two strings (expected and actual) are same
75
74
  # and which can "magically" replace expected value with the actual in case
@@ -300,8 +299,8 @@ private
300
299
  source = File.readlines(File::expand_path(file))
301
300
 
302
301
  # file may be changed by previous accepted assert_same's, adjust line numbers
303
- offset = @@file_offsets[file].keys.inject(0) do |sum, i|
304
- line.to_i >= i ? sum + @@file_offsets[file][i] : sum
302
+ offset = file_offsets[file].keys.inject(0) do |sum, i|
303
+ line.to_i >= i ? sum + file_offsets[file][i] : sum
305
304
  end
306
305
 
307
306
  expected_text_end_line = expected_text_start_line = line.to_i + offset
@@ -339,7 +338,7 @@ private
339
338
  # recalculate line number adjustments
340
339
  actual_length = actual.split("\n").length
341
340
  actual_length += 1 if change == :create_expected_string # END marker after expected value
342
- @@file_offsets[file][line.to_i] = actual_length - expected_length
341
+ file_offsets[file][line.to_i] = actual_length - expected_length
343
342
 
344
343
  source_file = File.open(file, "w+")
345
344
  source_file.write(source.join(''))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert_same
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-02 00:00:00.000000000 Z
12
+ date: 2013-10-04 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: assert_same assertion
15
15
  email: support@pluron.com