imitate 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/imitate.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "imitate"
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Petr Janda"]
data/lib/imitate.rb CHANGED
@@ -22,7 +22,7 @@ module Imitate
22
22
  # @param [String] Name of the class to be created.
23
23
  # @param [Proc] Optional block to be instance evaluated on new class.
24
24
  #
25
- def mock_class(name, &block)
25
+ def mock(name, &block)
26
26
  process_name(name) {|parent, token, leaf|
27
27
  leaf ? create_const(Class, parent, token, &block) : create_const(Module, parent, token)
28
28
  }
data/spec/imitate_spec.rb CHANGED
@@ -4,8 +4,8 @@ describe "Imitate" do
4
4
 
5
5
  describe '.unmock_all' do
6
6
  it 'should remove all mocked objects' do
7
- Imitate.mock_class('Foo')
8
- Imitate.mock_class('Bar')
7
+ Imitate.mock('Foo')
8
+ Imitate.mock('Bar')
9
9
 
10
10
  Foo.should be
11
11
  Bar.should be
@@ -21,14 +21,14 @@ describe "Imitate" do
21
21
  context 'const exists' do
22
22
  context 'const was mocked by imitate' do
23
23
  it 'should remove the class' do
24
- Imitate.mock_class('Foo')
24
+ Imitate.mock('Foo')
25
25
  Imitate.unmock('Foo')
26
26
 
27
27
  lambda { Object.const_get('Foo') }.should raise_error
28
28
  end
29
29
 
30
30
  it 'should remove the class and namespaces' do
31
- Imitate.mock_class('Foo::Bar')
31
+ Imitate.mock('Foo::Bar')
32
32
  Imitate.unmock('Foo::Bar')
33
33
 
34
34
  lambda { Foo::Bar }.should raise_error
@@ -36,7 +36,7 @@ describe "Imitate" do
36
36
  end
37
37
 
38
38
  it 'should remove record from MOCKED' do
39
- Imitate.mock_class('Foo')
39
+ Imitate.mock('Foo')
40
40
  Imitate.unmock('Foo')
41
41
 
42
42
  Imitate.expects(:remove_const).never
@@ -69,7 +69,7 @@ describe "Imitate" do
69
69
  after { Object.instance_eval { remove_const 'Module1' } }
70
70
 
71
71
  it 'should remove just class' do
72
- Imitate.mock_class('Module1::Foo1')
72
+ Imitate.mock('Module1::Foo1')
73
73
  Imitate.unmock('Module1::Foo1')
74
74
 
75
75
  Module1.should be
@@ -87,10 +87,10 @@ describe "Imitate" do
87
87
  end
88
88
  end
89
89
 
90
- describe '.mock_class' do
90
+ describe '.mock' do
91
91
  context 'if const doesnt exist' do
92
92
  context 'simple class' do
93
- before { Imitate.mock_class('Foo') }
93
+ before { Imitate.mock('Foo') }
94
94
  after { Imitate.unmock('Foo') }
95
95
 
96
96
  it 'should create new dummy class' do
@@ -101,7 +101,7 @@ describe "Imitate" do
101
101
 
102
102
  context 'class with block' do
103
103
  before {
104
- Imitate.mock_class('Foo') do
104
+ Imitate.mock('Foo') do
105
105
  def bar
106
106
  'bar'
107
107
  end
@@ -115,7 +115,7 @@ describe "Imitate" do
115
115
  end
116
116
 
117
117
  context 'class within namespace' do
118
- before { Imitate.mock_class('Foo::Bar') }
118
+ before { Imitate.mock('Foo::Bar') }
119
119
 
120
120
  it 'should create necessary namespace' do
121
121
  Foo::Bar.should be
@@ -125,10 +125,10 @@ describe "Imitate" do
125
125
  end
126
126
 
127
127
  context 'if const exists' do
128
- before { Imitate.mock_class('Imitate') }
128
+ before { Imitate.mock('Imitate') }
129
129
 
130
130
  it 'should not override already existing object' do
131
- Imitate.methods.should include('mock_class')
131
+ Imitate.methods.should include('mock')
132
132
  end
133
133
  end
134
134
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imitate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2160205840 !ruby/object:Gem::Requirement
16
+ requirement: &2157867840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.8.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2160205840
24
+ version_requirements: *2157867840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &2160203080 !ruby/object:Gem::Requirement
27
+ requirement: &2157867240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.12'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2160203080
35
+ version_requirements: *2157867240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2160200860 !ruby/object:Gem::Requirement
38
+ requirement: &2157866640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2160200860
46
+ version_requirements: *2157866640
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &2160198100 !ruby/object:Gem::Requirement
49
+ requirement: &2157866040 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.8.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2160198100
57
+ version_requirements: *2157866040
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &2160194700 !ruby/object:Gem::Requirement
60
+ requirement: &2157865440 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2160194700
68
+ version_requirements: *2157865440
69
69
  description: Simple class mock
70
70
  email: petrjanda@me.com
71
71
  executables: []
@@ -101,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  segments:
103
103
  - 0
104
- hash: 2598245985460209889
104
+ hash: -2170257274649016692
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements: