monkey-lib 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +14 -1
- data/lib/monkey/ext/array.rb +6 -0
- data/spec/monkey/ext/array_spec.rb +17 -0
- metadata +2 -2
data/Rakefile
CHANGED
@@ -39,9 +39,22 @@ else
|
|
39
39
|
exit 1
|
40
40
|
end
|
41
41
|
|
42
|
+
def backend_available?(backend = nil)
|
43
|
+
require backend unless backend.nil?
|
44
|
+
true
|
45
|
+
rescue LoadError
|
46
|
+
false
|
47
|
+
end
|
48
|
+
|
42
49
|
def spec_task(name, backend = nil, mode = nil)
|
43
50
|
desc "runs specs #{"with backend #{backend} " if backend}#{"(#{mode} mode)" if mode}"
|
44
|
-
|
51
|
+
if backend_available? backend
|
52
|
+
define_spec_task(name, "BACKEND=#{backend.to_s.inspect} BACKEND_SETUP=#{mode.to_s.inspect} #{ENV['RUBY'] || RUBY}", "spec/monkey/**/*_spec.rb")
|
53
|
+
else
|
54
|
+
task(name) do
|
55
|
+
puts "", "could not load #{backend.inspect}, skipping specs."
|
56
|
+
end
|
57
|
+
end
|
45
58
|
end
|
46
59
|
|
47
60
|
task :environment do
|
data/lib/monkey/ext/array.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require __FILE__.sub(%r{monkey/.*$}, "spec_helper")
|
2
2
|
|
3
3
|
describe Monkey::Ext::Array do
|
4
|
+
|
4
5
|
describe "backend expectations" do
|
5
6
|
# expects :extract_options!
|
6
7
|
it "imports extract_options! from backend" do
|
@@ -15,4 +16,20 @@ describe Monkey::Ext::Array do
|
|
15
16
|
ary2.should == [{:x => 10}, :foo]
|
16
17
|
end
|
17
18
|
end
|
19
|
+
|
20
|
+
describe "select!" do
|
21
|
+
|
22
|
+
it "results in the same arrays as Array#select" do
|
23
|
+
([1, 2, 3, 4, 5, 6].select! { |e| e > 3 }).should == ([1, 2, 3, 4, 5, 6].select { |e| e > 3 })
|
24
|
+
([1, 2, 3, 4, 5, 6].select! { |e| e < 0 }).should == ([1, 2, 3, 4, 5, 6].select { |e| e < 0 })
|
25
|
+
end
|
26
|
+
|
27
|
+
it "modifies the current array, rather than returning a new one" do
|
28
|
+
x = [1, 2, 3, 4, 5, 6]
|
29
|
+
x.select! { |e| e > 3 }
|
30
|
+
x.should == [4, 5, 6]
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
18
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monkey-lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-20 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|