5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/ftpspec/setup.rb', line 5
def self.run
file_contents = <<-EOF
require "spec_helper"
describe "/httpdocs/index.html" do
it { should be_mode "644" }
end
EOF
rakefile_contents = <<-EOF
require "rake"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = "spec/*/*_spec.rb"
end
task :default => :spec
EOF
spec_helper_contents = <<-EOF
require "ftpspec"
require "rubygems"
require "rspec"
require "net/ftp"
RSpec.configure do |c|
c.add_setting :ftp, :default => nil
c.before do
hostname = ""
user = ""
password = ""
c.ftp = Net::FTP.new
c.ftp.passive = true
c.ftp.connect(hostname)
c.ftp.login(user, password)
Ftpspec.set_ftp
end
c.after do
c.ftp.close
end
end
EOF
FileUtils.mkdir "spec"
File.open("spec/ftp_spec.rb", "w") do |f|
f.puts file_contents
end
File.open("spec/spec_helper.rb", "w") do |f|
f.puts spec_helper_contents
end
File.open("Rakefile", "w") do |f|
f.puts rakefile_contents
end
end
|