webmock_method 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTg0ZDU1N2I2OGZkMWEwYTNlYjE5YTk5ODJjNGUzNDg2MjRlYTVlMQ==
4
+ MmE0MWQxMjRjODAyYzJjZmM2NmY1Zjk3NTA1YzY5ZDVlMmM2YjBkYQ==
5
5
  data.tar.gz: !binary |-
6
- ZTYwM2I5ZDMzZGZmZDA5N2U2NDA4MDkwYjBmMGQ3MjViOTMyOWQzZQ==
6
+ N2IxNTc2ZmQwNzc0OWZmMGQ2NzIyZDgxZTUzNWEzYmVhMTRjZjFmMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGM3NTY0ODcyODk3MzA0OGJkMmU2YjNmMDc5MTMyODlkMzQ2YmI4NDA4Y2U4
10
- ZmU2YTMxODEwOTFiZWY3ZjdiNDdhMTZmNDMzODk2NTQ1NWI3ZDcxYWZhODVk
11
- Njk0MGM2MWY4OWQ1ZDgwZDgyMGRkZmM1MzRmZWQwY2E1ZWVjY2U=
9
+ MDlhZjg5NDgxYjRlMGZiNWI3MjM1ZTVjZDIwZjJjZjg1NDVlMThjMDU0ZjFj
10
+ YzM0MmE3N2VmZjk0NTNiYjdlOGM3YWE1YjkwY2Q3NWE0NjFkZTk4NjQ5ZDg3
11
+ NGYxN2Q0ZWIwNDhlYjVlOTNmODgxMjdlOTlmNzNlOWUxNWNhZTQ=
12
12
  data.tar.gz: !binary |-
13
- MzBmOTI1OTg5YWQ1NzVkMjhkOGJhZjc5ZmYyNDkzNzk1NGIzZmZhYWFjMWJl
14
- YjM3NjU1NGEwZTdmOTFlZTU3ZjM3ODAyNGM3MWIzMDVkZWE1MzQ5MWFlNDY2
15
- MjUwN2RlNDEyYjYyNjFiZmI5YTlmNTVjYjliOWEzZWZmMzU0YWI=
13
+ YTNhNmVjOTUyMjdmNzBhN2ZlMzFhN2NkYjUyNTBlZTc2N2RhMWYwOTAwNTc1
14
+ YTg0ZDFkNzBlN2U0MTRlZjUyMTZmODU0NjNmMjQ5YzhlN2MzNzJhMjI2MTM0
15
+ YzgyYzYwODA0YTQ3N2NjNmM2NzJkMmZlZjQ1NmQyMzU0MjZmNmI=
@@ -10,7 +10,7 @@
10
10
  </facet>
11
11
  </component>
12
12
  <component name="ModuleRunConfigurationManager">
13
- <configuration default="false" name="open_weather_spec: webmock_method" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
13
+ <configuration default="false" name="MetaMethods: webmock_method" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
14
14
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
15
15
  <module name="webmock_method" />
16
16
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -21,7 +21,7 @@
21
21
  <envs>
22
22
  <env name="JRUBY_OPTS" value="-X+O" />
23
23
  </envs>
24
- <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
24
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
25
25
  <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
26
26
  <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
27
27
  <COVERAGE_PATTERN ENABLED="true">
@@ -30,10 +30,10 @@
30
30
  </EXTENSION>
31
31
  <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
32
32
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
33
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/open_weather_map_service_spec.rb" />
33
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/meta_methods_spec.rb" />
34
34
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
35
35
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
36
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
36
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="MetaMethods" />
37
37
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
38
38
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
39
39
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
@@ -42,13 +42,11 @@
42
42
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
43
43
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
44
44
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
45
- <RunnerSettings RunnerId="RubyDebugRunner" />
46
45
  <RunnerSettings RunnerId="RubyRunner" />
47
- <ConfigurationWrapper RunnerId="RubyDebugRunner" />
48
46
  <ConfigurationWrapper RunnerId="RubyRunner" />
49
47
  <method />
50
48
  </configuration>
51
- <configuration default="false" name="PaymentGateway#purchase returns error response if amount is negative: webmock_method" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
49
+ <configuration default="false" name="OpenWeatherMapService#quote gets the quote: webmock_method" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
52
50
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
53
51
  <module name="webmock_method" />
