gem_suit 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,11 @@
1
1
  = GemSuit CHANGELOG
2
2
 
3
- == Version 0.1.0 (March xxx, 2011)
3
+ == Version 0.1.1 (April 23, 2011)
4
+
5
+ * Added suit test {functional,integration,all}
6
+ * Improved `suit bundle` (running bundle install within gem dir and rails dummy app dirs only when required)
7
+ * Corrected generated suit_application.rb comment
8
+
9
+ == Version 0.1.0 (April 13, 2011)
4
10
 
5
11
  * Initial release
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -10,6 +10,13 @@ module GemSuit
10
10
 
11
11
  module InstanceMethods
12
12
 
13
+ def test_all(file_or_pattern = nil)
14
+ test_unit
15
+ test_functional
16
+ test_integration
17
+ test_suit
18
+ end
19
+
13
20
  def test_suit(file_or_pattern = nil)
14
21
  assert_suit_dir
15
22
 
@@ -29,6 +36,22 @@ module GemSuit
29
36
  end
30
37
 
31
38
  def test_unit(file_or_pattern = nil)
39
+ run_tests :unit, file_or_pattern
40
+ end
41
+
42
+ def test_functional(file_or_pattern = nil)
43
+ run_tests :functional, file_or_pattern
44
+ end
45
+
46
+ def test_integration(file_or_pattern = nil)
47
+ run_tests :integration, file_or_pattern
48
+ end
49
+
50
+ private
51
+
52
+ def run_tests(type, file_or_pattern)
53
+ raise ArgumentError, "Only :unit, :functional and :integration are allowed" unless [:unit, :functional, :integration].include? type
54
+
32
55
  assert_suit_dir
33
56
 
34
57
  loader = File.expand_path "../application/test_loader.rb", __FILE__
@@ -37,34 +60,36 @@ module GemSuit
37
60
  buffer.execute "suit restore"
38
61
 
39
62
  match = Dir[File.join(path, "**", "#{file_or_pattern || "*"}.rb")]
40
- match = Dir[File.join(path, file_or_pattern)] if match.empty?
41
- files = match.collect{|x| x.inspect}.join " "
63
+ match = Dir[File.join(path, file_or_pattern)] if match.empty? && !file_or_pattern.nil?
64
+ match.reject!{|x| x.include? "test/integration/suit/"}
42
65
 
