Ruby Airbone array testing is not working as expectedCalling shell commands from RubyUnit Testing C CodeWhat is Unit test, Integration Test, Smoke test, Regression Test?A concise explanation of nil v. empty v. blank in Ruby on RailsHow to write a switch statement in RubyHow to convert a string to lower or upper case in RubyCheck if a value exists in an array in Rubyclass << self idiom in RubyWhat is attr_accessor in Ruby?Why is it bad style to `rescue Exception => e` in Ruby?

Finitely generated matrix groups whose eigenvalues are all algebraic

ssTTsSTtRrriinInnnnNNNIiinngg

What is the opposite of "eschatology"?

Car headlights in a world without electricity

Does the Cone of Cold spell freeze water?

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

How dangerous is XSS

Why didn't Boeing produce its own regional jet?

How exploitable/balanced is this homebrew spell: Spell Permanency?

Does the Idaho Potato Commission associate potato skins with healthy eating?

Do creatures with a listed speed of "0 ft., fly 30 ft. (hover)" ever touch the ground?

Mathematica command that allows it to read my intentions

Do Iron Man suits sport waste management systems?

Different meanings of こわい

Can I hook these wires up to find the connection to a dead outlet?

Fair gambler's ruin problem intuition

How do I exit BASH while loop using modulus operator?

How to show a landlord what we have in savings?

One verb to replace 'be a member of' a club

My ex-girlfriend uses my Apple ID to log in to her iPad. Do I have to give her my Apple ID password to reset it?

Is this answer explanation correct?

Is this draw by repetition?

Is it "common practice in Fourier transform spectroscopy to multiply the measured interferogram by an apodizing function"? If so, why?

What's the meaning of "Sollensaussagen"?



Ruby Airbone array testing is not working as expected


Calling shell commands from RubyUnit Testing C CodeWhat is Unit test, Integration Test, Smoke test, Regression Test?A concise explanation of nil v. empty v. blank in Ruby on RailsHow to write a switch statement in RubyHow to convert a string to lower or upper case in RubyCheck if a value exists in an array in Rubyclass << self idiom in RubyWhat is attr_accessor in Ruby?Why is it bad style to `rescue Exception => e` in Ruby?













0















I have the json below




"menu":
"sections": [

"type": 4,
"frames": [

"itens": []

],
"order": 0
,

"type": 4,
"frames": [

"itens": [

"id": "1719016",
"type": 0,
"free": false

]

],
"order": 1

]




and the test below that may check if all json itens in array itens has an ID property:



expect_json_keys('menu.sections.0.frames.*.itens.*', :id)


The problem is that this test runs fine. But should fail.



My test only fail when I change my expectations to that:



expect_json_keys('menu.sections.0.frames.*.itens.0', :id)


Why this test is succesful instead of fail when using itens.*










