Skip to content

Commit

Permalink
Merge 784579b into 1cb2aef
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliia-salinko committed Dec 3, 2017
2 parents 1cb2aef + 784579b commit 903628b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions generators/config/templates/capybara.rb
Expand Up @@ -30,6 +30,8 @@
config.javascript_driver = Howitzer.driver.to_s.to_sym
end

Capybara.threadsafe = true

require 'howitzer/capybara_helpers'

# namespace for capybara helpers
Expand Down
19 changes: 19 additions & 0 deletions lib/howitzer/web.rb
@@ -1,6 +1,25 @@
module Howitzer
# This class holds everything related with web GUI
module Web
# Execute the given block within a given session
# @param name [String, Symbol] a session name

def self.within_session(name, &block)
Capybara.using_session(name, &block)
end

# @return [String, nil] a current session name

def self.current_session_name
Capybara.session_name
end

# Set a session to use
# @param value [String, Symbol] a session name

def self.current_session_name=(value)
Capybara.session_name = value
end
end
end
require 'howitzer/web/page_validator'
Expand Down
25 changes: 25 additions & 0 deletions spec/unit/lib/web_spec.rb
@@ -0,0 +1,25 @@
require 'spec_helper'
require 'howitzer/web'

RSpec.describe Howitzer::Web do
context '.within_session' do
it do
expect(Howitzer::Web.current_session_name).to eq(:default)
Howitzer::Web.within_session(:test_session) do
expect(Howitzer::Web.current_session_name).to eq(:test_session)
end
expect(Howitzer::Web.current_session_name).to eq(:default)
end
end

context '.current_session_name' do
it { expect(Howitzer::Web.current_session_name).to eq(:default) }
end

context '.current_session_name=' do
it do
Howitzer::Web.current_session_name = :test_session
expect(Howitzer::Web.current_session_name).to eq(:test_session)
end
end
end

0 comments on commit 903628b

Please sign in to comment.