From 5266ea26bb53ef78ae51359fb273fb607427590c Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 8 May 2014 14:03:10 +0200 Subject: [PATCH] Don't use let for find expressions --- .../support/toggable_fieldsets.rb | 20 +++++++++---------- .../work_packages/work_package_query_spec.rb | 9 ++++----- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/spec/features/accessibility/support/toggable_fieldsets.rb b/spec/features/accessibility/support/toggable_fieldsets.rb index e90dffe793..636af1aadc 100644 --- a/spec/features/accessibility/support/toggable_fieldsets.rb +++ b/spec/features/accessibility/support/toggable_fieldsets.rb @@ -30,15 +30,13 @@ require 'spec_helper' require 'features/work_packages/work_packages_page' shared_context 'find legend with text' do - let(:legend_text) { find('legend a span', text: fieldset_name) } - let(:fieldset) { legend_text.find(:xpath, '../../..') } + let(:fieldset) { } end shared_context 'find toggle label' do - let(:link) { legend_text.find(:xpath, '..') } - let(:toggle_state_label) { link.find("span.hidden-for-sighted", visible: false) } + let(:link) { find('legend a span', text: fieldset_name).find(:xpath, '..') } - it { expect(toggle_state_label).not_to be_nil } + it { expect(link.find("span.hidden-for-sighted", visible: false)).not_to be_nil } end shared_context 'Toggable fieldset examples' do @@ -53,7 +51,7 @@ shared_context 'Toggable fieldset examples' do describe 'after click' do include_context 'find legend with text' - before { legend_text.click } + before { find('legend a span', text: fieldset_name).click } it_behaves_like 'expanded fieldset' end @@ -70,7 +68,7 @@ shared_context 'Toggable fieldset examples' do describe 'after click' do include_context 'find legend with text' - before { legend_text.click } + before { find('legend a span', text: fieldset_name).click } it_behaves_like 'collapsed fieldset' end @@ -80,14 +78,14 @@ shared_context 'Toggable fieldset examples' do include_context 'find legend with text' include_context 'find toggle label' - it { expect(toggle_state_label.text(:all)).to include(I18n.t('js.label_collapsed')) } + it { expect(link.find("span.hidden-for-sighted", visible: false).text(:all)).to include(I18n.t('js.label_collapsed')) } end shared_examples_for 'toggle state set expanded' do include_context 'find legend with text' include_context 'find toggle label' - it { expect(toggle_state_label.text(:all)).to include(I18n.t('js.label_expanded')) } + it { expect(link.find("span.hidden-for-sighted", visible: false).text(:all)).to include(I18n.t('js.label_expanded')) } end shared_context 'collapsed CSS' do @@ -98,13 +96,13 @@ shared_context 'Toggable fieldset examples' do include_context 'collapsed CSS' include_context 'find legend with text' - it { expect(fieldset[:class]).to include(collapsed_class_name) } + it { expect(find('legend a span', text: fieldset_name).find(:xpath, '../../..')[:class]).to include(collapsed_class_name) } end shared_examples_for 'expanded fieldset' do include_context 'collapsed CSS' include_context 'find legend with text' - it { expect(fieldset[:class]).not_to include(collapsed_class_name) } + it { expect(find('legend a span', text: fieldset_name).find(:xpath, '../../..')[:class]).not_to include(collapsed_class_name) } end end diff --git a/spec/features/accessibility/work_packages/work_package_query_spec.rb b/spec/features/accessibility/work_packages/work_package_query_spec.rb index 5965768aa3..8568b6216d 100644 --- a/spec/features/accessibility/work_packages/work_package_query_spec.rb +++ b/spec/features/accessibility/work_packages/work_package_query_spec.rb @@ -43,15 +43,14 @@ describe 'Work package index accessibility' do end describe 'Select all link' do - let(:select_all_link) { find('table.list.issues th.checkbox a') } - let(:description_for_blind) { select_all_link.find(:xpath, 'span/span[@class="hidden-for-sighted"]') } + #let(:description_for_blind) { find('table.list.issues th.checkbox a').find(:xpath, 'span/span[@class="hidden-for-sighted"]') } describe 'Initial state', js: true do - it { expect(select_all_link).not_to be_nil } + it { expect(find('table.list.issues th.checkbox a')).not_to be_nil } - it { expect(select_all_link[:title]).to eq(I18n.t(:button_check_all)) } + it { expect(find('table.list.issues th.checkbox a')[:title]).to eq(I18n.t(:button_check_all)) } - it { expect(select_all_link[:alt]).to eq(I18n.t(:button_check_all)) } + it { expect(find('table.list.issues th.checkbox a')[:alt]).to eq(I18n.t(:button_check_all)) } # TODO: This test is failing because of what seems to be a bug in selenium. # The hidden-for-sighted elements cannot be found using because they are styled with