Module: Amfetamine::TestHelpers::ClassMethods
- Defined in:
- lib/amfetamine/helpers/test_helpers.rb
Instance Method Summary collapse
-
#prevent_external_connections! ⇒ Object
Allows for preventing external connections, also in a block.
- #restore_rest_client ⇒ Object
- #save_rest_client ⇒ Object
-
#stub_responses! {|rest_client| ... } ⇒ Object
Prevents external connections and provides a simple dsl.
Instance Method Details
#prevent_external_connections! ⇒ Object
Allows for preventing external connections, also in a block
10 11 12 13 14 15 16 17 18 |
# File 'lib/amfetamine/helpers/test_helpers.rb', line 10 def prevent_external_connections! save_rest_client self.rest_client = NeinNeinNein.new if block_given? yield self.rest_client restore_rest_client end end |
#restore_rest_client ⇒ Object
24 25 26 |
# File 'lib/amfetamine/helpers/test_helpers.rb', line 24 def restore_rest_client self.rest_client = @_old_rest_client || self.rest_client end |
#save_rest_client ⇒ Object
20 21 22 |
# File 'lib/amfetamine/helpers/test_helpers.rb', line 20 def save_rest_client @_old_rest_client = self.rest_client || @_old_rest_client end |
#stub_responses! {|rest_client| ... } ⇒ Object
Prevents external connections and provides a simple dsl
Dummy.stub_responses! do |r|
r.get(code: 200, path: '/dummies') { dummy }
end
33 34 35 36 |
# File 'lib/amfetamine/helpers/test_helpers.rb', line 33 def stub_responses! prevent_external_connections! yield rest_client end |