temporaries 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README.markdown +9 -9
- data/lib/temporaries/values.rb +1 -1
- data/lib/temporaries/version.rb +1 -1
- data/spec/unit/temporaries/values_spec.rb +11 -0
- metadata +43 -51
data/CHANGELOG
CHANGED
data/README.markdown
CHANGED
@@ -19,22 +19,22 @@ code. Nest them arbitrarily; the innermost one applies.
|
|
19
19
|
|
20
20
|
describe MyClass do
|
21
21
|
# Mylib.foo will be 5 within these examples.
|
22
|
-
|
22
|
+
use_attribute_value MyLib, :foo, 5
|
23
23
|
|
24
24
|
describe MyClass do
|
25
25
|
# In this nested example group, it will be 7.
|
26
|
-
|
26
|
+
use_attribute_value MyLib, :foo, 7
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
Here's the full list of methods you can use:
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
use_hash_value(hash, key, value)
|
33
|
+
use_constant_value(module, :constant, value)
|
34
|
+
use_attribute_value(object, :attribute, value)
|
35
|
+
use_instance_variable_value(object, :name, value)
|
36
|
+
use_class_variable_value(object, :name, value)
|
37
|
+
use_global_value(:name, value)
|
38
38
|
|
39
39
|
Sigils in the `name` are unnecessary in the last 3 (unlike
|
40
40
|
`instance_variable_get`, for instance).
|
@@ -42,7 +42,7 @@ Sigils in the `name` are unnecessary in the last 3 (unlike
|
|
42
42
|
### In Test::Unit
|
43
43
|
|
44
44
|
class MyTest < Test::Unit::TestCase
|
45
|
-
|
45
|
+
use_attribute_value MyLib, :foo, 5
|
46
46
|
end
|
47
47
|
|
48
48
|
## Digging Deeper
|
data/lib/temporaries/values.rb
CHANGED
@@ -93,7 +93,7 @@ module Temporaries
|
|
93
93
|
def define(mod)
|
94
94
|
if exists
|
95
95
|
save = "original_value = #{exists} ? #{get} : Temporaries::Values::UNDEFINED"
|
96
|
-
restore = "value
|
96
|
+
restore = "value.equal?(Temporaries::Values::UNDEFINED) ? #{remove} : #{set}"
|
97
97
|
else
|
98
98
|
save = "original_value = #{get}"
|
99
99
|
restore = set
|
data/lib/temporaries/version.rb
CHANGED
@@ -48,6 +48,17 @@ describe Temporaries::Values do
|
|
48
48
|
@mod.const_defined?(:CONSTANT).should be_false
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
describe "when the value is a hash" do
|
53
|
+
it "should pop cleanly, even though a hash can't be compared with #== to UNDEFINED in Ruby 1.9" do
|
54
|
+
@context.push_constant_value @mod, :CONSTANT, {}
|
55
|
+
@context.push_constant_value @mod, :CONSTANT, {}
|
56
|
+
@context.pop_constant_value @mod, :CONSTANT
|
57
|
+
lambda do
|
58
|
+
@context.pop_constant_value @mod, :CONSTANT
|
59
|
+
end.should_not raise_error
|
60
|
+
end
|
61
|
+
end
|
51
62
|
end
|
52
63
|
|
53
64
|
describe "#with_constant_value" do
|
metadata
CHANGED
@@ -1,63 +1,59 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: temporaries
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- George Ogata
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: ritual
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70153278732100 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
24
21
|
version: 0.3.0
|
25
22
|
type: :development
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: *70153278732100
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70153278731340 !ruby/object:Gem::Requirement
|
31
28
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
35
32
|
version: 2.5.0
|
36
33
|
type: :development
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: cucumber
|
40
34
|
prerelease: false
|
41
|
-
|
35
|
+
version_requirements: *70153278731340
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cucumber
|
38
|
+
requirement: &70153278730880 !ruby/object:Gem::Requirement
|
42
39
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
40
|
+
requirements:
|
41
|
+
- - =
|
42
|
+
- !ruby/object:Gem::Version
|
46
43
|
version: 0.10.2
|
47
44
|
type: :development
|
48
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70153278730880
|
49
47
|
description:
|
50
|
-
email:
|
48
|
+
email:
|
51
49
|
- george.ogata@gmail.com
|
52
50
|
executables: []
|
53
|
-
|
54
51
|
extensions: []
|
55
|
-
|
56
|
-
extra_rdoc_files:
|
52
|
+
extra_rdoc_files:
|
57
53
|
- CHANGELOG
|
58
54
|
- LICENSE
|
59
55
|
- README.markdown
|
60
|
-
files:
|
56
|
+
files:
|
61
57
|
- lib/temporaries/adapters/base.rb
|
62
58
|
- lib/temporaries/adapters/rspec.rb
|
63
59
|
- lib/temporaries/adapters/test_unit.rb
|
@@ -79,35 +75,31 @@ files:
|
|
79
75
|
- features/test_unit_integration.feature
|
80
76
|
- features/step_definitions/command_steps.rb
|
81
77
|
- features/support/env.rb
|
82
|
-
has_rdoc: true
|
83
78
|
homepage: http://github.com/oggy/temporaries
|
84
79
|
licenses: []
|
85
|
-
|
86
80
|
post_install_message:
|
87
81
|
rdoc_options: []
|
88
|
-
|
89
|
-
require_paths:
|
82
|
+
require_paths:
|
90
83
|
- lib
|
91
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
85
|
none: false
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
91
|
none: false
|
99
|
-
requirements:
|
100
|
-
- -
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version:
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
103
96
|
requirements: []
|
104
|
-
|
105
97
|
rubyforge_project:
|
106
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.8.10
|
107
99
|
signing_key:
|
108
100
|
specification_version: 3
|
109
101
|
summary: Set temporary values declaratively.
|
110
|
-
test_files:
|
102
|
+
test_files:
|
111
103
|
- spec/spec_helper.rb
|
112
104
|
- spec/support/test_context.rb
|
113
105
|
- spec/unit/temporaries/directory_spec.rb
|