qor_test 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +18 -16
- data/lib/qor_test/gem.rb +11 -12
- data/lib/qor_test/gemfile.rb +6 -4
- data/lib/qor_test/version.rb +1 -1
- data/test/gem_test.rb +98 -0
- metadata +5 -3
data/README.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
11
|
-
|
11
|
+
QorTest require a configuration file to know those dependencies and rubies need to be tested, For example:
|
12
12
|
|
13
13
|
# config/qor/test.rb
|
14
14
|
env '2.0' do
|
@@ -27,24 +27,24 @@
|
|
27
27
|
gem 'rails', [3.1, 3.2]
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
With above configuration, QorTest could generate 6 test cases.
|
31
31
|
|
32
|
-
1,
|
33
|
-
2,
|
34
|
-
3,
|
35
|
-
4,
|
36
|
-
5,
|
37
|
-
6,
|
32
|
+
1, Run tests with Rails 3.1 and Ruby 2.0
|
33
|
+
2, Run tests with Rails 3.2 and Ruby 2.0
|
34
|
+
3, Run tests with Rails 3.1 and Ruby 1.9
|
35
|
+
4, Run tests with Rails 3.2 and Ruby 1.9
|
36
|
+
5, Run tests with Rails 3.1 and Ruby 1.8
|
37
|
+
6, Run tests with Rails 3.2 and Ruby 1.8
|
38
38
|
|
39
|
-
|
39
|
+
To run "tests" of above 6 cases, you could run `qor_test` in your project root:
|
40
40
|
|
41
41
|
qor_test
|
42
42
|
|
43
|
-
Or
|
43
|
+
Or run those two cases in env '2.0' only by running
|
44
44
|
|
45
45
|
qor_test -e '2.0'
|
46
46
|
|
47
|
-
All dependencies definitions outside env definition will be shared in all envs, so you could
|
47
|
+
All dependencies definitions outside env definition will be shared in all envs, so you could simplify above configuration like below, it's the same!
|
48
48
|
|
49
49
|
# config/qor/test.rb
|
50
50
|
gem 'rails', [3.1, 3.2]
|
@@ -62,7 +62,7 @@
|
|
62
62
|
gem 'factory_girl_rails', '1.3.0'
|
63
63
|
end
|
64
64
|
|
65
|
-
|
65
|
+
Or you can write more advanced configuration:
|
66
66
|
|
67
67
|
# config/qor/test.rb
|
68
68
|
ruby '2.0'
|
@@ -73,9 +73,10 @@
|
|
73
73
|
gem 'rails', [3.1, 3.2]
|
74
74
|
gem 'devise', [2.2.0, 2.1.0, 2.0.0]
|
75
75
|
|
76
|
-
With it, QorTest will generate 54 test cases! (3 rubies x 3 paperclip x 2 rails x 3 devise),
|
76
|
+
With it, QorTest will generate 54 test cases! (3 rubies x 3 paperclip x 2 rails x 3 devise), is it dead easy to discover hidden compatibility issues?
|
77
77
|
|
78
|
-
|
78
|
+
|
79
|
+
Running `qor_test` will use command `rake spec` to run "tests" in each case for projects using rspec and `rake test` for others. but you could specify the test command by overwrite the environment variable 'COMMAND', e.g:
|
79
80
|
|
80
81
|
COMMAND='ruby test/xxxx.rb' qor_test
|
81
82
|
|
@@ -88,5 +89,6 @@
|
|
88
89
|
5. Create new Pull Request
|
89
90
|
|
90
91
|
## Author ##
|
91
|
-
|
92
|
-
|
92
|
+
Jinzhu <http://github.com/jinzhu>
|
93
|
+
|
94
|
+
* A Product From ThePlant <http://theplant.jp>
|
data/lib/qor_test/gem.rb
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
module Qor
|
2
2
|
module Test
|
3
3
|
class Gem
|
4
|
-
attr_accessor :name, :options
|
4
|
+
attr_accessor :name, :options
|
5
5
|
|
6
6
|
def initialize(node, gem_option=nil)
|
7
7
|
self.name = node.name.to_s
|
8
|
-
self.
|
8
|
+
self.options = gem_option.is_a?(Array) ? gem_option : [gem_option]
|
9
9
|
|
10
10
|
[:git, :path, :platforms].map do |type|
|
11
11
|
if node.parent.is_node?(type)
|
12
|
-
|
12
|
+
parent_option = {type => node.parent.value}.merge(node.parent.options)
|
13
|
+
if options[-1].is_a?(Hash)
|
14
|
+
self.options[-1] = parent_option.merge(options[-1])
|
15
|
+
else
|
16
|
+
self.options.push(parent_option)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
16
21
|
|
17
22
|
def to_s
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
%{gem "#{name}", #{gem_option.inspect}}
|
22
|
-
elsif options.is_a?(Hash)
|
23
|
-
%{gem "#{name}", #{options.inspect}}
|
24
|
-
else
|
25
|
-
%{gem "#{name}"}
|
26
|
-
end
|
23
|
+
result = %{gem "#{name}"}
|
24
|
+
result += %{, #{options.map(&:inspect).join(", ")}} if options.length > 0
|
25
|
+
result
|
27
26
|
end
|
28
27
|
|
29
28
|
def self.parse(node)
|
data/lib/qor_test/gemfile.rb
CHANGED
@@ -35,17 +35,19 @@ module Qor
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def generate_gems_entry(gems_from_config, gems_from_gemfile)
|
39
39
|
gem_names = [gems_from_config.keys, gems_from_gemfile.keys].flatten.compact.uniq
|
40
40
|
|
41
|
-
|
41
|
+
gem_names.map do |name|
|
42
42
|
gems_from_config[name] || gems_from_gemfile[name]
|
43
|
-
end.compact
|
43
|
+
end.compact.map(&:to_s).join("\n")
|
44
|
+
end
|
44
45
|
|
46
|
+
def write_gemfile(gems_from_config, gems_from_gemfile, filename)
|
45
47
|
File.open(filename, "w+") do |f|
|
46
48
|
f << Qor::Test::Configuration.combined_sources(options)
|
47
49
|
f << Qor::Test::Configuration.combined_gemspecs(options)
|
48
|
-
f <<
|
50
|
+
f << generate_gems_entry(gems_from_config, gems_from_gemfile)
|
49
51
|
end.path
|
50
52
|
end
|
51
53
|
end
|
data/lib/qor_test/version.rb
CHANGED
data/test/gem_test.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'qor_test'
|
3
|
+
|
4
|
+
describe Gem do
|
5
|
+
it "gem to string" do
|
6
|
+
# case 1
|
7
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
8
|
+
gem "rails", "3.1"
|
9
|
+
end
|
10
|
+
|
11
|
+
Qor::Test::Gem.parse(config.first("gem")).length.must_equal 1
|
12
|
+
Qor::Test::Gem.parse(config.first("gem"))[0].to_s.must_equal 'gem "rails", "3.1"'
|
13
|
+
|
14
|
+
# case 2
|
15
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
16
|
+
gem "rails", ["3.1", "3.2"]
|
17
|
+
end
|
18
|
+
|
19
|
+
Qor::Test::Gem.parse(config.first("gem")).length.must_equal 2
|
20
|
+
Qor::Test::Gem.parse(config.first("gem"))[0].to_s.must_equal 'gem "rails", "3.1"'
|
21
|
+
Qor::Test::Gem.parse(config.first("gem"))[1].to_s.must_equal 'gem "rails", "3.2"'
|
22
|
+
|
23
|
+
# case 3
|
24
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
25
|
+
gem 'nokogiri', [{:git => "git://github.com/tenderlove/nokogiri.git", :branch => "1.4"}, {:git => "git://github.com/tenderlove/nokogiri.git"}]
|
26
|
+
end
|
27
|
+
|
28
|
+
Qor::Test::Gem.parse(config.first("gem")).length.must_equal 2
|
29
|
+
Qor::Test::Gem.parse(config.first("gem"))[0].to_s.must_equal 'gem "nokogiri", {:git=>"git://github.com/tenderlove/nokogiri.git", :branch=>"1.4"}'
|
30
|
+
Qor::Test::Gem.parse(config.first("gem"))[1].to_s.must_equal 'gem "nokogiri", {:git=>"git://github.com/tenderlove/nokogiri.git"}'
|
31
|
+
|
32
|
+
# case 4
|
33
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
34
|
+
gem 'nokogiri', :git => "git://github.com/tenderlove/nokogiri.git", :branch => "1.4"
|
35
|
+
end
|
36
|
+
|
37
|
+
Qor::Test::Gem.parse(config.first("gem")).length.must_equal 1
|
38
|
+
Qor::Test::Gem.parse(config.first("gem"))[0].to_s.must_equal 'gem "nokogiri", {:git=>"git://github.com/tenderlove/nokogiri.git", :branch=>"1.4"}'
|
39
|
+
|
40
|
+
# case 5
|
41
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
42
|
+
gem 'RedCloth', ">= 4.1.0", "< 4.2.0"
|
43
|
+
end
|
44
|
+
|
45
|
+
Qor::Test::Gem.parse(config.first("gem")).length.must_equal 1
|
46
|
+
Qor::Test::Gem.parse(config.first("gem"))[0].to_s.must_equal 'gem "RedCloth", ">= 4.1.0", "< 4.2.0"'
|
47
|
+
|
48
|
+
# case 6
|
49
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
50
|
+
git "git://github.com/tenderlove/nokogiri.git" do
|
51
|
+
gem 'nokogiri', '1.4'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0]).length.must_equal 1
|
56
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0])[0].to_s.must_equal 'gem "nokogiri", "1.4", {:git=>"git://github.com/tenderlove/nokogiri.git"}'
|
57
|
+
|
58
|
+
# case 7
|
59
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
60
|
+
git "git://github.com/tenderlove/nokogiri.git" do
|
61
|
+
gem 'nokogiri', :branch => '1.4'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0]).length.must_equal 1
|
66
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0])[0].to_s.must_equal 'gem "nokogiri", {:git=>"git://github.com/tenderlove/nokogiri.git", :branch=>"1.4"}'
|
67
|
+
|
68
|
+
# case 8
|
69
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
70
|
+
gem "rails"
|
71
|
+
end
|
72
|
+
|
73
|
+
Qor::Test::Gem.parse(config.first("gem")).length.must_equal 1
|
74
|
+
Qor::Test::Gem.parse(config.first("gem"))[0].to_s.must_equal 'gem "rails"'
|
75
|
+
|
76
|
+
# case 9
|
77
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
78
|
+
git "git://github.com/tenderlove/nokogiri.git" do
|
79
|
+
gem 'nokogiri', ['1.4', '2.0']
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0]).length.must_equal 2
|
84
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0])[0].to_s.must_equal 'gem "nokogiri", "1.4", {:git=>"git://github.com/tenderlove/nokogiri.git"}'
|
85
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0])[1].to_s.must_equal 'gem "nokogiri", "2.0", {:git=>"git://github.com/tenderlove/nokogiri.git"}'
|
86
|
+
|
87
|
+
# case 10
|
88
|
+
config = Qor::Test::Configuration.load(nil, :force => true) do
|
89
|
+
git "git://github.com/tenderlove/nokogiri.git" do
|
90
|
+
gem 'nokogiri', [{:branch => '1.4'}, {:branch => '2.0'}]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0]).length.must_equal 2
|
95
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0])[0].to_s.must_equal 'gem "nokogiri", {:git=>"git://github.com/tenderlove/nokogiri.git", :branch=>"1.4"}'
|
96
|
+
Qor::Test::Gem.parse(config.deep_find("gem")[0])[1].to_s.must_equal 'gem "nokogiri", {:git=>"git://github.com/tenderlove/nokogiri.git", :branch=>"2.0"}'
|
97
|
+
end
|
98
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qor_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: qor_dsl
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/qor_test/rubies.rb
|
55
55
|
- lib/qor_test/version.rb
|
56
56
|
- qor_test.gemspec
|
57
|
+
- test/gem_test.rb
|
57
58
|
homepage: ''
|
58
59
|
licenses: []
|
59
60
|
post_install_message:
|
@@ -78,5 +79,6 @@ rubygems_version: 1.8.24
|
|
78
79
|
signing_key:
|
79
80
|
specification_version: 3
|
80
81
|
summary: ! 'Qor Test: Make test easier!'
|
81
|
-
test_files:
|
82
|
+
test_files:
|
83
|
+
- test/gem_test.rb
|
82
84
|
has_rdoc:
|