require 'spec_helper' module TeamcityRuby describe BuildConfiguration do before do delete_all_projects delete_all_vcs_roots @project = Project.create("Sample Project") end it "lists all build configurations", :vcr do build_configuration_names = ["Build Configuration 1", "Build Configuration 2"] build_configuration_names.each do |b| build_configuration = BuildConfiguration.create(b, :project_id => @project.teamcity_id) end BuildConfiguration.all.map(&:name).should == build_configuration_names end it "fetches a specific build configuration by id", :vcr do build_configuration = BuildConfiguration.create("Sample Build Configuration", :project_id => @project.teamcity_id) BuildConfiguration.find(:id => build_configuration.teamcity_id).should == build_configuration end context "a existing build configuration" do let(:build_configuration) { BuildConfiguration.create("Sample Build Configuration", :project_id => @project.teamcity_id) } it "can get a vcs root attached with specific checkout rules", :vcr do vcs_root = VcsRoot.create(:name => "Sample VCS Root") checkout_rules = "+:trunk => ." build_configuration.attach_vcs_root(vcs_root.teamcity_id, checkout_rules) build_configuration.vcs_root_entries.should == [{ :vcs_root_id => vcs_root.teamcity_id, :checkout_rules => checkout_rules }] end it "can get a build step added to it", :vcr do build_configuration.add_step(:name => "Sample Step", :type => "Maven") do |s| s['goals'] = 'verify' end created_build_step = build_configuration.steps.find { |s| s.name == 'Sample Step' } created_build_step.type.should == 'Maven' created_build_step.properties.should include({"goals" => "verify"}) end it "can get a build trigger added to it", :vcr do build_configuration.add_trigger(:type => "vcsTrigger") do |t| t["perCheckinTriggering"] = "true" end created_build_trigger = build_configuration.triggers.find { |s| s.type == 'vcsTrigger' } created_build_trigger.properties.should include({"perCheckinTriggering" => "true"}) end end end end