/
job_steps.rb
68 lines (51 loc) · 1.53 KB
/
job_steps.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env ruby
# vim: tabstop=2 expandtab shiftwidth=2
Given /^a simple job$/ do
@job = Jenkins::Job.create_freestyle(@base_url, Jenkins::Job.random_name)
@job.configure do
@job.add_script_step("ls")
end
end
Given /^a job$/ do
@job = Jenkins::Job.create_freestyle(@base_url, Jenkins::Job.random_name)
end
When /^I create a job named "([^"]*)"$/ do |name|
@job = Jenkins::Job.create_freestyle(@base_url, name)
end
When /^I run the job$/ do
@job.queue_build
end
When /^I save the job$/ do
@job.save
end
When /^I visit the job page$/ do
@job.open
end
When /^I build (\d+) jobs$/ do |count|
count.to_i.times do |i|
@job.queue_build
end
sleep 6 # Hard-coded sleep to allow the queue delay in Jenkins to expire
end
Then /^I should see console output matching "([^"]*)"$/ do |script|
@job.last_build.console.should match /#{Regexp.escape(script)}/
end
Then /^the (\d+) jobs should run concurrently$/ do |count|
count.to_i.times do |i|
# Build numbers start at 1
@job.build(i + 1).in_progress?.should be true
end
end
Then /^I should be prompted to enter the "(.*?)" parameter$/ do |param_name|
find(:xpath, "//input[@value='#{param_name}']").instance_of?(Capybara::Node::Element).should be true
end
Then /^the build should succeed$/ do
@job.last_build.succeeded?.should be true
end
Then /^it should be disabled$/ do
page.should_not have_content 'Build Now'
end
Then /^it should have an "(.*?)" button on the job page$/ do |button|
@job.open
page.should have_xpath("//button[text()='Enable']")
end