Module: AssertCSS
- Defined in:
- lib/assert_css.rb
Instance Method Summary collapse
- #_find_css_style(selector, rule) ⇒ Object
- #assert_css(block) ⇒ Object
- #assert_css_public_folder(root) ⇒ Object
- #assert_css_selector(selector) ⇒ Object
- #assert_css_style(selector, rule) ⇒ Object
- #assert_style(path = :style) ⇒ Object
Instance Method Details
#_find_css_style(selector, rule) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/assert_css.rb', line 21 def _find_css_style(selector, rule) @_cp.each_rule_set do |rule_set| if rule_set.selectors.include?(selector) and value = rule_set.get_value(rule) return value.sub(/;$/, '') end end return nil end |
#assert_css(block) ⇒ Object
8 9 10 11 |
# File 'lib/assert_css.rb', line 8 def assert_css(block) @_cp ||= CssParser::Parser.new @_cp.add_block!(block) end |
#assert_css_public_folder(root) ⇒ Object
31 32 33 |
# File 'lib/assert_css.rb', line 31 def assert_css_public_folder(root) @_public_folder = root end |
#assert_css_selector(selector) ⇒ Object
15 16 17 18 19 |
# File 'lib/assert_css.rb', line 15 def assert_css_selector(selector) raise 'selector must be a string' unless selector.kind_of? String # ERGO why no return me a RuleSet?? return @_cp.find_by_selector(selector) end |
#assert_css_style(selector, rule) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/assert_css.rb', line 35 def assert_css_style(selector, rule) if selector.respond_to? :delete_attribute #p selector.name return _find_css_style(selector.name, rule) else _find_css_style(selector, rule) or flunk "#{selector}{#{rule}} not found" end end |
#assert_style(path = :style) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/assert_css.rb', line 45 def assert_style(path = :style) assert_any_xpath path do |style| assert_css style.text false end end |