Class: BeValidAsset::BeValidCss

Inherits:
BeValidBase show all
Defined in:
lib/be_valid_asset/be_valid_css.rb

Instance Method Summary collapse

Constructor Details

#initialize(profile) ⇒ BeValidCss

Returns a new instance of BeValidCss.



10
11
12
# File 'lib/be_valid_asset/be_valid_css.rb', line 10

def initialize(profile)
  @profile = profile
end

Instance Method Details

#descriptionObject



27
28
29
# File 'lib/be_valid_asset/be_valid_css.rb', line 27

def description
  "be valid css"
end

#failure_messageObject



31
32
33
# File 'lib/be_valid_asset/be_valid_css.rb', line 31

def failure_message
  " expected css to be valid, but validation produced these errors:\n#{@message}"
end

#failure_message_when_negatedObject Also known as: negative_failure_message



35
36
37
# File 'lib/be_valid_asset/be_valid_css.rb', line 35

def failure_message_when_negated
  " expected to not be valid, but was (missing validation?)"
end

#matches?(fragment) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/be_valid_asset/be_valid_css.rb', line 14

def matches?(fragment)

  if fragment.respond_to? :body
    fragment = fragment.body.to_s
  end

  # The validator return a 500 Error if it's sent empty string
  fragment = ' ' if fragment.empty?

  query_params = { :text => fragment, :profile => @profile, :vextwarning => 'true' }
  return validate(query_params)
end