Class: Ftpspec::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/ftpspec/setup.rb

Class Method Summary collapse

Class Method Details

.runObject



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 = "require \"spec_helper\"\n\ndescribe \"/httpdocs/index.html\" do\n  it { should be_mode 644 }\nend\n  EOF\n\n  rakefile_contents = <<-EOF\nrequire \"rake\"\nrequire \"rspec/core/rake_task\"\n\nRSpec::Core::RakeTask.new(:spec) do |t|\n  t.pattern = \"spec/*/*_spec.rb\"\nend\n\ntask :default => :spec\n  EOF\n\n  spec_helper_contents = <<-EOF\nrequire \"ftpspec\"\nrequire \"rubygems\"\nrequire \"rspec\"\nrequire \"net/ftp\"\n\nRSpec.configure do |c|\n  c.add_setting :ftp, :default => nil\n  c.before do\nhostname = \"\"\nuser = \"\"\npassword = \"\"\nc.ftp = Net::FTP.new\nc.ftp.passive = true\nc.ftp.connect(hostname)\nc.ftp.login(user, password)\nFtpspec.set_ftp\n  end\n  c.after do\nc.ftp.close\n  end\nend\n  EOF\n\n  FileUtils.mkdir \"spec\"\n  File.open(\"spec/ftp_spec.rb\", \"w\") do |f|\n    f.puts file_contents\n  end\n  File.open(\"spec/spec_helper.rb\", \"w\") do |f|\n    f.puts spec_helper_contents\n  end\n  File.open(\"Rakefile\", \"w\") do |f|\n    f.puts rakefile_contents\n  end\nend\n"