jeremymcanally-context 0.0.6 → 0.5

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.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "context"
3
- s.version = "0.0.6"
3
+ s.version = "0.5"
4
4
  s.date = "2008-10-03"
5
5
  s.summary = "Contexts and DSL sugar for your tests"
6
6
  s.email = "jeremy@entp.com"
@@ -1,7 +1,8 @@
1
1
  class String
2
2
  # Replaces spaces and tabs with _ so we can use the string as a method name
3
+ # Also replace dangerous punctuation
3
4
  def to_method_name
4
- self.downcase.gsub(/[\s:']+/,'_')
5
+ self.downcase.gsub(/[\s:',;!#]+/,'_')
5
6
  end
6
7
 
7
8
  # Borrowed from +camelize+ in ActiveSupport
@@ -13,4 +14,4 @@ class String
13
14
  def to_class_name
14
15
  self.to_method_name.gsub(/\/(.?)/) { "#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
15
16
  end
16
- end
17
+ end
@@ -42,22 +42,24 @@ class Test::Unit::TestCase
42
42
 
43
43
  child.class_eval do
44
44
  def setup
45
+ super
45
46
  run_each_callbacks :before
46
47
  end
47
48
 
48
49
  def teardown
50
+ super
49
51
  run_each_callbacks :after
50
52
  end
51
53
  end
52
54
  end
53
55
 
54
56
  def run_each_callbacks(callback_type) # :nodoc:
55
- self.class.gather_callbacks(callback_type, :each).each { |c| instance_eval(&c) }
57
+ self.class.gather_callbacks(callback_type, :each).each { |c| instance_eval(&c) if c }
56
58
  end
57
59
 
58
60
  def run_all_callbacks(callback_type) # :nodoc:
59
61
  previous_ivars = instance_variables
60
- self.class.gather_callbacks(callback_type, :all).each { |c| instance_eval(&c) }
62
+ self.class.gather_callbacks(callback_type, :all).each { |c| instance_eval(&c) if c }
61
63
  (instance_variables - previous_ivars).inject({}) do |hash, ivar|
62
64
  hash.update ivar => instance_variable_get(ivar)
63
65
  end
@@ -1,8 +1,8 @@
1
1
  module Context
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 0
5
- TINY = 6
4
+ MINOR = 5
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -13,5 +13,9 @@ class TestCoreExt < Test::Unit::TestCase
13
13
  it "should change spaces to _" do
14
14
  assert :this_has_been_great, "This has been great".to_method_name
15
15
  end
16
+
17
+ it "should change dangerous punctuation to _" do
18
+ assert :no__really__this_was__good_, "No, really; this was #good!".to_method_name
19
+ end
16
20
  end
17
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeremymcanally-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: "0.5"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy McAnally