
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
h1. ayudante
h2. DESCRIPTION:
Collection of useful helpers for unit/functional/integration tests.
h2. FEATURES/PROBLEMS:
h3. Fixture Helpers
This uses method_missing to provide additional functions for each of your fixtures:
h4. assert_list_of_N
This asserts that the lists are the same size and have the same items. Any difference is reported.
Example:
fixtures :candy_bars
assert_list_of_candy_bars [:almond_joys, :m_and_ms], CandyBar.find_nutty()
h4. assert_set_of_N
This asserts that the lists are the same size and have the same items, but order is ignored.
Example:
assert_set_of_candy_bars [:almond_joys, :m_and_ms], CandyBar.find_nutty()
h3. Pre and Post Condition Checks
h3. assert_changes
Write:
assert_changes 'a' do
a = 'world'
end
instead of:
assert a != 'world'
a = 'world'
assert_equal 'world', a
The string 'a' 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.
Be explicit about a state change by specifying both the starting and ending values using an expression pointing to array of before and after values:
o.answer = 'yes'
assert_changes 'o.answer' => ['yes','no'] do
o.answer = 'no'
end
When given one value, it is considered the post-condition value. The precondition is that the value does NOT equal it:
i = true
assert_changes 'i' => false do # read as: i changes to false
i = false
end
Assert that several things change by passing an array:
a,b = 'hello','hi'
assert_changes ['a','b'] do
a = 'world'
b = 'earth'
end
Or use a hash, and pass multiple pre/post conditions of arbitrary complexity:
assert_changes 'post(:a).status' => [:preview, :published],
'comment(:c).status' => [:preview, :deleted] do
...
end
h3. assert_no_changes
assert_no_changes has an extended parameter possibilities:
i,j = 'hello','hi'
assert_no_changes 'i' do ... # i (before) == i (after)
assert_no_changes 'i'=>'hello' do ... # i == 'hello' before and after
assert_no_changes ['i','j'] do ... # neither i nor j change
assert_no_changes 'i'=>'hello','j'=>'hi' do # or be explicit with multiple
h3. A Complex Example
Provide multiple assertions of arbitrary complexity, referencing fixtures, etc. Note that assert_changes supports the :no_change symbol:
assert_changes
'inotech.services.public.include?(categories(:a))' => [true, :no_change],
'inotech.services.public.include?(categories(:b))'=>false,
'inotech.services.public.include?(categories(:c))'=>false do
post :edit_services_dialog, :id=>inotech.id, :service_category_id=>categories(:a).id
end
h2. REQUIREMENTS:
h2. INSTALL:
Installing the gem:
sudo gem install ndp-ayudante --source=http://gems.github.com
or in environment.rb
Rails::Initializer.run do |config|
config.gem "ndp-ayudante", :source => "http://gems.github.com", :lib=>'ayudante'
end
h2. TO COME
h2. LICENSE:
(The MIT License)
Copyright (c) 2009 Andrew J. Peterson, ndp@mac.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Unknown package
We found that ndp-ayudante demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.