{"id":19514859,"url":"https://github.com/ndp/ayudante","last_synced_at":"2026-05-12T21:33:20.884Z","repository":{"id":642437,"uuid":"284375","full_name":"ndp/ayudante","owner":"ndp","description":"Collection of useful test helpers for Ruby/Rails tests","archived":false,"fork":false,"pushed_at":"2010-01-27T06:05:32.000Z","size":128,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-23T13:40:19.507Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ndp.png","metadata":{"files":{"readme":"README.textile","changelog":"History.txt","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-08-21T17:26:28.000Z","updated_at":"2013-10-03T08:03:10.000Z","dependencies_parsed_at":"2022-07-05T05:30:44.473Z","dependency_job_id":null,"html_url":"https://github.com/ndp/ayudante","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndp%2Fayudante","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndp%2Fayudante/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndp%2Fayudante/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndp%2Fayudante/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ndp","download_url":"https://codeload.github.com/ndp/ayudante/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240766676,"owners_count":19854114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T23:37:51.448Z","updated_at":"2026-05-12T21:33:20.850Z","avatar_url":"https://github.com/ndp.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"h1. ayudante\n\n* http://github.com/ndp/ayudante\n* Continuous Integration at http://runcoderun.com/ndp/ayudante\n\nh2. DESCRIPTION:\n\nCollection of useful helpers for writing unit/functional/integration testunit tests.\n\n\nh2. FEATURES/PROBLEMS:\n\nh3. Fixture Helpers\n\nThis uses method_missing to provide additional functions for each of your \nfixtures:\n\nh4. assert_list_of_N\n\nThis asserts that the lists are the same size and have the same items. Any\ndifference is reported.\n\nExample:\n\u003cpre\u003e\u003ccode\u003efixtures :candy_bars\nassert_list_of_candy_bars [:almond_joys, :m_and_ms], CandyBar.find_nutty()\n\u003c/code\u003e\u003c/pre\u003e\n\nh4. assert_set_of_N\n\nThis asserts that the lists are the same size and have the same items, but order \nis ignored.\n\nExample:\n\u003cpre\u003e\u003ccode\u003eassert_set_of_candy_bars [:almond_joys, :m_and_ms], CandyBar.find_nutty()\n\u003c/code\u003e\u003c/pre\u003e\n\nh4. assert_contains_N\n\nThis asserts that all the items are found in the second parameter, but order\nis ignored.\n\nExample:\n\u003cpre\u003e\u003ccode\u003eassert_contains_candy_bars [:almond_joys, :m_and_ms], CandyBar.find_nutty()\n\u003c/code\u003e\u003c/pre\u003e\n\nh3. Pre and Post Condition Checks\n\nh3. assert_changes\n\nWrite:\n\u003cpre\u003e\u003ccode\u003e    assert_changes 'a' do\n        a = 'world'\n    end\n\u003c/code\u003e\u003c/pre\u003e\ninstead of: \n\u003cpre\u003e\u003ccode\u003e    assert a != 'world'\n    a = 'world'\n    assert_equal 'world', a\n\u003c/code\u003e\u003c/pre\u003e\n\nThe string \u003ccode\u003e'a'\u003c/code\u003e passed to assert changes is evaluated in the block context, both before and after the block is run. The first eval is call the *pre-condition*, and the second the *post-condition*.\n\nBe explicit about a state change by specifying both the starting and ending values using an expression pointing to array of before and after values:\n\u003cpre\u003e\u003ccode\u003e    o.answer = 'yes'\n    assert_changes 'o.answer' =\u003e ['yes','no'] do\n      o.answer = 'no'\n    end\n\u003c/code\u003e\u003c/pre\u003e    \n\nWhen given one value, it is considered the post-condition value. \nThe precondition is that the value does NOT equal it:\n\n\u003cpre\u003e\u003ccode\u003e    i = true\n    assert_changes 'i' =\u003e false do   # read as: i changes to false\n      i = false\n    end\n\u003c/code\u003e\u003c/pre\u003e\n\nAssert that several things change by passing an array:\n\n\u003cpre\u003e\u003ccode\u003e    a,b = 'hello','hi'\n    assert_changes ['a','b'] do\n        a = 'world'\n        b = 'earth'\n    end\n\u003c/code\u003e\u003c/pre\u003e\n\nOr use a hash, and pass multiple pre/post conditions of arbitrary complexity:\n\n\u003cpre\u003e\u003ccode\u003e      assert_changes 'post(:a).status' =\u003e [:preview, :published],\n                            'comment(:c).status' =\u003e [:preview, :deleted] do\n        ...\n      end\n\u003c/code\u003e\u003c/pre\u003e    \n\nh3. assert_no_changes\n\nassert_no_changes has an extended parameter possibilities:\n\n\u003cpre\u003e\u003ccode\u003e    i,j = 'hello','hi'\n    assert_no_changes 'i' do ...                # i (before) == i (after)\n    assert_no_changes 'i'=\u003e'hello' do ...       # i == 'hello' before and after\n    assert_no_changes ['i','j'] do ...          # neither i nor j change\n    assert_no_changes 'i'=\u003e'hello','j'=\u003e'hi' do # or be explicit with multiple\n\u003c/code\u003e\u003c/pre\u003e\n\nh3. A Complex Example\n\nProvide multiple assertions of arbitrary complexity, referencing fixtures, etc. \nNote that assert_changes supports the :no_change symbol:\n\n\u003cpre\u003e\u003ccode\u003e    assert_changes\n        'inotech.services.public.include?(categories(:a))' =\u003e [true, :no_change],\n            'inotech.services.public.include?(categories(:b))'=\u003efalse,\n            'inotech.services.public.include?(categories(:c))'=\u003efalse do\n      post :edit_services_dialog, :id=\u003einotech.id, :service_category_id=\u003ecategories(:a).id\n    end\n\u003c/code\u003e\u003c/pre\u003e\n\n\nh2. REQUIREMENTS:\n\n* none\n\nh2. INSTALL:\n\n* Installing the gem: \u003cpre\u003e\u003ccode\u003esudo gem install ndp-ayudante --source=http://gems.github.com\u003c/code\u003e\u003c/pre\u003e\n\n* or in environment.rb\n\u003cpre\u003e\u003ccode\u003e  Rails::Initializer.run do |config|\n    config.gem \"ndp-ayudante\", :source =\u003e \"http://gems.github.com\", :lib=\u003e'ayudante'\n  end\u003c/code\u003e\u003c/pre\u003e\n\nh2. TO COME\n\n* Better error messages on fixture helpers\n* Add assert_includes_N fixture helper\n* Add assert_excludes_N fixture helper\n\nh2. LICENSE:\n\n(The MIT License)\n\nCopyright (c) 2009 Andrew J. Peterson, ndp@mac.com\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndp%2Fayudante","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndp%2Fayudante","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndp%2Fayudante/lists"}