Sha256: 7f56c480b3f9439e23db63719c1b5c22ddac95b1dad667857d7a39fab1478aec

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

shared_examples_for :form_that_shows_errors do
  it "should show errors when validation fails" do
    page.click_button('Submit')
    
    page.should have_error_on 'user_name'
  end
  
  it "should show errors when validation fails in .errors" do
    page.click_button('Submit')
    
    page.should have_rendered_error_on 'user_name'
  end
  
  it "not change when validation succeeds" do
    page.fill_in 'Name', :with => 'whatever'
    page.click_button('Submit')
    
    page.should have_no_error_on 'user_name'
  end
end

describe 'html forms with show_errors', :type => :request, :js => true do
  before(:each) do
    page.visit('/users/new?type=html&ajax=false')
  end
  
  it_behaves_like :form_that_shows_errors
end

describe 'json forms with show_errors', :type => :request, :js => true do
  before(:each) do
    page.visit('/users/new?type=json&ajax=false')
  end
  
  it_behaves_like :form_that_shows_errors
end

describe 'ajax html forms with show_errors', :type => :request, :js => true do
  before(:each) do
    page.visit('/users/new?type=html&ajax=true')
  end
  
  it_behaves_like :form_that_shows_errors
end

describe 'ajax json forms with show_errors', :type => :request, :js => true do
  before(:each) do
    page.visit('/users/new?type=json&ajax=true')
  end
  
  it_behaves_like :form_that_shows_errors
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
edifice-forms-0.5.1 spec/error_handling_spec.rb
edifice-forms-0.5.0 spec/error_handling_spec.rb