{"issue":{"milestone":null,"title":"Add Regexp support to with_* matchers and improve error messages","created_at":"2011-12-20T23:31:27Z","user":{"login":"jeffmccune","id":8972,"url":"https://api.github.com/users/jeffmccune","gravatar_id":"d2e375016f15692c49ad3aa4c91f6c52","avatar_url":"https://secure.gravatar.com/avatar/d2e375016f15692c49ad3aa4c91f6c52?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"updated_at":"2011-12-29T23:02:22Z","state":"open","labels":[],"id":2619784,"closed_at":null,"html_url":"https://github.com/rodjek/rspec-puppet/issues/17","pull_request":{"patch_url":"https://github.com/rodjek/rspec-puppet/pull/17.patch","html_url":"https://github.com/rodjek/rspec-puppet/pull/17","diff_url":"https://github.com/rodjek/rspec-puppet/pull/17.diff"},"body":"Without this patch it is difficult to match portions of long strings\r\nwhich are attribute values of resource parameters.  For example, the\r\ncontent parameter of a file resource with a multi-line template.\r\n\r\nThis patch makes it easier to match portions of the parameter's value by\r\npassing a Regexp instance to the with_ catch all matcher.\r\n\r\nThe use case looks like:\r\n\r\n    describe 'with lsbmajdistrelease available' do\r\n      let(:facts) { @facter_facts.merge({'lsbmajdistrelease' => '6'}) }\r\n      it { should_not contain_file('puppetenterprise.repo').with_content(missing_content) }\r\n      it { should contain_package 'pe-ruby-devel' }\r\n      it do\r\n        should contain_file('puppetenterprise.repo').with_content(/baseurl=http/)\r\n        should contain_file('puppetenterprise.repo').with_content(/pe_base/)\r\n        should contain_file('puppetenterprise.repo').with_content(/pe_updates/)\r\n        should contain_file('puppetenterprise.repo').with_content(/pe_extras/)\r\n      end\r\n    end\r\n\r\nThis feature allows the same parameter to be matched multiple times using\r\nmultiple different regular expressions.\r\n\r\nThis patch also improves the error message by presenting the actual value in\r\nthe catalog when it does not match the expectation.  This change applies to\r\nboth String and Regexp expectation matches.\r\n\r\nThe error output now looks like:\r\n\r\n    1) pe_devel on redhat el6 os families with lsbmajdistrelease available\r\n       Failure/Error: should contain_file('puppetenterprise.repo').with_content(/JEFF MCCUNE/)\r\n         expected that the catalogue would contain File[puppetenterprise.repo] with content \\\r\n         matching `/JEFF MCCUNE/` but its value of `\"# KERMIT FROG\\n\"` does not\r\n\r\nSpec tests have been added to exercise the handling of Regexp instances.","number":17,"url":"https://api.github.com/repos/rodjek/rspec-puppet/issues/17","comments":6,"assignee":null},"comment":{"created_at":"2011-12-29T23:02:22Z","user":{"login":"bodepd","id":97123,"url":"https://api.github.com/users/bodepd","gravatar_id":"41349aef9be3c1e242cec5df35d45a12","avatar_url":"https://secure.gravatar.com/avatar/41349aef9be3c1e242cec5df35d45a12?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"updated_at":"2011-12-29T23:02:22Z","id":3306254,"body":"Reviewed-By: Dan Bode <dan@puppetlabs.com>","url":"https://api.github.com/repos/rodjek/rspec-puppet/issues/comments/3306254"},"action":"created"}