superdupe 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,7 @@ module ActiveResource #:nodoc:
|
|
32
32
|
|
33
33
|
private
|
34
34
|
def find_every(options)
|
35
|
-
external_request =
|
35
|
+
external_request = Dupe.disabled?
|
36
36
|
|
37
37
|
case from = options[:from]
|
38
38
|
when Symbol
|
@@ -48,8 +48,8 @@ module ActiveResource #:nodoc:
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def find_one(options)
|
51
|
-
external_request =
|
52
|
-
|
51
|
+
external_request = Dupe.disabled?
|
52
|
+
|
53
53
|
case from = options[:from]
|
54
54
|
when Symbol
|
55
55
|
instantiate_record(get(from, options[:params]))
|
@@ -60,8 +60,8 @@ module ActiveResource #:nodoc:
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def find_single(scope, options)
|
63
|
-
external_request =
|
64
|
-
|
63
|
+
external_request = Dupe.disabled?
|
64
|
+
|
65
65
|
prefix_options, query_options = split_options(options[:params])
|
66
66
|
path = element_path(scope, prefix_options, query_options)
|
67
67
|
instantiate_record(connection.get(path, headers, external_request), prefix_options)
|
@@ -9,23 +9,6 @@ class Dupe
|
|
9
9
|
|
10
10
|
class NilValue; end
|
11
11
|
|
12
|
-
attr_reader :name
|
13
|
-
attr_reader :transformer
|
14
|
-
attr_reader :default
|
15
|
-
|
16
|
-
def initialize(name, options={})
|
17
|
-
default = options[:default]
|
18
|
-
transformer = options[:transformer]
|
19
|
-
|
20
|
-
if transformer
|
21
|
-
raise ArgumentError, "Your transformer must be a kind of proc." if !transformer.kind_of?(Proc)
|
22
|
-
raise ArgumentError, "Your transformer must accept a parameter." if transformer.arity != 1
|
23
|
-
end
|
24
|
-
|
25
|
-
@name = name
|
26
|
-
@default = default
|
27
|
-
@transformer = transformer
|
28
|
-
end
|
29
12
|
|
30
13
|
# Suppose we have the following attribute template:
|
31
14
|
#
|
data/lib/superdupe/dupe.rb
CHANGED
@@ -11,7 +11,19 @@ class Dupe
|
|
11
11
|
# set this to "true" if you want Dupe to spit out mocked requests
|
12
12
|
# after each of your cucumber scenario's run
|
13
13
|
attr_accessor :debug
|
14
|
-
|
14
|
+
|
15
|
+
def enable!
|
16
|
+
@dupe_disabled = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def disable!
|
20
|
+
@dupe_disabled = true
|
21
|
+
end
|
22
|
+
|
23
|
+
def disabled?
|
24
|
+
@dupe_disabled
|
25
|
+
end
|
26
|
+
|
15
27
|
# Suppose we're creating a 'book' resource. Perhaps our app assumes every book has a title, so let's define a book resource
|
16
28
|
# that specifies just that:
|
17
29
|
#
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Something < ActiveResource::Base
|
4
|
+
self.site = 'http://localhost'
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Something do
|
8
|
+
it 'works as usuall witch mocked responses' do
|
9
|
+
Dupe.create Something, :name => 'really nothing'
|
10
|
+
Something.find(1).should be_a Something
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'ignores mocked resources when disabled' do
|
14
|
+
Dupe.disable!
|
15
|
+
Dupe.disabled?.should be true
|
16
|
+
lambda { Something.find(1) }.should raise_error
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'works as usuall again when enabled' do
|
20
|
+
Dupe.enable!
|
21
|
+
Dupe.create Something, :name => 'really nothing'
|
22
|
+
Something.find(1).should be_a Something
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superdupe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.5
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marco Ribi
|
@@ -16,11 +16,14 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2011-03-03 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
name: activeresource
|
26
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
27
|
none: false
|
25
28
|
requirements:
|
26
29
|
- - ">="
|
@@ -31,10 +34,7 @@ dependencies:
|
|
31
34
|
- 3
|
32
35
|
- 3
|
33
36
|
version: 2.3.3
|
34
|
-
|
35
|
-
name: activeresource
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: *id001
|
37
|
+
requirement: *id001
|
38
38
|
description: |-
|
39
39
|
SuperDupe is a fork of the originally Dupe and rides on top of ActiveResource to allow you to cuke the client side of
|
40
40
|
a service-oriented app without having to worry about whether or not the service is live or available while cuking.
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- rails_generators/dupe/templates/definitions.rb
|
72
72
|
- rails_generators/dupe/templates/load_dupe.rb
|
73
73
|
- spec/lib_specs/active_resource_extensions_spec.rb
|
74
|
+
- spec/lib_specs/disable_dupe_spec.rb
|
74
75
|
- spec/lib_specs/namespaced_active_resource_extensions_spec.rb
|
75
76
|
- spec/lib_specs/new_and_save_resource_spec.rb
|
76
77
|
- spec/spec_helper.rb
|
@@ -110,6 +111,7 @@ specification_version: 3
|
|
110
111
|
summary: A tool that helps you mock services while cuking.
|
111
112
|
test_files:
|
112
113
|
- spec/lib_specs/active_resource_extensions_spec.rb
|
114
|
+
- spec/lib_specs/disable_dupe_spec.rb
|
113
115
|
- spec/lib_specs/namespaced_active_resource_extensions_spec.rb
|
114
116
|
- spec/lib_specs/new_and_save_resource_spec.rb
|
115
117
|
- spec/spec_helper.rb
|