Skip to content

Commit

Permalink
adding the install stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
tansaku committed Jun 26, 2014
1 parent 3dd5422 commit 47d826d
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
23 changes: 23 additions & 0 deletions install/install.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Feature: Installation of dependencies
In order to check that the supplied homework can be graded by AutoGrader
As an AutoGrader deployer
I need to check the installation

Scenario: Install gems
Given that I am in the project root directory "ruby-intro"
When I install gems
Then I should see that there are no errors

Scenario: Install or check AutoGraders
Given that I am in the project root directory "ruby-intro"
When I install or check "saasbook/rag" as "rag"
And I change to branch "develop"
And I install the AutoGrader gems
And I run cucumber for AutoGrader
Then I should see that there are no errors

Scenario: Verify correct version of AutoGraders
Given I go to the AutoGrader directory "rag"
And it has an origin of "saasbook/rag"
When I fetch the latest on origin branch "develop"
Then I should see no difference
79 changes: 79 additions & 0 deletions install/install_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
require 'open3'

def run_in_dir(arg_string, dir=@dir)
run_process(arg_string, dir, false)
end

def run_process(cli_string, dir='.', gemfile=false)
if gemfile
@test_output, @test_errors, @test_status = Open3.capture3(
{ 'BUNDLE_GEMFILE' => 'Gemfile' }, cli_string, :chdir => dir
)
else
@test_output, @test_errors, @test_status = Open3.capture3(
cli_string, :chdir => dir
)
end
raise ( @test_output + @test_errors + @test_status.to_s ) unless @test_status.success?
end

Given /^that I am in the project root directory "(.*?)"$/ do |project_dir|
@project_dir = project_dir
expect(File.basename(Dir.getwd)).to eq @project_dir
end

Given(/^I go to the AutoGrader directory "(.*?)"$/) do |rag|
@dir = rag
end

Given(/^it has an origin of "(.*?)"$/) do |origin|
run_in_dir("git remote -v")
origin = "https://github.com/#{origin}".gsub('.git', '')
@test_output = @test_output.gsub('.git', '')
expect(@test_output).to match(/origin\t#{origin} \(fetch\)/)
end

When(/^I install gems$/) do
@dir = Dir.getwd
run_process 'bundle install', '.', true
end

When(/^I install or check "(.*)" as "(.*)"$/) do |repo, dir|
if ! Dir.exists?(dir)
puts "Clone AutoGraders as '#{dir}'"
run_process("git clone https://github.com/#{repo} #{dir}" )
else
puts "Existing '#{dir}'. Skip clone, fetch instead."
run_in_dir("git fetch origin", dir )
end
@dir = dir if Dir.exists?(dir)
steps %Q{Given it has an origin of "#{repo}"}
end

When(/^I fetch the latest on origin branch "(.*?)"$/) do |branch|
@branch = branch
run_in_dir("git fetch origin #{@branch}")
end

When(/^I change to branch "(.*?)"$/) do |branch|
run_in_dir("git checkout #{branch}")
end

When(/^I install the AutoGrader gems$/) do
run_process('bundle install', @dir, true)
end

When /^I run cucumber for AutoGrader$/ do
@test_output, @test_errors, @test_status = Open3.capture3(
{ 'BUNDLE_GEMFILE' => 'Gemfile' }, 'bundle exec cucumber', :chdir => 'rag'
)
end

Then(/^I should see no difference$/) do
run_in_dir("git diff origin/#{@branch}")
expect(@test_output == '').to be_true
end

Then(/^I should see that there are no errors$/) do
expect(@test_status).to be_success
end

0 comments on commit 47d826d

Please sign in to comment.