require File.expand_path(File.dirname(__FILE__) + '../../spec_helper') describe "Runner" do let(:user_api) { Octokit::Client.new( login: ENV['LOGIN'], access_token: ENV['ACCESS_TOKEN'] ) } let(:file){ f = File.expand_path(File.dirname(__FILE__) + '/../fixtures/.travis.yml') Travis::Yaml.parse( File.open(f).read ) } let(:github_user){ Warden::GitHub::User.new } before(:each) do perkins_app Perkins::Repo.delete_all allow_any_instance_of(Warden::GitHub::User).to receive(:api).and_return(user_api) @user = Warden::GitHub::User.new Perkins::Repo.sync_github_repos(@user) to_add = Perkins::Repo.synced_records.where(name: "michelson/BigBroda").first Perkins::Repo.add_from_github(to_add.gb_id) end context "in repo" do let( :repo ){ Perkins::Repo.first } before :each do #expect(repo.load_git).to be_instance_of(Git::Base) @runner = Perkins::Runner.new @runner.config = file @runner.repo = repo #allow_any_instance_of(Perkins::Repo).to receive(:clone_or_load).and_return(true) #allow_any_instance_of(Perkins::Repo).to receive(:git).and_return(Git::Base.new) end it "runner should raise error in case it fails" do expect{@runner.run!}.to raise_error end it "should install bundler" do #allow_any_instance_of(Git::Base).to receive(:chdir).and_return(true) expect{@runner.run("master")}.to_not raise_error #expect(Git::Base).to have_received(:chdir) expect(@runner.duration).to be > 0 expect(@runner).to_not be_running end end context "a go repo" do let( :repo ){ Perkins::Repo.find_by(name: "michelson/godard") } before :each do repo.clone_or_load @runner = repo.runner end it "should install bundler" do expect{@runner.run("master")}.to_not raise_error expect(@runner.duration).to be > 0 expect(@runner).to_not be_running end end end