require 'spec_helper'

describe 'Create school' do

  it 'should faild witn invalid values' do
    admin = create :admin
    login_as_user admin
    visit admin_path
    click_link 'admin_schools_link'
    click_link 'create_school'
    click_button 'create_school_button'
    page.should have_content "can't be blank"

  end

  it 'should create school with valid values' do
    admin = create :admin
    login_as_user admin
    visit admin_path
    click_link 'admin_schools_link'
    click_link 'create_school'

    fill_in 'school_name', with: 'New School'
    fill_in 'school_description', with: 'description'
    fill_in 'school_address', with: 'Firefield Street'
    click_button 'create_school_button'

    school = School.last
    school.name.should eq 'New School'
    school.address.should eq "Firefield Street"

    current_path.should eq admin_school_path school
  end
end
