Module: MuckTestMethods
- Defined in:
- lib/test/muck_test_methods.rb
Instance Method Summary collapse
- #assert_no_xml_tag(xml, conditions) ⇒ Object
-
#assert_xml_tag(xml, conditions) ⇒ Object
Add more helper methods to be used for testing xml.
- #assure_logout ⇒ Object
- #ensure_flash(val) ⇒ Object
- #ensure_flash_contains(val) ⇒ Object
- #login_as(user) ⇒ Object
- #make_parent_params(parent) ⇒ Object
Instance Method Details
#assert_no_xml_tag(xml, conditions) ⇒ Object
36 37 38 39 40 |
# File 'lib/test/muck_test_methods.rb', line 36 def assert_no_xml_tag(xml, conditions) doc = HTML::Document.new(xml) assert !doc.find(conditions), "expected no tag, but found tag matching #{conditions.inspect} in:\n#{xml.inspect}" end |
#assert_xml_tag(xml, conditions) ⇒ Object
Add more helper methods to be used for testing xml
30 31 32 33 34 |
# File 'lib/test/muck_test_methods.rb', line 30 def assert_xml_tag(xml, conditions) doc = HTML::Document.new(xml) assert doc.find(conditions), "expected tag, but no tag found matching #{conditions.inspect} in:\n#{xml.inspect}" end |
#assure_logout ⇒ Object
13 14 15 16 |
# File 'lib/test/muck_test_methods.rb', line 13 def assure_logout user_session = UserSession.find user_session.destroy if user_session end |
#ensure_flash(val) ⇒ Object
18 19 20 |
# File 'lib/test/muck_test_methods.rb', line 18 def ensure_flash(val) assert_contains flash.values, val, ", Flash: #{flash.inspect}" end |
#ensure_flash_contains(val) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/test/muck_test_methods.rb', line 22 def ensure_flash_contains(val) flash.values.each do |flv| return true if flv.include?(val) end false end |
#login_as(user) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/test/muck_test_methods.rb', line 3 def login_as(user) success = UserSession.create(user) if !success errors = user.errors..to_sentence = 'User has not been activated' if !user.active? raise "could not login as #{user.to_param}. Please make sure the user is valid. #{} #{errors}" end UserSession.find end |
#make_parent_params(parent) ⇒ Object
42 43 44 |
# File 'lib/test/muck_test_methods.rb', line 42 def make_parent_params(parent) { :parent_id => parent.id, :parent_type => parent.class.to_s } end |