54
52
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -68,10 +66,10 @@
68
66
  </EXTENSION>
69
67
  <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
70
68
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
71
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/payment_gateway_spec.rb" />
69
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/open_weather_map_service_spec.rb" />
72
70
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
73
71
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
74
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="PaymentGateway#purchase returns error response if amount is negative" />
72
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="OpenWeatherMapService#quote gets the quote" />
75
73
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
76
74
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
77
75
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
@@ -84,7 +82,7 @@
84
82
  <ConfigurationWrapper RunnerId="RubyRunner" />
85
83
  <method />
86
84
  </configuration>
87
- <configuration default="false" name="Run spec 'payment_gateway_spec': webmock_method" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
85
+ <configuration default="false" name="Run spec 'open_weather_map_service_spec': webmock_method" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
88
86
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
89
87
  <module name="webmock_method" />
90
88
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -104,7 +102,7 @@
104
102
  </EXTENSION>
105
103
  <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
106
104
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
107
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/payment_gateway_spec.rb" />
105
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/open_weather_map_service_spec.rb" />
108
106
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
109
107
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
110
108
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
@@ -120,7 +118,7 @@
120
118
  <ConfigurationWrapper RunnerId="RubyRunner" />
121
119
  <method />
122
120
  </configuration>
123
- <configuration default="false" name="MetaMethods: webmock_method" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
121
+ <configuration default="false" name="Run spec 'payment_gateway_spec': webmock_method" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
124
122
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
125
123
  <module name="webmock_method" />
126
124
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -140,10 +138,10 @@
140
138
  </EXTENSION>
141
139
  <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
142
140
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
143
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/meta_methods_spec.rb" />
141
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/payment_gateway_spec.rb" />
144
142
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
145
143
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
146
- <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="MetaMethods" />
144
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
147
145
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
148
146
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
149
147
  <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
@@ -184,29 +182,29 @@
184
182
  <component name="NewModuleRootManager">
185
183
  <content url="file://$MODULE_DIR$/../docs" />
186
184
  <content url="file://$MODULE_DIR$" />
187
- <orderEntry type="jdk" jdkName="RVM: ruby-1.9.3-p545 [webmock_method]" jdkType="RUBY_SDK" />
185
+ <orderEntry type="jdk" jdkName="RVM: ruby-1.9.3-p550 [webmock_method]" jdkType="RUBY_SDK" />
188
186
  <orderEntry type="sourceFolder" forTests="false" />
189
- <orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.5, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
190
- <orderEntry type="library" scope="PROVIDED" name="awesome_print (v1.2.0, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
191
- <orderEntry type="library" scope="PROVIDED" name="bundler (v1.5.3, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
192
- <orderEntry type="library" scope="PROVIDED" name="crack (v0.4.2, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
193
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
194
- <orderEntry type="library" scope="PROVIDED" name="file_utils (v1.0.7, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
195
- <orderEntry type="library" scope="PROVIDED" name="gemcutter (v0.7.1, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
196
- <orderEntry type="library" scope="PROVIDED" name="gemspec_deps_gen (v1.1.2, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
197
- <orderEntry type="library" scope="PROVIDED" name="haml (v4.0.5, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
198
- <orderEntry type="library" scope="PROVIDED" name="json_pure (v1.8.1, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
199
- <orderEntry type="library" scope="PROVIDED" name="meta_methods (v1.1.0, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
200
- <orderEntry type="library" scope="PROVIDED" name="metaclass (v0.0.4, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
201
- <orderEntry type="library" scope="PROVIDED" name="mocha (v1.0.0, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
202
- <orderEntry type="library" scope="PROVIDED" name="rspec (v2.14.1, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
203
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.14.8, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
204
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.14.5, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
205
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.14.6, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
206
- <orderEntry type="library" scope="PROVIDED" name="safe_yaml (v1.0.1, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
207
- <orderEntry type="library" scope="PROVIDED" name="tilt (v2.0.1, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
208
- <orderEntry type="library" scope="PROVIDED" name="webmock (v1.17.4, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
209
- <orderEntry type="library" scope="PROVIDED" name="xml-simple (v1.1.3, RVM: ruby-1.9.3-p545 [webmock_method]) [gem]" level="application" />
187
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.6, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
188
+ <orderEntry type="library" scope="PROVIDED" name="awesome_print (v1.2.0, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
189
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.4, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
190
+ <orderEntry type="library" scope="PROVIDED" name="crack (v0.4.2, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
191
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
192
+ <orderEntry type="library" scope="PROVIDED" name="file_utils (v1.0.7, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
193
+ <orderEntry type="library" scope="PROVIDED" name="gemcutter (v0.7.1, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
194
+ <orderEntry type="library" scope="PROVIDED" name="gemspec_deps_gen (v1.1.2, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
195
+ <orderEntry type="library" scope="PROVIDED" name="haml (v4.0.5, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
196
+ <orderEntry type="library" scope="PROVIDED" name="json_pure (v1.8.1, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
197
+ <orderEntry type="library" scope="PROVIDED" name="meta_methods (v1.3.0, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
198
+ <orderEntry type="library" scope="PROVIDED" name="metaclass (v0.0.4, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
199
+ <orderEntry type="library" scope="PROVIDED" name="mocha (v1.1.0, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
200
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.1.0, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
201
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.1.7, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
202
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.1.2, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
203
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.1.3, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
204
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.1.2, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
205
+ <orderEntry type="library" scope="PROVIDED" name="safe_yaml (v1.0.4, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
206
+ <orderEntry type="library" scope="PROVIDED" name="tilt (v2.0.1, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
207
+ <orderEntry type="library" scope="PROVIDED" name="webmock (v1.20.4, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
208
+ <orderEntry type="library" scope="PROVIDED" name="xml-simple (v1.1.4, RVM: ruby-1.9.3-p550 [webmock_method]) [gem]" level="application" />
210
209
  </component>
211
- </module>
212
-
210
+ </module>
data/CHANGES CHANGED
@@ -21,4 +21,8 @@
21
21
 
22
22
  == Version 1.2.1
23
23
 
24
- * Small bug fix.
24
+ * Small bug fix.
25
+
26
+ == Version 1.2.2
27
+
28
+ * Bug fix.
data/README.md CHANGED
@@ -73,14 +73,14 @@ Then, create stub/mock for your service:
73
73
  # stubs/open_weather_map_service.rb
74
74
 
75
75
  require 'webmock_method'
76
- require 'json'
77
76
 
78
77
  require 'services/open_weather_map_service.rb'
79
78
 
80
79
  class OpenWeatherMapService
81
80
  extend WebmockMethod
82
81
 
