Compare 2 cucumber JSON reports with ruby











up vote
0
down vote

favorite












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
}
}
]
},









share|improve this question






















  • Did you look for a gems that compare json or hashes?
    – Martin Zinovsky
    2 days ago






  • 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
    2 days ago










  • @AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
    – Mikhah
    2 days ago










  • @AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
    – Mikhah
    2 days ago










  • @Mikhah cool, welcome.
    – Aleksei Matiushkin
    2 days ago















up vote
0
down vote

favorite












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
}
}
]
},









share|improve this question






















  • Did you look for a gems that compare json or hashes?
    – Martin Zinovsky
    2 days ago






  • 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
    2 days ago










  • @AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
    – Mikhah
    2 days ago










  • @AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
    – Mikhah
    2 days ago










  • @Mikhah cool, welcome.
    – Aleksei Matiushkin
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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
}
}
]
},









share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









Mikhah

619




619












  • Did you look for a gems that compare json or hashes?
    – Martin Zinovsky
    2 days ago






  • 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
    2 days ago










  • @AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
    – Mikhah
    2 days ago










  • @AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
    – Mikhah
    2 days ago










  • @Mikhah cool, welcome.
    – Aleksei Matiushkin
    2 days ago


















  • Did you look for a gems that compare json or hashes?
    – Martin Zinovsky
    2 days ago






  • 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
    2 days ago










  • @AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
    – Mikhah
    2 days ago










  • @AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
    – Mikhah
    2 days ago










  • @Mikhah cool, welcome.
    – Aleksei Matiushkin
    2 days ago
















Did you look for a gems that compare json or hashes?
– Martin Zinovsky
2 days ago




Did you look for a gems that compare json or hashes?
– Martin Zinovsky
2 days ago




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
2 days ago




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
2 days ago












@AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
– Mikhah
2 days ago




@AlekseiMatiushkin interesting, will try it now, I'll keep you posted on the result
– Mikhah
2 days ago












@AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
– Mikhah
2 days ago




@AlekseiMatiushkin looks like this is exactly what I've needed, thanks a lot
– Mikhah
2 days ago












@Mikhah cool, welcome.
– Aleksei Matiushkin
2 days ago




@Mikhah cool, welcome.
– Aleksei Matiushkin
2 days ago












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










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.






share|improve this answer





















    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',
    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
    });


    }
    });














     

    draft saved


    draft discarded


















    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








    up vote
    1
    down vote



    accepted










    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.






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      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.






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        Aleksei Matiushkin

        77k95087




        77k95087






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)