Class: CheckIn::Input

Inherits:
Object
  • Object
show all
Includes:
RSpec::Expectations, RSpec::Matchers
Defined in:
lib/cucumber/pickles/steps/check_in/input.rb

Instance Method Summary collapse

Constructor Details

#initialize(label, value, within) ⇒ Input

Returns a new instance of Input.



6
7
8
9
10
# File 'lib/cucumber/pickles/steps/check_in/input.rb', line 6

def initialize(label, value, within)
  @label = label
  @value = value
  @within = within || Capybara.current_session
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cucumber/pickles/steps/check_in/input.rb', line 12

def call
  case input.native.attribute("type")

  when "text"
    expect(input.value).to eq @value
  when "radio", "checkbox"
    case @value

    when "true", true
      expect(input).to be_selected
    when "false", false, nil
      expect(input).not_to be_selected
    end
  when "file"
    expect(page).to have_selector("[src$='#{@value}']")
  end
end