83
- webmock_method :quote, [:location, :units], lambda { |_|
82
+ webmock_method :quote, [:location, :units],
83
+ lambda { |_|
84
84
  File.open "#{File.dirname(__FILE__)}/stubs/templates/quote_response.json.erb"
85
85
  }, /#{WebmockMethod.url}/
86
86
  end
@@ -94,10 +94,11 @@ end
94
94
  * **url** to remote service (optional).
95
95
 
96
96
  You can build responses of arbitrary complexity with your own code or you can use **RenderHelper**, that comes with this
97
- gem. Currently it supports **erb** renderer only. Here is example of how to build xml response:
97
+ gem. Currently it supports **erb** and **haml** renderers only. Here is example of how to build xml response:
98
98
 
99
99
  ```ruby
100
- webmock_method :purchase, [:amount, :credit_card], lambda { |binding|
100
+ webmock_method :purchase, [:amount, :credit_card],
101
+ lambda { |binding|
101
102
  RenderHelper.render :erb, "#{File.dirname(__FILE__)}/templates/purchase_response.xml.erb", binding
102
103
  }
103
104
  ```
@@ -105,8 +106,9 @@ gem. Currently it supports **erb** renderer only. Here is example of how to buil
105
106
  It's possible to tweak your response on the fly:
106
107
 
107
108
  ```ruby
108
- webmock_method :purchase, [:amount, :credit_card], lambda { |binding|
109
- RenderHelper.render :erb, "#{File.dirname(__FILE__)}/templates/purchase_response.xml.erb", binding
109
+ webmock_method :purchase, [:amount, :credit_card],
110
+ lambda { |binding|
111
+ RenderHelper.render :erb, "#{File.dirname(__FILE__)}/templates/purchase_response.xml.erb", binding
110
112
  } do |parent, _, credit_card|
111
113
  if credit_card.card_type == "VISA"
112
114
  define_attribute(parent, :success, true)
@@ -140,6 +142,8 @@ WebmockMethod.url = "http://api.openweathermap.org/data/2.5/weather"
140
142
  And finally, create spec for testing your mocked service:
141
143
 
142
144
  ```ruby
145
+ require 'json'
146
+
143
147
  require "stubs/open_weather_map_service"
144
148
 
145
149
  describe OpenWeatherMapService do
@@ -153,6 +157,35 @@ describe OpenWeatherMapService do
153
157
  end
154
158
  ```
155
159
 
160
+ If you need to simulate exception raised inside the mocked method, do the following:
161
+
162
+ ```ruby
163
+ webmock_method :purchase, [:amount, :credit_card],
164
+ lambda { |binding|
165
+ # prepare response
166
+ ...
167
+ } do |parent, amount, credit_card|
168
+ define_attribute(parent, :error, create_error(parent, "Negative amount")) if amount < 0
169
+
170
+ ...
171
+ end
172
+
173
+ def self.create_error parent, reason
174
+ define_attribute(parent, :error, Exception.new(reason))
175
+ end
176
+
177
+ end
178
+ ```
179
+
180
+ **webmock** gem code is aware of **error** variable and will throw this exception, so yo can verify it inside
181
+ your test:
182
+
183
+ ```ruby
184
+ it "returns error response if amount is negative" do
185
+ expect{subject.purchase(-1000, valid_credit_card)}.to raise_exception(Exception)
186
+ end
187
+ ```
188
+
156
189
  ## Contributing
157
190
 
158
191
  1. Fork it
@@ -1,3 +1,3 @@
1
- module WebmockMethod
2
- VERSION = "1.2.1"
1
+ class WebmockMethod
2
+ VERSION = "1.2.2"
3
3
  end
@@ -1,8 +1,8 @@
1
1
  require 'webmock'
2
- require 'meta_methods'
2
+ require 'meta_methods/core'
3
3
 
4
4
  module WebmockMethod
5
- include MetaMethods::Core
5
+ # include MetaMethods::Core
6
6
 
7
7
  extend self
8
8
 
@@ -15,7 +15,7 @@ module WebmockMethod
15
15
 
16
16
  define_method("#{method_name}_with_webmock_method") do |*args|
17
17
  param_names.each_with_index do |param_name, index|
18
- current_class.define_attribute(self, param_name, args[index])
18
+ MetaMethods::Core.instance.define_attribute(self, param_name, args[index])
19
19
  end
20
20
 
21
21
  yield(self, *args) if block_given?
@@ -21,20 +21,22 @@ end
21
21
  # 2. Create service mock
22
22
 
23
23
  require 'webmock_method'
24
- require 'json'
25
24
 
26
25
  class OpenWeatherMapService
27
26
  extend WebmockMethod
28
27
 
29
- webmock_method :quote, [:location, :units], lambda { |_|
30
- File.open "#{File.dirname(__FILE__)}/stubs/templates/quote_response.json.erb"
31
- }, /#{WebmockMethod.url}/
28
+ webmock_method :quote, [:location, :units],
29
+ lambda { |_|
30
+ File.open "#{File.dirname(__FILE__)}/stubs/templates/quote_response.json.erb"
31
+ }, /#{WebmockMethod.url}/
32
32
  end
33
33
 
34
34
  # 3. Test service mock
35
35
 
36
36
  # Make sure we don't hit external service: when stub is commented, test should fail
37
- WebMock.disable_net_connect!(allow_localhost: true)
37
+ # WebMock.disable_net_connect!(allow_localhost: true)
38
+
39
+ require 'json'
38
40
 
39
41
  describe OpenWeatherMapService do
40
42
  describe "#quote" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock_method
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-25 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webmock
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.2.2
141
+ rubygems_version: 2.4.2
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Extension for webmock to make stubbed methods.