Commit 40a23685 authored by Rajendra Kadam's avatar Rajendra Kadam

Add path for fixture for schema json

Add a sample test in survey response controller
parent 4bf5ff00
......@@ -28,6 +28,8 @@ RSpec.describe SurveyResponsesController do
action: 'submit_response',
context: [{ schema: described_class::SURVEY_RESPONSE_SCHEMA_URL, data: { response: 'bar', survey_id: 1 } }]
)
match_snowplow_context_schema(schema_path: 'survey_response_schema', context: { :response => 'bar', :survey_id => 1, :instance_id => 2 } )
end
end
......
......@@ -13,6 +13,7 @@ module SchemaPath
end
Rails.root.join(dir.to_s, 'spec', "fixtures/api/schemas/#{schema}.json").to_s
Rails.root.join(dir.to_s, 'spec', "fixtures/product_intelligence/#{schema}.json").to_s
end
def self.validator(schema_path)
......@@ -46,13 +47,11 @@ RSpec::Matchers.define :match_response_schema do |schema, dir: nil, **options|
end
RSpec::Matchers.define :match_snowplow_schema do |schema, dir: nil, **options|
match do |response|
match do |data|
schema_path = Pathname.new(SchemaPath.expand(schema, dir))
validator = SchemaPath.validator(schema_path)
data = Gitlab::Json.parse(response.body)
validator.valid?(data)
validator.valid?(data.stringify_keys)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment