From c07b691b8fcee14c0bd3bc854a87f752acce8f64 Mon Sep 17 00:00:00 2001 From: cblanc Date: Tue, 5 May 2015 22:51:26 +0100 Subject: [PATCH] Updated test for expected ban behaviour --- spec/features/shoutbox/shoutbox_spec.rb | 35 +++++++++++-------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/spec/features/shoutbox/shoutbox_spec.rb b/spec/features/shoutbox/shoutbox_spec.rb index 30d75ac..dec6542 100644 --- a/spec/features/shoutbox/shoutbox_spec.rb +++ b/spec/features/shoutbox/shoutbox_spec.rb @@ -1,26 +1,23 @@ require 'spec_helper' -feature 'Shoutbox' do +feature 'Shoutbox', js: true do + let!(:user) { create :user } + background do - @user = create :user - sign_in_as @user - visit root_path + sign_in_as user end - feature 'user creates a shout', js: true do - scenario 'shouting with valid content' do - shout = rand(100000).to_s - fill_in 'shoutbox_text', with: shout - click_button 'Shout!' - expect(page).to have_content(shout) - end + scenario 'creating a valid shout' do + visit root_path + shout = rand(100000).to_s + fill_in 'shoutbox_text', with: shout + click_button 'Shout!' + expect(page).to have_content(shout) + end - scenario 'unable to while banned' do - @user.bans.create! ban_type: Ban::TYPE_MUTE, expiry: Time.now + 10.days - shout = rand(100000).to_s - fill_in 'shoutbox_text', with: shout - click_button 'Shout!' - expect(page).to_not have_content(shout) - end - end + scenario 'creating shout while banned' do + Ban.create! ban_type: Ban::TYPE_MUTE, expiry: Time.now + 10.days, user_name: user.username + visit root_path + expect(find("#sidebar")).to have_content "You have been muted." + end end \ No newline at end of file