diff --git a/spec/features/conference_spec.rb b/spec/features/conference_spec.rb index b5c6fd52..4e28f449 100644 --- a/spec/features/conference_spec.rb +++ b/spec/features/conference_spec.rb @@ -24,7 +24,7 @@ feature Conference do click_button 'Create Conference' - expect(page.find('#flash_notice').text). + expect(flash). to eq('Conference was successfully created.') expect(Conference.count).to eq(expected_count) end @@ -40,7 +40,7 @@ feature Conference do fill_in 'conference_social_tag', with: 'NewCon' click_button 'Update Conference' - expect(page.find('#flash_notice').text). + expect(flash). to eq('Conference was successfully updated.') conference.reload @@ -70,7 +70,7 @@ feature Conference do click_button 'Update Venue' - expect(page.find('#flash_notice').text). + expect(flash). to eq('Venue was successfully updated.') venue = Conference.find(conference.id).venue @@ -90,7 +90,7 @@ feature Conference do 'sed diam voluptua. new' click_button 'Update Venue' - expect(page.find('#flash_notice').text). + expect(flash). to eq('Venue was successfully updated.') venue.reload diff --git a/spec/features/proposal_spec.rb b/spec/features/proposal_spec.rb index 950dd2c4..c8176a4c 100644 --- a/spec/features/proposal_spec.rb +++ b/spec/features/proposal_spec.rb @@ -48,7 +48,7 @@ feature Event do click_button 'Update' - expect(page.find('#flash_notice').text). + expect(flash). to eq('You updated your account successfully.') expect(Event.count).to eq(expected_count) @@ -78,12 +78,12 @@ feature Event do expect(page.has_content?('Example Proposal')).to be true expect(page.has_content?('Accepted (confirmation pending)')).to be true click_link "confirm_proposal_#{event.id}" - expect(page.find('#flash_notice').text). + expect(flash). to eq('Event was confirmed. Please register to attend the conference.') find('#register').click - expect(page.find('#flash_notice').text). + expect(flash). to eq('You are now registered.') end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 257c19d8..acfed143 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -50,6 +50,9 @@ RSpec.configure do |config| # Includes support/login_macros for feature tests config.include LoginMacros, type: :feature + # Includes support/flash for feature tests + config.include Flash, type: :feature + # As we start from scratch in April 2014, let's forbid the old :should syntax config.expect_with :rspec do |c| c.syntax = :expect diff --git a/spec/support/flash.rb b/spec/support/flash.rb new file mode 100644 index 00000000..e999decc --- /dev/null +++ b/spec/support/flash.rb @@ -0,0 +1,13 @@ +module Flash + def flash + results = all(:css, 'div#flash p') + if results.empty? + return 'none' + end + if results.count > 1 + texts = results.map { |r| r.text } + fail "One flash expected, but we had #{texts.inspect}" + end + results.first.text + end +end