Compare 2 cucumber JSON reports with ruby
The problem is: I have 2 cucumber test reports in JSON format
I need to remove redundant key-value pairs from those reports and compare them, but I can't understand how to remove the unnecessary data from those 2 jsons because of their structure after JSON.parse (array or hash with many nested arrays/hashes). Please advice if there are some gems or known solutions to do this
JSON structure is e.g. :
[
{
"uri": "features/home_screen.feature",
"id": "as-a-user-i-want-to-explore-home-screen",
"keyword": "Feature",
"name": "As a user I want to explore home screen",
"description": "",
"line": 2,
"tags": [
{
"name": "@home_screen",
"line": 1
}
],
"elements": [
{
"keyword": "Background",
"name": "",
"description": "",
"line": 3,
"type": "background",
"before": [
{
"match": {
"location": "features/step_definitions/support/hooks.rb:1"
},
"result": {
"status": "passed",
"duration": 505329000
}
}
],
"steps": [
{
"keyword": "Given ",
"name": "I click OK button in popup",
"line": 4,
"match": {
"location": "features/step_definitions/registration_steps.rb:91"
},
"result": {
"status": "passed",
"duration": 2329140000
}
},
{
"keyword": "And ",
"name": "I click Allow button in popup",
"line": 5,
"match": {
"location": "features/step_definitions/registration_steps.rb:96"
},
"result": {
"status": "passed",
"duration": 1861776000
}
}
]
},
json ruby cucumber
|
show 1 more comment
The problem is: I have 2 cucumber test reports in JSON format
I need to remove redundant key-value pairs from those reports and compare them, but I can't understand how to remove the unnecessary data from those 2 jsons because of their structure after JSON.parse (array or hash with many nested arrays/hashes). Please advice if there are some gems or known solutions to do this
JSON structure is e.g. :
[
{
"uri": "features/home_screen.feature",
"id": "as-a-user-i-want-to-explore-home-screen",
"keyword": "Feature",
"name": "As a user I want to explore home screen",
"description": "",
"line": 2,
"tags": [
{
"name": "@home_screen",
"line": 1
}
],
"elements": [
{
"keyword": "Background",
"name": "",
"description": "",
"line": 3,
"type": "background",
"before": [
{
"match": {
"location": "features/step_definitions/support/hooks.rb:1"
},
"result": {
"status": "passed",
"duration": 505329000
}
}
],
"steps": [
{
"keyword": "Given ",
"name": "I click OK button in popup",
"line": 4,
"match": {
"location": "features/step_definitions/registration_steps.rb:91"
},
"result": {
"status": "passed",
"duration": 2329140000
}
},
{
"keyword": "And ",
"name": "I click Allow button in popup",
"line": 5,
"match": {
"location": "features/step_definitions/registration_steps.rb:96"
},
"result": {
"status": "passed",
"duration": 1861776000
}
}
]
},
json ruby cucumber
Did you look for a gems that compare json or hashes?
– Martin Zinovsky
Nov 21 '18 at 10:45
1
You might tryiteraptor
the gem I have created exactly for this kind of tasks. It allows iterating, mapping and reducing the deeply nested structures.
– Aleksei Matiushkin
Nov 21 '18 at 10:48
@AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
– Mikhah
Nov 21 '18 at 10:56
@AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
– Mikhah
Nov 21 '18 at 11:31
@Mikhah cool, welcome.
– Aleksei Matiushkin
Nov 21 '18 at 11:42
|
show 1 more comment
The problem is: I have 2 cucumber test reports in JSON format
I need to remove redundant key-value pairs from those reports and compare them, but I can't understand how to remove the unnecessary data from those 2 jsons because of their structure after JSON.parse (array or hash with many nested arrays/hashes). Please advice if there are some gems or known solutions to do this
JSON structure is e.g. :
[
{
"uri": "features/home_screen.feature",
"id": "as-a-user-i-want-to-explore-home-screen",
"keyword": "Feature",
"name": "As a user I want to explore home screen",
"description": "",
"line": 2,
"tags": [
{
"name": "@home_screen",
"line": 1
}
],
"elements": [
{
"keyword": "Background",
"name": "",
"description": "",
"line": 3,
"type": "background",
"before": [
{
"match": {
"location": "features/step_definitions/support/hooks.rb:1"
},
"result": {
"status": "passed",
"duration": 505329000
}
}
],
"steps": [
{
"keyword": "Given ",
"name": "I click OK button in popup",
"line": 4,
"match": {
"location": "features/step_definitions/registration_steps.rb:91"
},
"result": {
"status": "passed",
"duration": 2329140000
}
},
{
"keyword": "And ",
"name": "I click Allow button in popup",
"line": 5,
"match": {
"location": "features/step_definitions/registration_steps.rb:96"
},
"result": {
"status": "passed",
"duration": 1861776000
}
}
]
},
json ruby cucumber
The problem is: I have 2 cucumber test reports in JSON format
I need to remove redundant key-value pairs from those reports and compare them, but I can't understand how to remove the unnecessary data from those 2 jsons because of their structure after JSON.parse (array or hash with many nested arrays/hashes). Please advice if there are some gems or known solutions to do this
JSON structure is e.g. :
[
{
"uri": "features/home_screen.feature",
"id": "as-a-user-i-want-to-explore-home-screen",
"keyword": "Feature",
"name": "As a user I want to explore home screen",
"description": "",
"line": 2,
"tags": [
{
"name": "@home_screen",
"line": 1
}
],
"elements": [
{
"keyword": "Background",
"name": "",
"description": "",
"line": 3,
"type": "background",
"before": [
{
"match": {
"location": "features/step_definitions/support/hooks.rb:1"
},
"result": {
"status": "passed",
"duration": 505329000
}
}
],
"steps": [
{
"keyword": "Given ",
"name": "I click OK button in popup",
"line": 4,
"match": {
"location": "features/step_definitions/registration_steps.rb:91"
},
"result": {
"status": "passed",
"duration": 2329140000
}
},
{
"keyword": "And ",
"name": "I click Allow button in popup",
"line": 5,
"match": {
"location": "features/step_definitions/registration_steps.rb:96"
},
"result": {
"status": "passed",
"duration": 1861776000
}
}
]
},
json ruby cucumber
json ruby cucumber
asked Nov 21 '18 at 10:43
MikhahMikhah
699
699
Did you look for a gems that compare json or hashes?
– Martin Zinovsky
Nov 21 '18 at 10:45
1
You might tryiteraptor
the gem I have created exactly for this kind of tasks. It allows iterating, mapping and reducing the deeply nested structures.
– Aleksei Matiushkin
Nov 21 '18 at 10:48
@AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
– Mikhah
Nov 21 '18 at 10:56
@AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
– Mikhah
Nov 21 '18 at 11:31
@Mikhah cool, welcome.
– Aleksei Matiushkin
Nov 21 '18 at 11:42
|
show 1 more comment
Did you look for a gems that compare json or hashes?
– Martin Zinovsky
Nov 21 '18 at 10:45
1
You might tryiteraptor
the gem I have created exactly for this kind of tasks. It allows iterating, mapping and reducing the deeply nested structures.
– Aleksei Matiushkin
Nov 21 '18 at 10:48
@AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
– Mikhah
Nov 21 '18 at 10:56
@AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
– Mikhah
Nov 21 '18 at 11:31
@Mikhah cool, welcome.
– Aleksei Matiushkin
Nov 21 '18 at 11:42
Did you look for a gems that compare json or hashes?
– Martin Zinovsky
Nov 21 '18 at 10:45
Did you look for a gems that compare json or hashes?
– Martin Zinovsky
Nov 21 '18 at 10:45
1
1
You might try
iteraptor
the gem I have created exactly for this kind of tasks. It allows iterating, mapping and reducing the deeply nested structures.– Aleksei Matiushkin
Nov 21 '18 at 10:48
You might try
iteraptor
the gem I have created exactly for this kind of tasks. It allows iterating, mapping and reducing the deeply nested structures.– Aleksei Matiushkin
Nov 21 '18 at 10:48
@AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
– Mikhah
Nov 21 '18 at 10:56
@AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
– Mikhah
Nov 21 '18 at 10:56
@AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
– Mikhah
Nov 21 '18 at 11:31
@AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
– Mikhah
Nov 21 '18 at 11:31
@Mikhah cool, welcome.
– Aleksei Matiushkin
Nov 21 '18 at 11:42
@Mikhah cool, welcome.
– Aleksei Matiushkin
Nov 21 '18 at 11:42
|
show 1 more comment
1 Answer
1
active
oldest
votes
Since you are asking for a gem, you might try iteraptor
I have created exactly for this kind of tasks.
It allows iterating, mapping and reducing the deeply nested structures. For instance, to filter out all the keys called "name"
on all levels, you might do:
input.iteraptor.reject(/name/)
The more detailed description might be found on the github page linked above.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410337%2fcompare-2-cucumber-json-reports-with-ruby%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since you are asking for a gem, you might try iteraptor
I have created exactly for this kind of tasks.
It allows iterating, mapping and reducing the deeply nested structures. For instance, to filter out all the keys called "name"
on all levels, you might do:
input.iteraptor.reject(/name/)
The more detailed description might be found on the github page linked above.
add a comment |
Since you are asking for a gem, you might try iteraptor
I have created exactly for this kind of tasks.
It allows iterating, mapping and reducing the deeply nested structures. For instance, to filter out all the keys called "name"
on all levels, you might do:
input.iteraptor.reject(/name/)
The more detailed description might be found on the github page linked above.
add a comment |
Since you are asking for a gem, you might try iteraptor
I have created exactly for this kind of tasks.
It allows iterating, mapping and reducing the deeply nested structures. For instance, to filter out all the keys called "name"
on all levels, you might do:
input.iteraptor.reject(/name/)
The more detailed description might be found on the github page linked above.
Since you are asking for a gem, you might try iteraptor
I have created exactly for this kind of tasks.
It allows iterating, mapping and reducing the deeply nested structures. For instance, to filter out all the keys called "name"
on all levels, you might do:
input.iteraptor.reject(/name/)
The more detailed description might be found on the github page linked above.
answered Nov 21 '18 at 11:54
Aleksei MatiushkinAleksei Matiushkin
81.5k95591
81.5k95591
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410337%2fcompare-2-cucumber-json-reports-with-ruby%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you look for a gems that compare json or hashes?
– Martin Zinovsky
Nov 21 '18 at 10:45
1
You might try
iteraptor
the gem I have created exactly for this kind of tasks. It allows iterating, mapping and reducing the deeply nested structures.– Aleksei Matiushkin
Nov 21 '18 at 10:48
@AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
– Mikhah
Nov 21 '18 at 10:56
@AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
– Mikhah
Nov 21 '18 at 11:31
@Mikhah cool, welcome.
– Aleksei Matiushkin
Nov 21 '18 at 11:42