Sha256: 2103884b11f246287d9f0bf3f31e03219c8347de337678d55be0ece3577e7012

Contents?: true

Size: 1.7 KB

Versions: 10

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe 'Full Behavior', :js => true do
  include Capybara::DSL

  [:jquery].each do |js_framework|

    url = case js_framework
    when :jquery then '/projects/new'
    end

    context "with #{js_framework}" do
      context 'adding/removing fields' do
        it 'adds fields and increments count' do
          visit url
          click_link 'Add new task'
          all("input[id^='project_tasks_attributes_']", visible: true).count.should eq(1)
          click_link 'Add new task'
          all("input[id^='project_tasks_attributes_']", visible: true).count.should eq(2)
          click_link 'Add new task'
          all("input[id^='project_tasks_attributes_']", visible: true).count.should eq(3)
        end

        it 'removes fields' do
          visit url
          click_link 'Add new task'
          all("input[id^='project_tasks_attributes_']", visible: true).count.should eq(1)
          click_link 'Remove'
          all("input[id^='project_tasks_attributes_']", visible: true).count.should eq(0)
          click_link 'Add new task'
          all("input[id^='project_tasks_attributes_']", visible: true).count.should eq(1)
        end
      end

      context 'after application submission' do
        it 'emits general remove event' do
          visit url
          click_link 'Add new task'
          all("input[id^='project_tasks_attributes_']", visible: true).count.should eq(1)
          click_link 'Remove'
          all("input[id^='project_tasks_attributes_']", visible: true).count.should eq(0)
          click_button 'Submit'
          page.should have_selector(:xpath, "//input[@id='project_tasks_attributes_0__destroy' and @value='1']", visible: false)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
freeform-2.0.4 spec/behavior_spec.rb
freeform-2.0.3 spec/behavior_spec.rb
freeform-2.0.2 spec/behavior_spec.rb
freeform-2.0.1 spec/behavior_spec.rb
freeform-2.0.0 spec/behavior_spec.rb
freeform-1.0.11 spec/behavior_spec.rb
freeform-1.0.9 spec/behavior_spec.rb
freeform-1.0.8 spec/behavior_spec.rb
freeform-1.0.6 spec/behavior_spec.rb
freeform-1.0.5 spec/behavior_spec.rb