Sha256: c77aa5a2e24a7a4edccb8a8ef70c331585c6124099f0bdf2e2071f0d7717c82a

Contents?: true

Size: 1.1 KB

Versions: 37

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

feature 'Contact form' do
  scenario 'submitting the form' do
    submit_contact_form
    expect(page).to have_content('Your message has been sent')
  end

  scenario 'with a missing field' do
    submit_contact_form(:name => '')
    expect(page).to have_content('All fields are required')
  end

  scenario 'with an invalid email' do
    submit_contact_form(:email => 'blah')
    expect(page).to have_content('Invalid email address')
  end

  scenario 'with an invalid captcha' do
    submit_contact_form(:captcha => 'blah')
    expect(page).to have_content('Spam check was incorrect')
  end

  def submit_contact_form(fields={})
    fields.reverse_merge!(
      :name => 'Joe',
      :email => 'joe@example.com',
      :subject => 'Testing',
      :message => 'Hi there',
      :captcha => 'rQ9pC'
    )

    visit '/contact'

    fill_in 'Name', :with => fields[:name]
    fill_in 'Email', :with => fields[:email]
    fill_in 'Subject', :with => fields[:subject]
    fill_in 'Message', :with => fields[:message]
    fill_in 'Spam check', :with => fields[:captcha]

    click_button 'Send'
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
dugway-0.8.1 spec/features/contact_form_spec.rb
dugway-0.8.0 spec/features/contact_form_spec.rb
dugway-0.7.1 spec/features/contact_form_spec.rb
dugway-0.7.0 spec/features/contact_form_spec.rb
dugway-0.6.7 spec/features/contact_form_spec.rb
dugway-0.6.6 spec/features/contact_form_spec.rb
dugway-0.6.5 spec/features/contact_form_spec.rb
dugway-0.6.4 spec/features/contact_form_spec.rb
dugway-0.6.3 spec/features/contact_form_spec.rb
dugway-0.6.2 spec/features/contact_form_spec.rb
dugway-0.6.1 spec/features/contact_form_spec.rb
dugway-0.6.0 spec/features/contact_form_spec.rb
dugway-0.5.9 spec/features/contact_form_spec.rb
dugway-0.5.8 spec/features/contact_form_spec.rb
dugway-0.5.7 spec/features/contact_form_spec.rb
dugway-0.5.6 spec/features/contact_form_spec.rb
dugway-0.5.4 spec/features/contact_form_spec.rb