share|improve this question


























    0















    I have the json below




    "menu":
    "sections": [

    "type": 4,
    "frames": [

    "itens": []

    ],
    "order": 0
    ,

    "type": 4,
    "frames": [

    "itens": [

    "id": "1719016",
    "type": 0,
    "free": false

    ]

    ],
    "order": 1

    ]




    and the test below that may check if all json itens in array itens has an ID property:



    expect_json_keys('menu.sections.0.frames.*.itens.*', :id)


    The problem is that this test runs fine. But should fail.



    My test only fail when I change my expectations to that:



    expect_json_keys('menu.sections.0.frames.*.itens.0', :id)


    Why this test is succesful instead of fail when using itens.*










    share|improve this question
























      0












      0








      0








      I have the json below




      "menu":
      "sections": [

      "type": 4,
      "frames": [

      "itens": []

      ],
      "order": 0
      ,

      "type": 4,
      "frames": [

      "itens": [

      "id": "1719016",
      "type": 0,
      "free": false

      ]

      ],
      "order": 1

      ]




      and the test below that may check if all json itens in array itens has an ID property:



      expect_json_keys('menu.sections.0.frames.*.itens.*', :id)


      The problem is that this test runs fine. But should fail.



      My test only fail when I change my expectations to that:



      expect_json_keys('menu.sections.0.frames.*.itens.0', :id)


      Why this test is succesful instead of fail when using itens.*










      share|improve this question














      I have the json below




      "menu":
      "sections": [

      "type": 4,
      "frames": [

      "itens": []

      ],
      "order": 0
      ,

      "type": 4,
      "frames": [

      "itens": [

      "id": "1719016",
      "type": 0,
      "free": false

      ]

      ],
      "order": 1

      ]




      and the test below that may check if all json itens in array itens has an ID property:



      expect_json_keys('menu.sections.0.frames.*.itens.*', :id)


      The problem is that this test runs fine. But should fail.



      My test only fail when I change my expectations to that:



      expect_json_keys('menu.sections.0.frames.*.itens.0', :id)


      Why this test is succesful instead of fail when using itens.*







      ruby testing airborne






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 21:29









      user3810036user3810036

      284




      284






















          2 Answers
          2






          active

          oldest

          votes


















          1














          I reproduced your problem and tried to debug a bit.



          I see this airborne gem for the first time (so take the following with a grain of salt), but I think the problem hides in the airborne implementation itself, here, to be more precise: https://github.com/brooklynDev/airborne/blob/master/lib/airborne/path_matcher.rb#L82



          This line is intended to run expectation block (this one in this particular case) for each item matching the wildcarded segment, but for an empty array it simply does nothing. No expectations run - no failures.



          So it's not something wrong in your tests code, it's about the gem itself.
          As a kind of workaround, you could try smth. like the following:



          expect_json_types('menu.sections.0.frames.*.itens', :array_of_objects) # <= add this
          expect_json_keys('menu.sections.0.frames.*.itens.*', :id)


          e.g. testing the type of the value before testing the value itself - in this case it fails with Expected array_of_objects got Array instead






          share|improve this answer






























            0














            Thank you very much @konstantin-strukov. This solution works fine for this test case.



            But in some test cases I still have to write some extra code.



            The expectation you´ve writen fails for this json http://www.mocky.io/v2/5c827f26310000e8421d1e83. OK, I have a test case where it should really fail. I´ll use your solution in a lot of use cases. Thank you again.



            But I have some test cases that shouldn´t fail if I have at least one filled itens property (http://www.mocky.io/v2/5c827f26310000e8421d1e83). expect_json_keys('menu.sections.0.frames.*.itens.?', :id) should be sufficient but it doesn´t because it works using itens.* or itens.?. I´ve tried to fit your solution in these test cases but it didn´t work as expected.






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



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053079%2fruby-airbone-array-testing-is-not-working-as-expected%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              I reproduced your problem and tried to debug a bit.



              I see this airborne gem for the first time (so take the following with a grain of salt), but I think the problem hides in the airborne implementation itself, here, to be more precise: https://github.com/brooklynDev/airborne/blob/master/lib/airborne/path_matcher.rb#L82



              This line is intended to run expectation block (this one in this particular case) for each item matching the wildcarded segment, but for an empty array it simply does nothing. No expectations run - no failures.



              So it's not something wrong in your tests code, it's about the gem itself.
              As a kind of workaround, you could try smth. like the following:



              expect_json_types('menu.sections.0.frames.*.itens', :array_of_objects) # <= add this
              expect_json_keys('menu.sections.0.frames.*.itens.*', :id)


              e.g. testing the type of the value before testing the value itself - in this case it fails with Expected array_of_objects got Array instead






              share|improve this answer



























                1














                I reproduced your problem and tried to debug a bit.



                I see this airborne gem for the first time (so take the following with a grain of salt), but I think the problem hides in the airborne implementation itself, here, to be more precise: https://github.com/brooklynDev/airborne/blob/master/lib/airborne/path_matcher.rb#L82



                This line is intended to run expectation block (this one in this particular case) for each item matching the wildcarded segment, but for an empty array it simply does nothing. No expectations run - no failures.



                So it's not something wrong in your tests code, it's about the gem itself.
                As a kind of workaround, you could try smth. like the following:



                expect_json_types('menu.sections.0.frames.*.itens', :array_of_objects) # <= add this
                expect_json_keys('menu.sections.0.frames.*.itens.*', :id)


                e.g. testing the type of the value before testing the value itself - in this case it fails with Expected array_of_objects got Array instead






                share|improve this answer

























                  1












                  1








                  1







                  I reproduced your problem and tried to debug a bit.



                  I see this airborne gem for the first time (so take the following with a grain of salt), but I think the problem hides in the airborne implementation itself, here, to be more precise: https://github.com/brooklynDev/airborne/blob/master/lib/airborne/path_matcher.rb#L82



                  This line is intended to run expectation block (this one in this particular case) for each item matching the wildcarded segment, but for an empty array it simply does nothing. No expectations run - no failures.



                  So it's not something wrong in your tests code, it's about the gem itself.
                  As a kind of workaround, you could try smth. like the following:



                  expect_json_types('menu.sections.0.frames.*.itens', :array_of_objects) # <= add this
                  expect_json_keys('menu.sections.0.frames.*.itens.*', :id)


                  e.g. testing the type of the value before testing the value itself - in this case it fails with Expected array_of_objects got Array instead






                  share|improve this answer













                  I reproduced your problem and tried to debug a bit.



                  I see this airborne gem for the first time (so take the following with a grain of salt), but I think the problem hides in the airborne implementation itself, here, to be more precise: https://github.com/brooklynDev/airborne/blob/master/lib/airborne/path_matcher.rb#L82



                  This line is intended to run expectation block (this one in this particular case) for each item matching the wildcarded segment, but for an empty array it simply does nothing. No expectations run - no failures.



                  So it's not something wrong in your tests code, it's about the gem itself.
                  As a kind of workaround, you could try smth. like the following:



                  expect_json_types('menu.sections.0.frames.*.itens', :array_of_objects) # <= add this
                  expect_json_keys('menu.sections.0.frames.*.itens.*', :id)


                  e.g. testing the type of the value before testing the value itself - in this case it fails with Expected array_of_objects got Array instead







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 7 at 23:15









                  Konstantin StrukovKonstantin Strukov

                  1914




                  1914























                      0














                      Thank you very much @konstantin-strukov. This solution works fine for this test case.



                      But in some test cases I still have to write some extra code.



                      The expectation you´ve writen fails for this json http://www.mocky.io/v2/5c827f26310000e8421d1e83. OK, I have a test case where it should really fail. I´ll use your solution in a lot of use cases. Thank you again.



                      But I have some test cases that shouldn´t fail if I have at least one filled itens property (http://www.mocky.io/v2/5c827f26310000e8421d1e83). expect_json_keys('menu.sections.0.frames.*.itens.?', :id) should be sufficient but it doesn´t because it works using itens.* or itens.?. I´ve tried to fit your solution in these test cases but it didn´t work as expected.






                      share|improve this answer



























                        0














                        Thank you very much @konstantin-strukov. This solution works fine for this test case.



                        But in some test cases I still have to write some extra code.



                        The expectation you´ve writen fails for this json http://www.mocky.io/v2/5c827f26310000e8421d1e83. OK, I have a test case where it should really fail. I´ll use your solution in a lot of use cases. Thank you again.



                        But I have some test cases that shouldn´t fail if I have at least one filled itens property (http://www.mocky.io/v2/5c827f26310000e8421d1e83). expect_json_keys('menu.sections.0.frames.*.itens.?', :id) should be sufficient but it doesn´t because it works using itens.* or itens.?. I´ve tried to fit your solution in these test cases but it didn´t work as expected.






                        share|improve this answer

























                          0












                          0








                          0







                          Thank you very much @konstantin-strukov. This solution works fine for this test case.



                          But in some test cases I still have to write some extra code.



                          The expectation you´ve writen fails for this json http://www.mocky.io/v2/5c827f26310000e8421d1e83. OK, I have a test case where it should really fail. I´ll use your solution in a lot of use cases. Thank you again.



                          But I have some test cases that shouldn´t fail if I have at least one filled itens property (http://www.mocky.io/v2/5c827f26310000e8421d1e83). expect_json_keys('menu.sections.0.frames.*.itens.?', :id) should be sufficient but it doesn´t because it works using itens.* or itens.?. I´ve tried to fit your solution in these test cases but it didn´t work as expected.






                          share|improve this answer













                          Thank you very much @konstantin-strukov. This solution works fine for this test case.



                          But in some test cases I still have to write some extra code.



                          The expectation you´ve writen fails for this json http://www.mocky.io/v2/5c827f26310000e8421d1e83. OK, I have a test case where it should really fail. I´ll use your solution in a lot of use cases. Thank you again.



                          But I have some test cases that shouldn´t fail if I have at least one filled itens property (http://www.mocky.io/v2/5c827f26310000e8421d1e83). expect_json_keys('menu.sections.0.frames.*.itens.?', :id) should be sufficient but it doesn´t because it works using itens.* or itens.?. I´ve tried to fit your solution in these test cases but it didn´t work as expected.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 8 at 16:12









                          user3810036user3810036

                          284




                          284



























                              draft saved

                              draft discarded
















































                              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.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053079%2fruby-airbone-array-testing-is-not-working-as-expected%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

                              Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                              Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                              Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved