Sha256: 2285487d540a5b29f9ddc1c02e32f0afbb50a63c1ca12fd1c3c431092dc028da

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'
require 'capybara/rspec'

module Qcourses

  describe CoursesController, :type => :request do
    before(:all) do
      Capybara.app = CoursesController
    end
    let(:app) { CoursesController } 
    let(:url) { '/courses' }

    describe "get trainings" do 

      context "when no repository contigured" do
        it "shows error" do
          get url
          last_response.should be_ok
          last_response.body.should have_selector('p.error')
        end
      end

      context "when repository configured" do
        let!(:courses) { CourseRepository.in_memory }

        it "shows the list of trainings" do
          courses.create_course identification: 'training1', name: 'training 1'
          courses.create_course identification: 'training2', name: 'training 2'
          get url
          last_response.should be_ok
          last_response.body.should have_selector('.courses #course_training1.course .training_name', :text => 'training 1') 
          last_response.body.should have_selector('.courses #course_training2.course .training_name', :text => 'training 2') 
        end

        it "shows no courses available when no courses are available" do
          get url
          last_response.should be_ok
          last_response.body.should have_selector('.courses', :text => 'no courses yet')
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
qcourses-0.1.8 spec/qcourses/controllers/courses_controller_spec.rb
qcourses-0.1.7 spec/qcourses/controllers/courses_controller_spec.rb
qcourses-0.1.6 spec/qcourses/controllers/courses_controller_spec.rb
qcourses-0.1.5 spec/qcourses/controllers/courses_controller_spec.rb
qcourses-0.1.4 spec/qcourses/controllers/courses_controller_spec.rb
qcourses-0.1.3 spec/qcourses/controllers/courses_controller_spec.rb
qcourses-0.1.2 spec/qcourses/controllers/courses_controller_spec.rb