Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-44991

Behat: add step to check if attribute DOES NOT contain text

    Details

    • Testing Instructions:
      Hide

      0. Place attached temporary file mdl44991.feature in the location course/tests/behat within your Moodle installation.
      1. Ensure Behat is working in general, including running the behat init script.
      2. Run Behat with --tags=mdl44991

      EXPECTED: You should see 2 scenarios both passed (usually takes a minute or two).

      3. Edit the .feature file to change both instances of 'has-region-side-pre' by removing the x from the name (so that the attribute does now contain that value).
      4. Rerun the same test

      EXPECTED:
      This time there should be 2 failures indicated and you should see a message like:
      01. The attribute "class" contains "haxs-region-side-pre" (value: "format-site course path-site [...and so on, it's kind of a long attribute....]")

      Show
      0. Place attached temporary file mdl44991.feature in the location course/tests/behat within your Moodle installation. 1. Ensure Behat is working in general, including running the behat init script. 2. Run Behat with --tags=mdl44991 EXPECTED: You should see 2 scenarios both passed (usually takes a minute or two). 3. Edit the .feature file to change both instances of 'has-region-side-pre' by removing the x from the name (so that the attribute does now contain that value). 4. Rerun the same test EXPECTED: This time there should be 2 failures indicated and you should see a message like: 01. The attribute "class" contains "haxs-region-side-pre" (value: "format-site course path-site [...and so on, it's kind of a long attribute....] ")
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull Master Branch:
      MDL-44991-master

      Description

      Add step opposite to MDL-44891

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              quen Sam Marshall added a comment -

              I've made the step with the exact same wording but 'should not' instead of 'should', as required for consistency.

              Based on the wording, and after discussion in dev chat, I decided to make it behave as follows:

              Example:

              Then the "X" attribute of "Y" "css_element" should not contain "Z"

              PASS IF: Y has attribute X, and the text of attribute X does not contain Z
              FAIL IF: Y does not have attribute X, or Y has attribute X but the text of attribute X contains Z.

              Basically because of the wording this makes sense. It's not a complete opposite of the 'should' step though, because it will still fail if the attribute doesn't exist. Probably, if we needed a way to check for the attribute not existing, we should add another additional step (and make it a pair for symmetry) to ensure unambiguous wording:

              Then Y should not have attribute X
              Then Y should have attribute X

              Not sure anybody needs those though, so I figure probably best to leave it until required rather than add unnecessary steps!

              Show
              quen Sam Marshall added a comment - I've made the step with the exact same wording but 'should not' instead of 'should', as required for consistency. Based on the wording, and after discussion in dev chat, I decided to make it behave as follows: Example: Then the "X" attribute of "Y" "css_element" should not contain "Z" PASS IF: Y has attribute X, and the text of attribute X does not contain Z FAIL IF: Y does not have attribute X, or Y has attribute X but the text of attribute X contains Z. Basically because of the wording this makes sense. It's not a complete opposite of the 'should' step though, because it will still fail if the attribute doesn't exist. Probably, if we needed a way to check for the attribute not existing, we should add another additional step (and make it a pair for symmetry) to ensure unambiguous wording: Then Y should not have attribute X Then Y should have attribute X Not sure anybody needs those though, so I figure probably best to leave it until required rather than add unnecessary steps!
              Hide
              cibot CiBoT added a comment -

              Results for MDL-44991

              Show
              cibot CiBoT added a comment - Results for MDL-44991 Remote repository: https://github.com/sammarshallou/moodle.git Remote branch MDL-44991 -m25 to be integrated into upstream MOODLE_25_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2856 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2856/artifact/work/smurf.html Remote branch MDL-44991 -m26 to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2857 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2857/artifact/work/smurf.html Remote branch MDL-44991 -master to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2858 Error: The MDL-44991 -master branch at https://github.com/sammarshallou/moodle.git exceeds the maximum number of commits ( 99 > 15)
              Hide
              quen Sam Marshall added a comment -

              Tim peer reviewed this (over my shoulder) - submitting for integration.

              There isn't any particular urgency in this feature, however Marina is correct that it makes sense to have it to pair with the already-integrated 'should' version.

              Show
              quen Sam Marshall added a comment - Tim peer reviewed this (over my shoulder) - submitting for integration. There isn't any particular urgency in this feature, however Marina is correct that it makes sense to have it to pair with the already-integrated 'should' version.
              Hide
              quen Sam Marshall added a comment -

              Note: The stable branches are based on my MDL-44891 stable branches; the master branch is based on integration/master. In each case it's just the last commit that is relevant to this specific issue.

              Show
              quen Sam Marshall added a comment - Note: The stable branches are based on my MDL-44891 stable branches; the master branch is based on integration/master. In each case it's just the last commit that is relevant to this specific issue.
              Hide
              quen Sam Marshall added a comment -

              Rebased on latest stable/master branches and pushed.

              Show
              quen Sam Marshall added a comment - Rebased on latest stable/master branches and pushed.
              Show
              cibot CiBoT added a comment - Results for MDL-44991 Remote repository: https://github.com/sammarshallou/moodle.git Remote branch MDL-44991 -m25 to be integrated into upstream MOODLE_25_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2923 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2923/artifact/work/smurf.html Remote branch MDL-44991 -m26 to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2924 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2924/artifact/work/smurf.html Remote branch MDL-44991 -master to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2925 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2925/artifact/work/smurf.html
              Hide
              marina Marina Glancy added a comment -

              Thanks Sam, integrated in 2.5, 2.6 and master

              Show
              marina Marina Glancy added a comment - Thanks Sam, integrated in 2.5, 2.6 and master
              Hide
              skodak Petr Skoda added a comment -

              hmm, I get the failures in master only, the 26 and 25 still report 2 scenarios (2 passed) with 2 steps (2 passed). weird

              Show
              skodak Petr Skoda added a comment - hmm, I get the failures in master only, the 26 and 25 still report 2 scenarios (2 passed) with 2 steps (2 passed). weird
              Hide
              marina Marina Glancy added a comment -

              I'm passing the test. The file attached by Sam assumes Clean theme to be used. By default on 2.5 and 2.6 we have Standard theme in behat tests and body element does not have this class attribute. I tested on the following feature and I get 2 passes and 2 failures for each versions. And failures are the ones that are named "should fail".

              @mdl44991
              Feature: Temporary check of attribute test
                In order to test something
                As a developer
                I need to test it
               
                @javascript
                Scenario: Check attribute on home page with JS on - should pass
                  Then the "class" attribute of "body" "css_element" should not contain "xformat-site"
               
                @javascript
                Scenario: Check attribute on home page with JS on - should fail
                  Then the "class" attribute of "body" "css_element" should not contain "format-site"
               
                Scenario: Check attribute on home page with JS off - should pass
                  Then the "class" attribute of "body" "css_element" should not contain "xformat-site"
               
                Scenario: Check attribute on home page with JS off - should fail
                  Then the "class" attribute of "body" "css_element" should not contain "format-site"
              

              Show
              marina Marina Glancy added a comment - I'm passing the test. The file attached by Sam assumes Clean theme to be used. By default on 2.5 and 2.6 we have Standard theme in behat tests and body element does not have this class attribute. I tested on the following feature and I get 2 passes and 2 failures for each versions. And failures are the ones that are named "should fail". @mdl44991 Feature: Temporary check of attribute test In order to test something As a developer I need to test it   @javascript Scenario: Check attribute on home page with JS on - should pass Then the "class" attribute of "body" "css_element" should not contain "xformat-site"   @javascript Scenario: Check attribute on home page with JS on - should fail Then the "class" attribute of "body" "css_element" should not contain "format-site"   Scenario: Check attribute on home page with JS off - should pass Then the "class" attribute of "body" "css_element" should not contain "xformat-site"   Scenario: Check attribute on home page with JS off - should fail Then the "class" attribute of "body" "css_element" should not contain "format-site"
              Hide
              marina Marina Glancy added a comment -

               vendor/bin/behat --config /home/marina/repositories/int_25/behatdata/behat/behat.yml
              Moodle 2.5.5+ (Build: 20140422), pgsql, 391726782e0388af2f00abf9b9924590565b7e85
              Server OS "Linux", Browser: "firefox"
              Started at 24-04-2014, 04:14
              .F.F
               
              (::) failed steps (::)
               
              01. The attribute "class" contains "format-site" (value: "format-site course path-site gecko dir-ltr lang-en yui-skin-sam yui3-skin-sam localhost--int_25 pagelayout-frontpage course-1 context-2 notloggedin  jsenabled")
                  In step `Then the "class" attribute of "body" "css_element" should not contain "format-site"'. # behat_general::the_attribute_of_should_not_contain()
                  From scenario `Check attribute on home page with JS on - should fail'.                         # /home/marina/Downloads/mdl44991.feature:12
                  Of feature `Temporary check of attribute test'.                                                # /home/marina/Downloads/mdl44991.feature
               
              02. The attribute "class" contains "format-site" (value: "format-site course path-site dir-ltr lang-en yui-skin-sam yui3-skin-sam localhost--int_25 pagelayout-frontpage course-1 context-2 notloggedin ")
                  In step `Then the "class" attribute of "body" "css_element" should not contain "format-site"'. # behat_general::the_attribute_of_should_not_contain()
                  From scenario `Check attribute on home page with JS off - should fail'.                        # /home/marina/Downloads/mdl44991.feature:18
                  Of feature `Temporary check of attribute test'.                                                # /home/marina/Downloads/mdl44991.feature
               
              4 scenarios (2 passed, 2 failed)
              4 steps (2 passed, 2 failed)
              0m9.394s
              

              Show
              marina Marina Glancy added a comment - vendor/bin/behat --config /home/marina/repositories/int_25/behatdata/behat/behat.yml Moodle 2.5.5+ (Build: 20140422), pgsql, 391726782e0388af2f00abf9b9924590565b7e85 Server OS "Linux", Browser: "firefox" Started at 24-04-2014, 04:14 .F.F   (::) failed steps (::)   01. The attribute "class" contains "format-site" (value: "format-site course path-site gecko dir-ltr lang-en yui-skin-sam yui3-skin-sam localhost--int_25 pagelayout-frontpage course-1 context-2 notloggedin jsenabled") In step `Then the "class" attribute of "body" "css_element" should not contain "format-site"'. # behat_general::the_attribute_of_should_not_contain() From scenario `Check attribute on home page with JS on - should fail'. # /home/marina/Downloads/mdl44991.feature:12 Of feature `Temporary check of attribute test'. # /home/marina/Downloads/mdl44991.feature   02. The attribute "class" contains "format-site" (value: "format-site course path-site dir-ltr lang-en yui-skin-sam yui3-skin-sam localhost--int_25 pagelayout-frontpage course-1 context-2 notloggedin ") In step `Then the "class" attribute of "body" "css_element" should not contain "format-site"'. # behat_general::the_attribute_of_should_not_contain() From scenario `Check attribute on home page with JS off - should fail'. # /home/marina/Downloads/mdl44991.feature:18 Of feature `Temporary check of attribute test'. # /home/marina/Downloads/mdl44991.feature   4 scenarios (2 passed, 2 failed) 4 steps (2 passed, 2 failed) 0m9.394s
              Hide
              skodak Petr Skoda added a comment -

              thanks Marina for the explanation, marking as tested

              Show
              skodak Petr Skoda added a comment - thanks Marina for the explanation, marking as tested
              Hide
              poltawski Dan Poltawski added a comment -

              Thank you for your contributions reporting, testing, developing, peer reviewing, pinging and helping this issue to get fixed!

              It's now part of Moodle!

              We couldn't have done it without you!

              Show
              poltawski Dan Poltawski added a comment - Thank you for your contributions reporting, testing, developing, peer reviewing, pinging and helping this issue to get fixed! It's now part of Moodle! We couldn't have done it without you!
              Hide
              quen Sam Marshall added a comment -

              sorry for confusing test (again)! thanks all.

              Show
              quen Sam Marshall added a comment - sorry for confusing test (again)! thanks all.

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    12/May/14