ruby_ext 0.5.9 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/Rakefile +2 -3
  2. data/lib/rake_ext/project.rb +1 -2
  3. data/lib/rspec_ext.rb +37 -35
  4. data/lib/rspec_ext/nokogiri.rb +26 -0
  5. data/lib/ruby_ext/core.rb +3 -5
  6. data/lib/ruby_ext/core/array.rb +1 -1
  7. data/lib/ruby_ext/core/basic_object.rb +1 -1
  8. data/lib/ruby_ext/core/deep_clone.rb +3 -10
  9. data/lib/ruby_ext/core/enumerable.rb +3 -3
  10. data/lib/ruby_ext/core/false_class.rb +1 -1
  11. data/lib/ruby_ext/core/hash.rb +23 -7
  12. data/lib/ruby_ext/core/module.rb +37 -57
  13. data/lib/ruby_ext/core/multiple_inheritance.rb +3 -3
  14. data/lib/ruby_ext/core/must.rb +0 -16
  15. data/lib/ruby_ext/core/nil_class.rb +5 -0
  16. data/lib/ruby_ext/core/object.rb +7 -7
  17. data/lib/ruby_ext/core/open_object.rb +7 -25
  18. data/lib/ruby_ext/core/string.rb +1 -6
  19. data/lib/ruby_ext/more.rb +2 -0
  20. data/lib/ruby_ext/more/callbacks.rb +37 -0
  21. data/lib/ruby_ext/more/declarative_cache.rb +45 -56
  22. data/lib/yaml_fix.rb +9 -0
  23. data/spec/core/array_spec.rb +1 -1
  24. data/spec/core/deep_clone_spec.rb +4 -2
  25. data/spec/core/enumerable.rb +1 -1
  26. data/spec/core/module_spec.rb +65 -107
  27. data/spec/core/multiple_inheritance_spec.rb +4 -4
  28. data/spec/core/must_spec.rb +1 -1
  29. data/spec/core/object_spec.rb +6 -6
  30. data/spec/core/open_object_spec.rb +1 -1
  31. data/spec/more/callbacks_spec.rb +90 -20
  32. data/spec/more/declarative_cache_spec.rb +96 -75
  33. data/spec/more/observable_spec.rb +10 -34
  34. data/spec/more/open_constructor_spec.rb +14 -11
  35. data/spec/spec_helper.rb +2 -0
  36. metadata +5 -6
  37. data/lib/rspec_ext/xhtml.rb +0 -48
  38. data/lib/ruby_ext/fixes.rb +0 -6
  39. data/spec/core/spec_helper.rb +0 -2
  40. data/spec/more/spec_helper.rb +0 -2
@@ -1,41 +1,17 @@
1
- require "more/spec_helper"
1
+ require "spec_helper"
2
2
 
3
3
  describe "Observable" do
4
- class AnObservable
5
- include RubyExt::Observable
6
- end
4
+ after{remove_constants :Tmp}
5
+
6
+ it "method without parameters" do
7
+ class Tmp
8
+ include RubyExt::Observable
9
+ end
7
10
 
8
- it "Method without Parameters" do
9
- mock = mock("Observer")
10
- obs = AnObservable.new
11
+ mock = mock "Observer"
12
+ obs = Tmp.new
11
13
  obs.add_observer mock
12
- mock.should_receive(:update).with(2)
14
+ mock.should_receive(:update).with 2
13
15
  obs.notify_observers :update, 2
14
16
  end
15
-
16
- # it "Method without Parameters" do
17
- # mock = mock("Observer")
18
- # obs = AnObservable.new
19
- # obs.add_observer(mock, method: :custom_update, filter: -> {|o| o == 2})
20
- # mock.should_receive(:custom_update).with(2)
21
- # obs.notify_observers 2
22
- # obs.notify_observers 4
23
- # end
24
- #
25
- # it "With Block" do
26
- # mock = mock("Observer")
27
- # mock.should_receive(:got)
28
- # obs = AnObservable.new
29
- # obs.add_observer{mock.got}
30
- # obs.notify_observers
31
- # end
32
- #
33
- # it "With Block and Filter" do
34
- # mock = mock("Observer")
35
- # obs = AnObservable.new
36
- # obs.add_observer(filter: -> {|o| o == 2}){|o| mock.got o}
37
- # mock.should_receive(:got).with(2)
38
- # obs.notify_observers 2
39
- # obs.notify_observers 4
40
- # end
41
17
  end
@@ -1,35 +1,38 @@
1
- require "more/spec_helper"
1
+ require "spec_helper"
2
2
 
3
3
  describe 'OpenConstructor' do
4
- class Test
5
- include RubyExt::OpenConstructor
6
- attr_accessor :name, :value
4
+ before_all do
5
+ class Tmp
6
+ include RubyExt::OpenConstructor
7
+ attr_accessor :name, :value
8
+ end
7
9
  end
10
+ after_all{remove_constants :Tmp}
8
11
 
9
12
  it 'should initialize atributes from Hash' do
10
- t = Test.new.set(name: 'name', value: 'value')
13
+ t = Tmp.new.set(name: 'name', value: 'value')
11
14
  [t.name, t.value].should == ['name', 'value']
12
15
  end
13
16
 
14
17
  it 'should initialize atributes from any Object' do