43
- section = path.match(/suit\/([^\/]*)\//).captures[0].capitalize.gsub "-", " "
44
- files_desc = match.size == 1 ?
45
- match.first.gsub(path, "") :
46
- "#{file_or_pattern.nil? ? "All" : "Multiple"} tests"
66
+ unless match.empty?
67
+ files = match.collect{|x| x.inspect}.join " "
47
68
 
48
- buffer.log "#{section} - #{files_desc}"
49
- buffer.execute "ruby #{loader} #{"-I" if match.size > 1}#{files}"
50
- buffer.execute "suit restore"
69
+ section = path.match(/suit\/([^\/]*)\//).captures[0].capitalize.gsub "-", " "
70
+ files_desc = match.size == 1 ?
71
+ match.first.gsub(path, "") :
72
+ "#{file_or_pattern.nil? ? "All" : "Multiple"} tests"
73
+
74
+ buffer.log "#{section} - #{files_desc}"
75
+ buffer.execute "ruby #{loader} #{"-I" if match.size > 1}#{files}"
76
+ buffer.execute "suit restore"
77
+ end
51
78
  end
52
79
 
53
80
  data = IOBuffer.capture do |buffer|
54
81
  if options.rails_versions == ["0"]
55
- proc.call buffer, "suit/shared/test/unit/"
82
+ proc.call buffer, "suit/shared/test/#{type}/"
56
83
  else
57
84
  (options.rails_versions || major_rails_versions).each do |rails_version|
58
- proc.call buffer, "suit/rails-#{rails_version}/dummy/test/unit/"
85
+ proc.call buffer, "suit/rails-#{rails_version}/dummy/test/#{type}/"
59
86
  end
60
87
  end
61
88
  end
62
89
 
63
- print_test_results "Unit", data
90
+ print_test_results type.to_s.capitalize, data
64
91
  end
65
92
 
66
- private
67
-
68
93
  def files(action)
69
94
  assert_suit_dir
70
95
 
@@ -30,27 +30,39 @@ module GemSuit
30
30
  private
31
31
 
32
32
  def assert_gem_dir(non_gemsuit = false)
33
- if Dir["*.gemspec"].empty?
33
+ unless gem_dir?
34
34
  raise Error, "Missing *.gemspec in current directory. Is this really a gem directory?"
35
35
  end
36
- if non_gemsuit && !Dir[".suit"].empty?
36
+ if non_gemsuit && suit_dir?
37
37
  raise Error, "Found .suit in current directory. Is this gem already provided with GemSuit?"
38
38
  end
39
39
  end
40
40
 
41
41
  def assert_suit_dir
42
42
  assert_gem_dir
43
- if Dir[".suit"].empty?
43
+ unless suit_dir?
44
44
  raise Error, "Missing .suit in current directory. Is this really a GemSuit directory?"
45
45
  end
46
46
  end
47
47
 
48
48
  def assert_rails_dir
49
- unless File.expand_path("").match /suit\/rails-\d\/dummy$/
49
+ unless rails_dir?
50
50
  raise Error, "Current directory path does not match \"/suit/rails-{2,3}/dummy\". Is this really a GemSuit dummy app?"
51
51
  end
52
52
  end
53
53
 
54
+ def gem_dir?
55
+ !Dir["*.gemspec"].empty?
56
+ end
57
+
58
+ def suit_dir?
59
+ gem_dir? && !Dir[".suit"].empty?
60
+ end
61
+
62
+ def rails_dir?
63
+ !!File.expand_path("").match(/suit\/rails-\d\/dummy$/)
64
+ end
65
+
54
66
  def major_rails_versions
55
67
  Dir["suit/rails-*"].collect{|dir| dir.match(/rails-(\d)/); $1}
56
68
  end
data/lib/gem_suit/cli.rb CHANGED
@@ -128,10 +128,15 @@ module GemSuit
128
128
 
129
129
  desc "bundle", "Run `bundle install` (should be invoked from a Rails dummy application) only when necessary (used for testing)"
130
130
  def bundle
131
- assert_rails_dir
132
- if `bundle check`.any?{|line| line.include? "`bundle install`"}
133
- puts "Running `bundle install` (this can take several minutes...)".yellow
134
- system "bundle install"
131
+ raise Error, "Current directory path does not match either a GemSuit directory or a Rails dummy app. Quitting." unless suit_dir? || rails_dir?
132
+
133
+ dirs = [File.expand_path("")]
134
+ dirs.concat Dir["suit/rails-*/dummy"] if suit_dir?
135
+ dirs.each do |dir|
136
+ if `cd #{dir} && bundle check`.any?{|line| line.include? "`bundle install`"}
137
+ puts "Running `bundle install` (this can take several minutes...)".yellow
138
+ system "cd #{dir} && bundle install"
139
+ end
135
140
  end
136
141
  end
137
142
 
@@ -2,7 +2,7 @@ module GemSuit
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join(".")
8
8
  end
@@ -11,10 +11,10 @@ class SuitApplication < GemSuit::Application
11
11
  # generate_something
12
12
  # end
13
13
 
14
- # def config_for_template(path)
14
+ # def locals_for_template(path)
15
15
  # case path
16
16
  # when "Gemfile"
17
- # {"rails_gem_version" => "3.0.5"}
17
+ # {:rails_gem_version => "3.0.6"}
18
18
  # end
19
19
  # end
20
20
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_suit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Engel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-13 00:00:00 +02:00
18
+ date: 2011-04-23 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency