Class: Conformity::SuccessConditions

Inherits:
Object
  • Object
show all
Defined in:
lib/conformity/success_conditions.rb

Instance Method Summary collapse

Constructor Details

#initialize(session = Capybara.current_session) ⇒ SuccessConditions

Returns a new instance of SuccessConditions.



4
5
6
7
# File 'lib/conformity/success_conditions.rb', line 4

def initialize(session = Capybara.current_session)
  @session = session
  @conditions = []
end

Instance Method Details

#has_content?(content) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
# File 'lib/conformity/success_conditions.rb', line 9

def has_content?(content)
  add_condition do
    session.has_content?(content)
  end
end

#has_status_code?(status_code) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/conformity/success_conditions.rb', line 15

def has_status_code?(status_code)
  add_condition do
    session.status_code == status_code
  end
end

#success?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/conformity/success_conditions.rb', line 21

def success?
  conditions.all? { |condition| condition.call() }
end