spec/unit/lib/web/element_dsl_spec.rb in howitzer-2.1.1 vs spec/unit/lib/web/element_dsl_spec.rb in howitzer-2.2.0
- old
+ new
@@ -4,18 +4,27 @@
RSpec.describe Howitzer::Web::ElementDsl do
let(:klass) do
Class.new do
include Howitzer::Web::ElementDsl
def capybara_scopes
- @_scopes ||= [Capybara.current_session]
+ @capybara_scopes ||= Hash.new { |hash, key| hash[key] = [Capybara.current_session] }
+ @capybara_scopes[Howitzer.session_name]
end
end
end
let(:klass_object) { klass.new }
it 'returns correct capybara context' do
allow(Capybara).to receive(:current_session) { 'session' }
expect(klass_object.capybara_context).to eq('session')
+ end
+
+ it 'returns another capybara context' do
+ allow(Capybara).to receive(:current_session) { 'session' }
+ expect(klass_object.capybara_context).to eq('session')
+ Howitzer.session_name = 'session2'
+ allow(Capybara).to receive(:current_session) { 'session2' }
+ expect(klass_object.capybara_context).to eq('session2')
end
include_examples :element_dsl
include_examples :capybara_context_holder
end