browse-everything 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,121 +0,0 @@
1
- require "spec_helper"
2
- require 'rake'
3
-
4
- # saves original $stdout in variable
5
- # set $stdout as local instance of StringIO
6
- # yields to code execution
7
- # returns the local instance of StringIO
8
- # resets $stdout to original value
9
- def capture_stdout
10
- out = StringIO.new
11
- $stdout = out
12
- yield
13
- return out.string
14
- ensure
15
- $stdout = STDOUT
16
- end
17
-
18
- def loaded_files_excluding_current_rake_file
19
- $".reject { |file| file.include? "tasks/sufia-fixtures" }
20
- end
21
-
22
- def attempts_max
23
- 30
24
- end
25
-
26
- describe "Rake Tasks" do
27
- before (:each) do
28
- @rake = Rake::Application.new
29
- Rake.application = @rake
30
- Rake.application.rake_require("browse-everything-dev", ["#{BrowseEverything::Engine.root}/tasks/"], loaded_files_excluding_current_rake_file)
31
- Rake::Task.define_task(:environment)
32
- end
33
-
34
- describe "start" do
35
- after (:each) do
36
- @rake['app:stop'].invoke
37
- end
38
- it "start an app" do
39
- o = capture_stdout do
40
- @rake['app:start'].invoke
41
- end
42
- o.should include "Starting"
43
- attempts = 1
44
- while ((!File.exists?('spec/internal/tmp/pids/server.pid')) && (attempts=+1 <attempts_max ))
45
- sleep(0.01)
46
- end
47
-
48
- expect(File).to exist("spec/internal/tmp/pids/server.pid")
49
- end
50
- end
51
-
52
- describe "stop" do
53
- it "stop a started app" do
54
-
55
- o = capture_stdout do
56
- @rake['app:start'].invoke
57
- end
58
-
59
- #wait until the app has started
60
- while (!File.exists?('spec/internal/tmp/pids/server.pid'))
61
- sleep(0.01)
62
- end
63
-
64
- o = capture_stdout do
65
- @rake['app:stop'].invoke
66
- end
67
- o.should include "Stopping"
68
- attempts = 1
69
- while ((File.exists?('spec/internal/tmp/pids/server.pid')) && (attempts=+1 <attempts_max ))
70
- sleep(0.01)
71
- end
72
- expect(File).not_to exist("spec/internal/tmp/pids/server.pid")
73
- end
74
-
75
- it "not fail when stopping a stopped app" do
76
-
77
- o = capture_stdout do
78
- @rake['app:stop'].invoke
79
- end
80
- expect(File).not_to exist("spec/internal/tmp/pids/server.pid")
81
- end
82
- end
83
-
84
- describe "clean" do
85
- after (:each) do
86
- @rake['app:generate'].invoke
87
- #wait until the app has generated
88
- while (!File.exists?('spec/internal/app/assets/stylesheets/'))
89
- sleep(0.01)
90
- end
91
- end
92
-
93
- it "remove spec internal app" do
94
-
95
- o = capture_stdout do
96
- @rake['app:clean'].invoke
97
- end
98
- expect(File).not_to exist("spec/internal/app")
99
- end
100
-
101
- it "stop server" do
102
- o = capture_stdout do
103
- @rake['app:start'].invoke
104
- end
105
-
106
- #wait until the app has started
107
- while (!File.exists?('spec/internal/tmp/pids/server.pid'))
108
- sleep(0.01)
109
- end
110
-
111
- o = capture_stdout do
112
- @rake['app:clean'].invoke
113
- end
114
- o.should include "Stopping"
115
- expect(File).not_to exist("spec/internal/app")
116
-
117
- end
118
-
119
- end
120
-
121
- end
@@ -1,70 +0,0 @@
1
- namespace :app do
2
- desc "Create the test rails app"
3
- task :generate do
4
- unless File.exists?('spec/internal/Rakefile')
5
- puts "Generating rails app"
6
- `rails new spec/internal`
7
- puts "Updating gemfile"
8
-
9
- `echo "gem 'browse-everything', :path=>'../../../browse-everything'
10
- gem 'factory_girl_rails'
11
- " >> spec/internal/Gemfile`
12
- puts "Copying generator"
13
- `cp -r spec/support/lib/generators spec/internal/lib`
14
- Bundler.with_clean_env do
15
- within_test_app do
16
- puts "running test_app_generator"
17
- system "rails generate test_app"
18
- puts "Bundle install"
19
- `bundle install`
20
- puts "running migrations"
21
- puts `rake db:migrate db:test:prepare`
22
- end
23
- end
24
- end
25
- puts "Done generating test app"
26
- end
27
-
28
- desc "Clean out the test rails app"
29
- task :clean do
30
- if File.directory?('spec/internal')
31
- within_test_app do
32
- puts "Stopping Spring"
33
- `spring stop`
34
- end
35
- end
36
-
37
- Rake::Task["app:stop"].invoke
38
- puts "Removing sample rails app"
39
- `rm -rf spec/internal`
40
- end
41
-
42
- desc "Start the test rails app"
43
- task :start do
44
- Bundler.with_clean_env do
45
- within_test_app do
46
- puts "Starting test app"
47
- system "rails server -d"
48
- end
49
- end
50
- end
51
-
52
- desc "Stop the test rails app"
53
- task :stop do
54
- pid_file = 'tmp/pids/server.pid'
55
- within_test_app do
56
- if (File.exists?(pid_file))
57
- pid = File.read(pid_file)
58
- puts "Stopping pid #{pid}"
59
- system "kill -2 #{pid}"
60
- end
61
- end
62
- end
63
- end
64
-
65
- def within_test_app
66
- return unless (File.exists?('spec/internal'))
67
- FileUtils.cd('spec/internal')
68
- yield
69
- FileUtils.cd('../..')
70
- end