Sha256: bb43d1c6b361fdd777cf7a7c87832046948fcd5d8cee98b30e7abc96df87abca

Contents?: true

Size: 1.9 KB

Versions: 6

Compression:

Stored size: 1.9 KB

Contents

def find_app(name, version)
  Application.first(:name => name, :version => version)
end

def install_hello(name, version)
  raise "wrong gem name" unless name == "hello-ruby-station"
  Application.install(:file, hello_gem_path(version))
end

def data_dir_of(name, version)
  File.expand_path("#{name}-#{version}", Conf.data_dir)
end

def test_txt_path(name, version)
  File.expand_path("test.txt", data_dir_of(name, version))
end

Given /^I have '(.*) (.*)'( and its data)?$/ do |name, version, data|
  unless find_app(name, version)
    install_hello(name, version)
  end
  if data
    File.open(test_txt_path(name, version), "w"){|f|
      # Note: content of test data file should be unique
      f.puts version
    }
  end
end

Given /^I do not have '(.*) (.*)'$/ do |name, version|
  if app = find_app(name, version)
    app.uninstall
  end
end

When /^I install '(.*) (.*)'$/ do |name, version|
  install_hello(name, version)
end

Then /^I should (?:still )?have '(.*) (.*)'$/ do |name, version|
  app = find_app(name, version)
  Ramaze::Log.error Application.all if app.nil? 
  app.should_not be_nil
end

Then /^I should not have '(.*) (.*)'$/ do |name, version|
  find_app(name, version).should be_nil
end

def files_of(dir)
  Dir["#{dir}/**"].map{|path| path.sub(dir, "")}
end

Then /^data files of '(.*) (.*)' should exist$/ do |name, version|
  Dir.entries(data_dir_of(name, version)).should_not be_empty
end

Then /^data files of '(.*) (.*)' should not exist$/ do |name, version|
  File.exist?(data_dir_of(name, version)).should be_false
end

Then /^data files of '(.*) (.*)' is same as '(.*) (.*)'/ do |n1, v1, n2, v2|
  files1 = files_of(data_dir_of(n1, v1)).sort
  files2 = files_of(data_dir_of(n2, v2)).sort
  files1.should == files2

  files1.each do |rel_path|
    path1 = File.join(data_dir_of(n1, v1), rel_path)
    path2 = File.join(data_dir_of(n2, v2), rel_path)

    File.read(path1).should == File.read(path2)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-station-0.1.6 tests/features/step_definitions/application_steps.rb
ruby-station-0.1.5 tests/features/step_definitions/application_steps.rb
ruby-station-0.1.4 tests/features/step_definitions/application_steps.rb
ruby-station-0.1.4.rc3 tests/features/step_definitions/application_steps.rb
ruby-station-0.1.4.rc2 tests/features/step_definitions/application_steps.rb
ruby-station-0.1.4.rc1 tests/features/step_definitions/application_steps.rb