mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Added shoulda_macros directory support as per http://thoughtbot.lighthouseapp.com/projects/5807/tickets/62
This commit is contained in:
parent
2cb29f5e6d
commit
56a3f432b2
2 changed files with 26 additions and 2 deletions
14
README.rdoc
14
README.rdoc
|
@ -114,10 +114,22 @@ More to come here, but have fun with what's there.
|
|||
assert_contains(['a', '1'], /\d/)
|
||||
assert_contains(['a', '1'], 'a')
|
||||
|
||||
=== 3rd Party and Application Specific Macros
|
||||
|
||||
Any *.rb file under RAILS_ROOT/test/shoulda_macros/ or vendor/(plugins|gems)/gem_name/shoulda_macros/ will be automatically required when you run your tests. This allows you to distribute macros with your plugins, or to organize the macros inside your application. Remember to add your macro to Test::Unit::TestCase in the macro file:
|
||||
|
||||
# test/shoulda_macros/security.rb
|
||||
class Test::Unit::TestCase
|
||||
def self.should_be_denied(opts = {})
|
||||
should_set_the_flash_to(opts[:flash] || /Please log in/i)
|
||||
should_redirect_to(opts[:redirect] || 'login_url')
|
||||
end
|
||||
end
|
||||
|
||||
= Credits
|
||||
|
||||
Shoulda is maintained by {Tammer Saleh}[mailto:tsaleh@thoughtbot.com], and is funded by Thoughtbot[http://www.thoughtbot.com], inc.
|
||||
|
||||
= License
|
||||
|
||||
Shoulda is Copyright © 2006-2007 Tammer Saleh, Thoughtbot. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
||||
Shoulda is Copyright © 2006-2008 Tammer Saleh, Thoughtbot. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
||||
|
|
14
init.rb
14
init.rb
|
@ -1,3 +1,15 @@
|
|||
require 'rubygems'
|
||||
require 'active_support'
|
||||
require 'shoulda'
|
||||
require 'shoulda'
|
||||
|
||||
if defined?(RAILS_ROOT)
|
||||
# load in the 3rd party macros from vendorized plugins and gems
|
||||
Dir[File.join(RAILS_ROOT, "vendor", "{plugin,gem}", "*", "shoulda_macros", "*.rb")].each do |macro_file_path|
|
||||
require macro_file_path
|
||||
end
|
||||
|
||||
# load in the local application specific macros
|
||||
Dir[File.join(RAILS_ROOT, "test", "shoulda_macros", "*.rb")].each do |macro_file_path|
|
||||
require macro_file_path
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue