remarkable_rails 3.1.5 → 3.1.6
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG
CHANGED
@@ -403,7 +403,13 @@ module Remarkable
|
|
403
403
|
|
404
404
|
# Creates mock methods automatically.
|
405
405
|
#
|
406
|
-
# == Options
|
406
|
+
# == Options
|
407
|
+
#
|
408
|
+
# * <tt>:as</tt> - Used to set the model . For example, if you have
|
409
|
+
# Admin::Task model, you have to tell the name of the class to be
|
410
|
+
# mocked:
|
411
|
+
#
|
412
|
+
# mock_models :admin_task, :as => "Admin::Task"
|
407
413
|
#
|
408
414
|
# * <tt>:class_method</tt> - When set to false, does not create the
|
409
415
|
# class method which returns a proc.
|
@@ -440,6 +446,8 @@ module Remarkable
|
|
440
446
|
|
441
447
|
models.each do |model|
|
442
448
|
model = model.to_s
|
449
|
+
klass = options[:as] || model.classify
|
450
|
+
|
443
451
|
if options[:class_method]
|
444
452
|
(class << self; self; end).class_eval <<-METHOD
|
445
453
|
def #{model}_proc; proc { mock_#{model} }; end
|
@@ -452,11 +460,12 @@ module Remarkable
|
|
452
460
|
|
453
461
|
self.class_eval <<-METHOD
|
454
462
|
def mock_#{model}(stubs={})
|
455
|
-
@#{model} ||= mock_model(#{
|
463
|
+
@#{model} ||= mock_model(#{klass}, stubs)
|
456
464
|
end
|
457
465
|
METHOD
|
458
466
|
end
|
459
|
-
end
|
467
|
+
end
|
468
|
+
alias :mock_model :mock_models
|
460
469
|
|
461
470
|
end
|
462
471
|
|
@@ -24,13 +24,13 @@ describe 'MacroStubs' do
|
|
24
24
|
self.class.respond_to?(:mock_projects).should be_true
|
25
25
|
end
|
26
26
|
|
27
|
-
it 'should create a class singular
|
27
|
+
it 'should create a class singular proc method' do
|
28
28
|
self.class.respond_to?(:project_proc).should be_false
|
29
29
|
self.class.mock_models :project
|
30
30
|
self.class.respond_to?(:project_proc).should be_true
|
31
31
|
end
|
32
32
|
|
33
|
-
it 'should create a class plural
|
33
|
+
it 'should create a class plural proc method' do
|
34
34
|
self.class.respond_to?(:projects_proc).should be_false
|
35
35
|
self.class.mock_models :project
|
36
36
|
self.class.respond_to?(:projects_proc).should be_true
|
@@ -49,8 +49,15 @@ describe 'MacroStubs' do
|
|
49
49
|
self.class.respond_to?(:project_proc).should be_false
|
50
50
|
self.respond_to?(:mock_project).should be_true
|
51
51
|
end
|
52
|
+
|
53
|
+
it 'should allow the mock class to be set' do
|
54
|
+
self.class.mock_model :project, :as => "::Admin::Project"
|
55
|
+
lambda{
|
56
|
+
mock_project
|
57
|
+
}.should raise_error(NameError, "uninitialized constant Admin")
|
58
|
+
end
|
52
59
|
|
53
|
-
it 'should create procs which evals to a mock
|
60
|
+
it 'should create procs which evals to a mock' do
|
54
61
|
proc = self.class.task_proc
|
55
62
|
proc.should be_kind_of(Proc)
|
56
63
|
|
@@ -59,7 +66,7 @@ describe 'MacroStubs' do
|
|
59
66
|
@task.should_not be_nil
|
60
67
|
end
|
61
68
|
|
62
|
-
it 'should create procs which evals to an array of mocks
|
69
|
+
it 'should create procs which evals to an array of mocks' do
|
63
70
|
proc = self.class.tasks_proc
|
64
71
|
proc.should be_kind_of(Proc)
|
65
72
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remarkable_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Brando
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-06-
|
13
|
+
date: 2009-06-06 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 3.1.
|
44
|
+
version: 3.1.6
|
45
45
|
version:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: remarkable_activerecord
|
@@ -51,7 +51,7 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.1.
|
54
|
+
version: 3.1.6
|
55
55
|
version:
|
56
56
|
description: "Remarkable Rails: collection of matchers and macros with I18n for Rails"
|
57
57
|
email:
|