Refactor step definitions into much more logical files
This commit is contained in:
parent
db67a93456
commit
90134e06c9
|
@ -1,6 +1,14 @@
|
|||
#!/usr/bin/env ruby
|
||||
# vim: tabstop=2 expandtab shiftwidth=2
|
||||
When /^I visit the home page$/ do
|
||||
visit "/"
|
||||
end
|
||||
|
||||
When /^I click the "([^"]*)" checkbox$/ do |name|
|
||||
find(:xpath, "//input[@name='#{name}']").set(true)
|
||||
end
|
||||
|
||||
Then /^the page should say "([^"]*)"$/ do |content|
|
||||
page.should have_content(content)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
When /^I configure the job$/ do
|
||||
@job.configure
|
||||
end
|
||||
|
||||
When /^I add a script build step to run "([^"]*)"$/ do |script|
|
||||
@job.add_script_step(script)
|
||||
end
|
||||
|
||||
When /^I tie the job to the "([^"]*)" label$/ do |label|
|
||||
@job.configure do
|
||||
@job.label_expression = label
|
||||
end
|
||||
end
|
||||
|
||||
When /^I tie the job to the slave$/ do
|
||||
step %{I tie the job to the "#{@slave.name}" label}
|
||||
end
|
||||
|
||||
When /^I enable concurrent builds$/ do
|
||||
step %{I click the "_.concurrentBuild" checkbox}
|
||||
end
|
||||
|
||||
When /^I add a string parameter "(.*?)"$/ do |string_param|
|
||||
@job.configure do
|
||||
@job.add_parameter("String Parameter",string_param,string_param)
|
||||
end
|
||||
end
|
||||
When /^I add an Ant build step for:$/ do |ant_xml|
|
||||
@job.configure do
|
||||
@job.add_script_step("cat > build.xml <<EOF
|
||||
#{ant_xml}
|
||||
EOF")
|
||||
@job.add_ant_step('hello', 'build.xml')
|
||||
end
|
||||
end
|
||||
|
||||
When /^I disable the job$/ do
|
||||
@job.configure do
|
||||
@job.disable
|
||||
end
|
||||
end
|
||||
|
|
@ -2,42 +2,26 @@
|
|||
# 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 configure the job$/ do
|
||||
@job.configure
|
||||
end
|
||||
|
||||
When /^I visit the home page$/ do
|
||||
visit "/"
|
||||
end
|
||||
|
||||
When /^I create a job named "([^"]*)"$/ do |name|
|
||||
@job = Jenkins::Job.create_freestyle(@base_url, name)
|
||||
end
|
||||
|
||||
When /^I add a script build step to run "([^"]*)"$/ do |script|
|
||||
@job.add_script_step(script)
|
||||
end
|
||||
|
||||
When /^I run the job$/ do
|
||||
@job.queue_build
|
||||
end
|
||||
|
||||
When /^I click the "([^"]*)" checkbox$/ do |name|
|
||||
find(:xpath, "//input[@name='#{name}']").set(true)
|
||||
end
|
||||
|
||||
When /^I enable concurrent builds$/ do
|
||||
step %{I click the "_.concurrentBuild" checkbox}
|
||||
end
|
||||
|
||||
When /^I save the job$/ do
|
||||
@job.save
|
||||
end
|
||||
|
@ -46,16 +30,6 @@ When /^I visit the job page$/ do
|
|||
@job.open
|
||||
end
|
||||
|
||||
When /^I tie the job to the "([^"]*)" label$/ do |label|
|
||||
@job.configure do
|
||||
@job.label_expression = label
|
||||
end
|
||||
end
|
||||
|
||||
When /^I tie the job to the slave$/ do
|
||||
step %{I tie the job to the "#{@slave.name}" label}
|
||||
end
|
||||
|
||||
When /^I build (\d+) jobs$/ do |count|
|
||||
count.to_i.times do |i|
|
||||
@job.queue_build
|
||||
|
@ -63,16 +37,6 @@ When /^I build (\d+) jobs$/ do |count|
|
|||
sleep 6 # Hard-coded sleep to allow the queue delay in Jenkins to expire
|
||||
end
|
||||
|
||||
When /^I add a string parameter "(.*?)"$/ do |string_param|
|
||||
@job.configure do
|
||||
@job.add_parameter("String Parameter",string_param,string_param)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
############################################################################
|
||||
|
||||
|
||||
Then /^I should see console output matching "([^"]*)"$/ do |script|
|
||||
@job.last_build.console.should match /#{Regexp.escape(script)}/
|
||||
end
|
||||
|
@ -89,25 +53,10 @@ 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
|
||||
|
||||
When /^I add an Ant build step for:$/ do |ant_xml|
|
||||
@job.configure do
|
||||
@job.add_script_step("cat > build.xml <<EOF
|
||||
#{ant_xml}
|
||||
EOF")
|
||||
@job.add_ant_step('hello', 'build.xml')
|
||||
end
|
||||
end
|
||||
|
||||
Then /^the build should succeed$/ do
|
||||
@job.last_build.succeeded?.should be true
|
||||
end
|
||||
|
||||
When /^I disable the job$/ do
|
||||
@job.configure do
|
||||
@job.disable
|
||||
end
|
||||
end
|
||||
|
||||
Then /^it should be disabled$/ do
|
||||
page.should_not have_content 'Build Now'
|
||||
end
|
Loading…
Reference in New Issue