coulda 0.4.1 → 0.4.2
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.
- data/HISTORY +4 -0
- data/coulda.gemspec +3 -1
- data/lib/coulda.rb +2 -2
- data/lib/coulda/vendor/constantize.rb +45 -0
- data/lib/coulda/vendor/underscore.rb +9 -0
- metadata +3 -1
data/HISTORY
CHANGED
data/coulda.gemspec
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{coulda}
|
|
8
|
-
s.version = "0.4.
|
|
8
|
+
s.version = "0.4.2"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Evan David Light"]
|
|
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
|
|
|
30
30
|
"lib/coulda/feature.rb",
|
|
31
31
|
"lib/coulda/scenario.rb",
|
|
32
32
|
"lib/coulda/tasks.rb",
|
|
33
|
+
"lib/coulda/vendor/constantize.rb",
|
|
34
|
+
"lib/coulda/vendor/underscore.rb",
|
|
33
35
|
"test/feature_test.rb",
|
|
34
36
|
"test/integration/using_coulda_test.rb",
|
|
35
37
|
"test/regression/issue_1_test.rb",
|
data/lib/coulda.rb
CHANGED
|
@@ -9,6 +9,8 @@ require 'pending'
|
|
|
9
9
|
|
|
10
10
|
require 'coulda/feature'
|
|
11
11
|
require 'coulda/scenario'
|
|
12
|
+
require 'coulda/vendor/constantize'
|
|
13
|
+
require 'coulda/vendor/underscore'
|
|
12
14
|
|
|
13
15
|
module Kernel
|
|
14
16
|
def Feature(name, opts = {}, &block)
|
|
@@ -19,5 +21,3 @@ module Kernel
|
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
|
|
22
|
-
require 'vendor/constantize'
|
|
23
|
-
require 'vendor/underscore'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Slightly tweeked version of #constantize from ActiveSupport 2.3.3
|
|
2
|
+
class String
|
|
3
|
+
# Ruby 1.9 introduces an inherit argument for Module#const_get and
|
|
4
|
+
# #const_defined? and changes their default behavior.
|
|
5
|
+
if Module.method(:const_get).arity == 1
|
|
6
|
+
# Tries to find a constant with the name specified in the argument string:
|
|
7
|
+
#
|
|
8
|
+
# "Module".constantize # => Module
|
|
9
|
+
# "Test::Unit".constantize # => Test::Unit
|
|
10
|
+
#
|
|
11
|
+
# The name is assumed to be the one of a top-level constant, no matter whether
|
|
12
|
+
# it starts with "::" or not. No lexical context is taken into account:
|
|
13
|
+
#
|
|
14
|
+
# C = 'outside'
|
|
15
|
+
# module M
|
|
16
|
+
# C = 'inside'
|
|
17
|
+
# C # => 'inside'
|
|
18
|
+
# "C".constantize # => 'outside', same as ::C
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# NameError is raised when the name is not in CamelCase or the constant is
|
|
22
|
+
# unknown.
|
|
23
|
+
def constantize
|
|
24
|
+
names = self.split('::')
|
|
25
|
+
names.shift if names.empty? || names.first.empty?
|
|
26
|
+
|
|
27
|
+
constant = Object
|
|
28
|
+
names.each do |name|
|
|
29
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
|
30
|
+
end
|
|
31
|
+
constant
|
|
32
|
+
end
|
|
33
|
+
else
|
|
34
|
+
def constantize #:nodoc:
|
|
35
|
+
names = self.split('::')
|
|
36
|
+
names.shift if names.empty? || names.first.empty?
|
|
37
|
+
|
|
38
|
+
constant = Object
|
|
39
|
+
names.each do |name|
|
|
40
|
+
constant = constant.const_get(name, false) || constant.const_missing(name)
|
|
41
|
+
end
|
|
42
|
+
constant
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: coulda
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Evan David Light
|
|
@@ -45,6 +45,8 @@ files:
|
|
|
45
45
|
- lib/coulda/feature.rb
|
|
46
46
|
- lib/coulda/scenario.rb
|
|
47
47
|
- lib/coulda/tasks.rb
|
|
48
|
+
- lib/coulda/vendor/constantize.rb
|
|
49
|
+
- lib/coulda/vendor/underscore.rb
|
|
48
50
|
- test/feature_test.rb
|
|
49
51
|
- test/integration/using_coulda_test.rb
|
|
50
52
|
- test/regression/issue_1_test.rb
|