Skip to content

Commit

Permalink
Fixed that context names could not have characters other than \w and \s
Browse files Browse the repository at this point in the history
  • Loading branch information
soveran committed Mar 18, 2009
1 parent a0e5bb2 commit 2ef38f0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion contest.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'contest'
s.version = '0.0.3'
s.version = '0.0.4'
s.summary = %{Contexts for Test::Unit}
s.date = %q{2009-03-16}
s.author = "Damian Janowski"
Expand Down
2 changes: 1 addition & 1 deletion contest.gemspec.erb
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'contest'
s.version = '0.0.3'
s.version = '0.0.4'
s.summary = %{Contexts for Test::Unit}
s.date = %q{2009-03-16}
s.author = "Damian Janowski"
Expand Down
8 changes: 6 additions & 2 deletions lib/contest.rb
Expand Up @@ -44,10 +44,14 @@ def self.setup_blocks
end

def self.context_name(name)
"#{name.gsub(/(^| )(\w)/) { $2.upcase }}Test".to_sym
"Test#{sanitize_name(name).gsub(/(^| )(\w)/) { $2.upcase }}".to_sym
end

def self.test_name(name)
"test_#{name.gsub(/\s+/,'_')}".to_sym
"test_#{sanitize_name(name).gsub(/\s+/,'_')}".to_sym
end

def self.sanitize_name(name)
name.gsub(/\W+/, ' ')
end
end
3 changes: 3 additions & 0 deletions test/all_test.rb
Expand Up @@ -9,6 +9,9 @@ class FooTest < Test::Unit::TestCase
assert_equal 1, @value
end

context "context's non-word characters" do
end

context "some context" do
setup do
@value += 1
Expand Down

0 comments on commit 2ef38f0

Please sign in to comment.