Sha256: 1b743570e2b3bb6eeba3308cb0d791dc07c6e1471c29c788b97dedd0bfa0adf2

Contents?: true

Size: 972 Bytes

Versions: 6

Compression:

Stored size: 972 Bytes

Contents

require 'spec_helper'

describe 'NestedForm' do
  include Capybara::DSL
  
  def check_form
    page.should have_no_css('form .fields input[id$=name]')
    click_link 'Add new task'
    page.should have_css('form .fields input[id$=name]', :count => 1)
    find('form .fields input[id$=name]').should be_visible
    find('form .fields input[id$=_destroy]').value.should == 'false'
    
    click_link 'Remove'
    find('form .fields input[id$=_destroy]').value.should == '1'
    find('form .fields input[id$=name]').should_not be_visible
    
    click_link 'Add new task'
    click_link 'Add new task'
    fields = all('form .fields')
    fields.select { |field| field.visible? }.count.should == 2
    fields.reject { |field| field.visible? }.count.should == 1
  end
  
  it 'should work with jQuery and Prototype', :js => true do
    visit '/projects/new'
    check_form
    
    visit '/projects/new?type=prototype'
    check_form
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bbenezech-nested_form-0.0.6 spec/form_spec.rb
bbenezech-nested_form-0.0.5 spec/form_spec.rb
bbenezech-nested_form-0.0.4 spec/form_spec.rb
bbenezech-nested_form-0.0.3 spec/form_spec.rb
bbenezech-nested_form-0.0.2 spec/form_spec.rb
bbenezech-nested_form-0.0.1 spec/form_spec.rb