Top Level Namespace
Defined Under Namespace
Modules: AssertCSS, AssertJavaScript, AssertXPath, Hpricot, Relevate, RubyToken, SM, XML Classes: NilClass, String
Constant Summary collapse
- RAILS_ENV =
ENV.fetch('RAILS_ENV', 'test')
- AFE =
Test::Unit::AssertionFailedError
Instance Method Summary collapse
-
#_bequeath_attributes(node) ⇒ Object
ERGO node.descendant{ @type == ‘text’ and @id == ‘foo’ }.value ERGO node..a_descendant - overload ..
-
#_esc(x) ⇒ Object
:nodoc:.
-
#find_method_contents(file_info, modool, method) ⇒ Object
note: RDoc task fails if transcluder not found.
-
#got_hpricot? ⇒ Boolean
ERGO hpricot gets its own module (REXML-free!).
-
#got_pure_perl? ⇒ Boolean
Detect if your kit is complete, and detect if you have
Javascript::PurePerl
. -
#temporarily(obj, member, new_value) ⇒ Object
:startdoc:.
Instance Method Details
#_bequeath_attributes(node) ⇒ Object
ERGO node.descendant{ @type == ‘text’ and @id == ‘foo’ }.value
ERGO node..a_descendant - overload ..
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/assert_xpath.rb', line 153 def _bequeath_attributes(node) #:nodoc: return node if node.kind_of?(::Hpricot::Elem) or node.kind_of?(::Hpricot::Doc) # ERGO shouldn't this be in a stinkin' module?? # ERGO SIMPLER!! # ERGO document me def node.drill(&block) if block # ERGO harmonize with bang! version # ERGO deal if the key ain't a valid variable unless tribute(block) # ERGO pass in self (node)? sib = self nil while (sib = sib.next_sibling) and sib.node_type != :element q = sib and _bequeath_attributes(sib).drill(&block) return sib if q raise Test::Unit::AssertionFailedError.new("can't find beyond <#{ xpath }>") end end return self # ERGO if block returns false/nil, find siblings until it passes. # throw a test failure if it don't. # ERGO axis concept end return node # ERGO use this return value end |
#_esc(x) ⇒ Object
:nodoc:
742 743 744 |
# File 'lib/assert_xpath.rb', line 742 def _esc(x) #:nodoc: return x.gsub('?', '\?') end |
#find_method_contents(file_info, modool, method) ⇒ Object
note: RDoc task fails if transcluder not found
14 15 16 17 18 19 20 21 22 |
# File 'lib/rdoc_patch.rb', line 14 def find_method_contents(file_info, modool, method) file_info.each do |top| if mod = top.find_module_named(modool) and symbol = mod.find_local_symbol(method) return symbol.token_stream end end return nil end |
#got_hpricot? ⇒ Boolean
ERGO hpricot gets its own module (REXML-free!)
753 754 755 756 757 758 |
# File 'lib/assert_xpath.rb', line 753 def got_hpricot? # ERGO help tests pass without it require 'hpricot' return true rescue MissingSourceFile return false end |
#got_pure_perl? ⇒ Boolean
Detect if your kit is complete, and detect if you have Javascript::PurePerl
. If you don’t, we warn one time. Use this method to defend portable tests that should not break on computers without Javascript::PurePerl
Example:
if RAILS_ENV == 'test' and got_pure_perl?
class AssertJavaScriptTest < Test::Unit::TestCase
# ...
end
end
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
# File 'lib/assert_javascript.rb', line 592 def got_pure_perl? perl_version = `perl -v 2>&1` rescue 'perl, v0' perl_version =~ /perl, v(\d+)/ if $1.to_i < 5 puts "\ninsufficient Perl for assert_js!" unless $already_warned_about_missing_pure_perl $already_warned_about_missing_pure_perl = true return false end unless system('perl -e "use Javascript::PurePerl" 2>/dev/null') puts "\ninstall Javascript::PurePerl for best results!" unless $already_warned_about_missing_pure_perl $already_warned_about_missing_pure_perl = true return false end return true end |
#temporarily(obj, member, new_value) ⇒ Object
:startdoc:
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/assert_javascript.rb', line 18 def temporarily(obj, member, new_value) old_value = obj.send(member) begin obj.send(member.to_s+'=', new_value) # CONSIDER look up the assign thinger? yield ensure obj.send(member.to_s+'=', old_value) end end |