Skip to content

Commit

Permalink
Add view test for header
Browse files Browse the repository at this point in the history
  • Loading branch information
riggraz committed Aug 28, 2019
1 parent 0c1873d commit bdc3c32
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions spec/views/header_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'rails_helper'

RSpec.describe 'header', type: :view do
let(:board1) { FactoryBot.create(:board) }
let(:board2) { FactoryBot.create(:board) }

def render_header
render partial: 'layouts/header'
end

it 'renders a logo' do
render_header

expect(rendered).to have_selector('.navbar-brand')
end

it 'renders a link for each board' do
@boards = [board1, board2]

render_header

expect(rendered).to have_content(board1.name)
expect(rendered).to have_content(board2.name)
end

it 'applies "active" class to the active board link' do
@boards = [board1, board2]
@board = board1 # active board is board1

render_header

expect(rendered).to have_selector('.active', count: 1)
end
end

0 comments on commit bdc3c32

Please sign in to comment.