How to test this tiny part of the module, with super? (superclass - testing / integration action_dispatch-3.0.1 ...) The module is included in the specifications / requests for intercepting a message:
module ApiDoc
def post(path, parameters = nil, headers = nil)
super
document_request("post", path, parameters, headers) if ENV['API_DOC'] == "true"
end
...
end
I do not want it to run ActionDispatch :: Integration - independently, but I do not know how to mock or stub superto unit test it.
The module is used only in specifications and will have 100% testing coverage, which proves these types of indicators as useless. I need unit test it.
An example, if necessary, is how I use the ApiDoc module
require 'spec_helper'
describe "Products API" do
include ApiDoc
context "POST product" do
before do
@hash = {:product => {:name => "Test Name 1", :description => "Some data for testing"}}
end
it "can be done with JSON" do
valid_json = @hash.to_json
post("/products.json",valid_json,
{"CONTENT_TYPE" => "application/json",
"HTTP_AUTHORIZATION" => ActionController::HttpAuthentication::Basic.encode_credentials("user", "secret")})
response.should be_success
end
end
end
source
share