Module: Capybara::Bamboo::Client

Extended by:
BambooHelper, DSL, RSpec::Matchers
Defined in:
lib/capybara-bamboo-client.rb,
lib/capybara-bamboo-client/plan.rb,
lib/capybara-bamboo-client/version.rb,
lib/capybara-bamboo-client/bamboo_helper.rb

Defined Under Namespace

Modules: BambooHelper Classes: Plan

Constant Summary collapse

VERSION =
"0.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from BambooHelper

app_host_from_url, get_plan_key, included, register_driver

Class Attribute Details

.app_hostObject

Returns the value of attribute app_host.



15
16
17
# File 'lib/capybara-bamboo-client.rb', line 15

def app_host
  @app_host
end

.bamboo_urlObject

Returns the value of attribute bamboo_url.



15
16
17
# File 'lib/capybara-bamboo-client.rb', line 15

def bamboo_url
  @bamboo_url
end

.capybara_timeoutObject

Returns the value of attribute capybara_timeout.



15
16
17
# File 'lib/capybara-bamboo-client.rb', line 15

def capybara_timeout
  @capybara_timeout
end

.passwordObject

Returns the value of attribute password.



15
16
17
# File 'lib/capybara-bamboo-client.rb', line 15

def password
  @password
end

.phantomjs_pathObject

Returns the value of attribute phantomjs_path.



15
16
17
# File 'lib/capybara-bamboo-client.rb', line 15

def phantomjs_path
  @phantomjs_path
end

.plansObject

Returns the value of attribute plans.



15
16
17
# File 'lib/capybara-bamboo-client.rb', line 15

def plans
  @plans
end

.usernameObject

Returns the value of attribute username.



15
16
17
# File 'lib/capybara-bamboo-client.rb', line 15

def username
  @username
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
21
22
23
24
25
# File 'lib/capybara-bamboo-client.rb', line 17

def configure
  yield self
  @capybara_timeout ||= 60
  @phantomjs_path ||= File.expand_path('../../drivers/phantomjs.exe', __FILE__)
  @plans = []
  @app_host ||= app_host_from_url(bamboo_url)
  register_driver capybara_timeout, phantomjs_path, app_host
  self
end

.construct_plansObject



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/capybara-bamboo-client.rb', line 43

def construct_plans
  find('table[id="dashboard"]').all('tbody tr').each do |tr|
    tds = tr.all('td')
    plan_name_link = tds.first.find('a')
    plan_key = get_plan_key(plan_name_link[:id])
    operation_links = tds.last.all('a')
    @plans << Plan.new({app_host: app_host, name: plan_name_link.text, key: plan_key,
                        url: plan_name_link[:href],
                        build_action_url: operation_links.first[:href],
                        edit_plan_url: operation_links[1][:href],
                        favourite_plan_url: operation_links.last[:href]}).tap{|i| p i.inspect}
  end
end

.loginObject



27
28
29
30
31
32
33
34
35
# File 'lib/capybara-bamboo-client.rb', line 27

def 
  visit bamboo_url
  expect(page.all('createPlanLink').any?).to be false
  click_link 'login'
  fill_in 'loginForm_os_username', with: username || ENV[:BAMBOO_USERNAME]
  fill_in 'loginForm_os_password', with: password || ENV[:BAMBOO_PASSWORD]
  find('#loginForm_save').click
  expect(page).to have_button('createPlanLink')
end

.logoutObject



37
38
39
40
41
# File 'lib/capybara-bamboo-client.rb', line 37

def logout
  reset_session!
  visit bamboo_url
  expect(page).to have_link('login')
end