15
- t = Test.new.set(name: 'name', value: 'value')
16
- t2 = Test.new.set t
18
+ t = Tmp.new.set(name: 'name', value: 'value')
19
+ t2 = Tmp.new.set t
17
20
  [t2.name, t2.value].should == ['name', 'value']
18
21
  end
19
22
 
20
23
  it 'restrict copied values' do
21
- t = Test.new.set(name: 'name', value: 'value')
22
- t2 = Test.new.set t, [:name]
24
+ t = Tmp.new.set(name: 'name', value: 'value')
25
+ t2 = Tmp.new.set t, [:name]
23
26
  [t2.name, t2.value].should == ['name', nil]
24
27
 
25
28
  t = {name: 'name', value: 'value'}
26
- t2 = Test.new.set t, [:name]
29
+ t2 = Tmp.new.set t, [:name]
27
30
  [t2.name, t2.value].should == ['name', nil]
28
31
  end
29
32
 
30
33
  it 'to_hash' do
31
34
  h = {name: 'name', value: 'value'}
32
- t = Test.new.set h
35
+ t = Tmp.new.set h
33
36
  t.to_hash.should == h
34
37
  end
35
38
  end
@@ -0,0 +1,2 @@
1
+ require 'rspec_ext'
2
+ require 'ruby_ext'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.5.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-24 00:00:00.000000000Z
12
+ date: 2011-10-30 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -21,7 +21,7 @@ files:
21
21
  - readme.md
22
22
  - lib/rake_ext/project.rb
23
23
  - lib/rake_ext.rb
24
- - lib/rspec_ext/xhtml.rb
24
+ - lib/rspec_ext/nokogiri.rb
25
25
  - lib/rspec_ext.rb
26
26
  - lib/ruby_ext/core/array.rb
27
27
  - lib/ruby_ext/core/basic_object.rb
@@ -41,7 +41,6 @@ files:
41
41
  - lib/ruby_ext/core/time.rb
42
42
  - lib/ruby_ext/core/true_class.rb
43
43
  - lib/ruby_ext/core.rb
44
- - lib/ruby_ext/fixes.rb
45
44
  - lib/ruby_ext/more/callbacks.rb
46
45
  - lib/ruby_ext/more/declarative_cache.rb
47
46
  - lib/ruby_ext/more/observable.rb
@@ -49,6 +48,7 @@ files:
49
48
  - lib/ruby_ext/more/tuple.rb
50
49
  - lib/ruby_ext/more.rb
51
50
  - lib/ruby_ext.rb
51
+ - lib/yaml_fix.rb
52
52
  - spec/core/array_spec.rb
53
53
  - spec/core/deep_clone_spec.rb
54
54
  - spec/core/enumerable.rb
@@ -57,12 +57,11 @@ files:
57
57
  - spec/core/must_spec.rb
58
58
  - spec/core/object_spec.rb
59
59
  - spec/core/open_object_spec.rb
60
- - spec/core/spec_helper.rb
61
60
  - spec/more/callbacks_spec.rb
62
61
  - spec/more/declarative_cache_spec.rb
63
62
  - spec/more/observable_spec.rb
64
63
  - spec/more/open_constructor_spec.rb
65
- - spec/more/spec_helper.rb
64
+ - spec/spec_helper.rb
66
65
  homepage: http://github.com/alexeypetrushin/ruby_ext
67
66
  licenses: []
68
67
  post_install_message:
@@ -1,48 +0,0 @@
1
- #
2
- # FuzzyHash, to_fuzzy_hash, to_html
3
- #
4
- begin
5
- require 'nokogiri'
6
-
7
- class RSpec::FuzzyHash < Hash
8
- def == o
9
- return true if super
10
-
11
- if o.respond_to? :each
12
- o.each do |k, v|
13
- return false if (self[k.to_sym] || self[k.to_s]) != v
14
- end
15
- return true
16
- end
17
-
18
- false
19
- end
20
- end
21
-
22
- ::Nokogiri::XML::Node.class_eval do
23
- def to_fuzzy_hash
24
- h = RSpec::FuzzyHash.new
25
- attributes.each{|n, v| h[n] = v.value}
26
- h[:content] = content
27
- h
28
- end
29
- end
30
-
31
- class String
32
- def to_xhtml css = nil
33
- require 'nokogiri'
34
-
35
- node = Nokogiri::HTML(self)
36
- unless css
37
- node
38
- else
39
- nodes = node.css(css)
40
- raise "Elements for '#{css}' CSS query not found!" if nodes.size < 1
41
- raise "Found more than one elment for '#{css}' CSS query!" if nodes.size > 1
42
- nodes.first
43
- end
44
- end
45
- end
46
- rescue LoadError
47
- warn "WARN: some specs require the 'nokogiri' gem, but there's no such gem on this system, these specs will be scipped!"
48
- end
@@ -1,6 +0,0 @@
1
- # Clone doesn't unfreeze String.
2
- class String
3
- def clone
4
- "" + self
5
- end
6
- end
@@ -1,2 +0,0 @@
1
- require 'rspec_ext'
2
- require 'ruby_ext/core'
@@ -1,2 +0,0 @@
1
- require 'core/spec_helper'
2
- require 'ruby_ext/more'