infinity_test 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.infinity_test +30 -2
- data/.rspec +2 -0
- data/.rvmrc +1 -1
- data/Gemfile +10 -2
- data/Gemfile.lock +52 -12
- data/History.markdown +86 -2
- data/LICENSE.txt +22 -0
- data/Rakefile +25 -9
- data/Readme.markdown +47 -23
- data/TODO.markdown +12 -0
- data/Tasks +2 -3
- data/VERSION.yml +2 -2
- data/bin/infinity_test +1 -1
- data/features/heuristics.feature +23 -0
- data/features/support/env.rb +2 -0
- data/images/fuuu/failure.png +0 -0
- data/images/fuuu/pending.png +0 -0
- data/images/fuuu/sucess.png +0 -0
- data/infinity_test.gemspec +62 -29
- data/lib/infinity_test.rb +29 -9
- data/lib/infinity_test/application.rb +222 -68
- data/lib/infinity_test/application_library/rails.rb +94 -0
- data/lib/infinity_test/application_library/rubygems.rb +43 -0
- data/lib/infinity_test/binary_path.rb +30 -8
- data/lib/infinity_test/builder.rb +56 -0
- data/lib/infinity_test/command.rb +18 -24
- data/lib/infinity_test/configuration.rb +96 -44
- data/lib/infinity_test/continuous_testing.rb +17 -39
- data/lib/infinity_test/dependencies.rb +76 -41
- data/lib/infinity_test/environment.rb +15 -0
- data/lib/infinity_test/heuristics.rb +36 -0
- data/lib/infinity_test/heuristics_helper.rb +9 -0
- data/lib/infinity_test/options.rb +56 -19
- data/lib/infinity_test/runner.rb +25 -17
- data/lib/infinity_test/test_framework.rb +109 -0
- data/lib/infinity_test/test_library/bacon.rb +55 -0
- data/lib/infinity_test/test_library/cucumber.rb +22 -0
- data/lib/infinity_test/test_library/rspec.rb +58 -0
- data/lib/infinity_test/test_library/test_unit.rb +46 -0
- data/spec/factories/company/Gemfile +0 -0
- data/spec/factories/infinity_test_example +2 -2
- data/spec/infinity_test/application_library/rails_spec.rb +140 -0
- data/spec/infinity_test/application_library/rubygems_spec.rb +52 -0
- data/spec/infinity_test/application_spec.rb +274 -50
- data/spec/infinity_test/binary_path_spec.rb +72 -0
- data/spec/infinity_test/builder_spec.rb +7 -0
- data/spec/infinity_test/command_spec.rb +13 -14
- data/spec/infinity_test/configuration_spec.rb +183 -57
- data/spec/infinity_test/continuous_testing_spec.rb +19 -1
- data/spec/infinity_test/environment_spec.rb +23 -0
- data/spec/infinity_test/heuristics_helper_spec.rb +15 -0
- data/spec/infinity_test/heuristics_spec.rb +127 -0
- data/spec/infinity_test/options_spec.rb +48 -26
- data/spec/infinity_test/runner_spec.rb +37 -29
- data/spec/infinity_test/test_framework_spec.rb +127 -0
- data/spec/infinity_test/test_library/bacon_spec.rb +150 -0
- data/spec/infinity_test/test_library/cucumber_spec.rb +8 -0
- data/spec/infinity_test/test_library/rspec_spec.rb +185 -0
- data/spec/infinity_test/test_library/test_unit_spec.rb +184 -0
- data/spec/infinity_test_spec.rb +23 -12
- data/spec/spec_helper.rb +86 -30
- metadata +62 -32
- data/lib/infinity_test/notifications/growl.rb +0 -15
- data/lib/infinity_test/notifications/lib_notify.rb +0 -11
- data/lib/infinity_test/rspec.rb +0 -87
- data/lib/infinity_test/test_unit.rb +0 -74
- data/spec/infinity_test/notifications/growl_spec.rb +0 -9
- data/spec/infinity_test/notifications/lib_notify_spec.rb +0 -9
- data/spec/infinity_test/rspec_spec.rb +0 -189
- data/spec/infinity_test/test_unit_spec.rb +0 -182
- data/spec/spec.opts +0 -1
@@ -0,0 +1,55 @@
|
|
1
|
+
module InfinityTest
|
2
|
+
module TestLibrary
|
3
|
+
class Bacon < TestFramework
|
4
|
+
binary :bacon
|
5
|
+
parse_results :specifications => /(\d+) specifications/, :requirements => /(\d+) requirements/, :failures => /(\d+) failure/, :errors => /(\d+) errors/
|
6
|
+
|
7
|
+
# Bacon Framework
|
8
|
+
#
|
9
|
+
# For more information about the Bacon see: http://github.com/chneukirchen/bacon
|
10
|
+
#
|
11
|
+
# bacon = InfinityTest::Bacon.new(:rubies => '1.9.1,1.9.2')
|
12
|
+
# bacon.rubies # => '1.9.1,1.9.2'
|
13
|
+
# bacon.test_directory_pattern # => "^spec/*/(.*)_spec.rb"
|
14
|
+
# bacon.test_pattern # => 'spec/**/*_spec.rb'
|
15
|
+
#
|
16
|
+
def initialize(options={})
|
17
|
+
super(options)
|
18
|
+
@test_pattern = 'spec/**/*_spec.rb'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Construct all the commands for each ruby
|
22
|
+
# First, try to find the bacon binary, and raise/puts an Error if don't find it.
|
23
|
+
# After that, verifying if the user have a Gemfile, and if has, run with "bundle exec" command, else will run normally
|
24
|
+
#
|
25
|
+
def construct_rubies_commands(file=nil)
|
26
|
+
commands = {}
|
27
|
+
environments do |environment, ruby_version|
|
28
|
+
bacon_binary = search_bacon(environment)
|
29
|
+
command = construct_command(
|
30
|
+
:for => ruby_version,
|
31
|
+
:binary => bacon_binary,
|
32
|
+
:load_path => 'lib:spec',
|
33
|
+
:file => file,
|
34
|
+
:environment => environment) || next
|
35
|
+
commands[ruby_version] = command
|
36
|
+
end
|
37
|
+
commands
|
38
|
+
end
|
39
|
+
|
40
|
+
def sucess?
|
41
|
+
return false if failure?
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
def failure?
|
46
|
+
@failures > 0
|
47
|
+
end
|
48
|
+
|
49
|
+
def pending?
|
50
|
+
false # Don't have pending in Bacon
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module InfinityTest
|
2
|
+
module TestLibrary
|
3
|
+
class Cucumber < TestFramework
|
4
|
+
include HeuristicsHelper
|
5
|
+
binary :cucumber
|
6
|
+
parse_results :passed => /(\d+) passed/, :failed => /(\d+) failed/
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
add_heuristics!
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_heuristics!
|
13
|
+
heuristics do
|
14
|
+
add("^features/*/*feature") do
|
15
|
+
run :all => :tests, :in_dir => :steps_definitions
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module InfinityTest
|
2
|
+
module TestLibrary
|
3
|
+
class Rspec < TestFramework
|
4
|
+
binary :rspec, :name => :rspec_two
|
5
|
+
binary :spec, :name => :rspec_one
|
6
|
+
|
7
|
+
parse_results :examples => /(\d+) example/, :failures => /(\d+) failure/, :pending => /(\d+) pending/
|
8
|
+
|
9
|
+
#
|
10
|
+
# rspec = InfinityTest::Rspec.new(:rubies => '1.9.1,1.9.2')
|
11
|
+
# rspec.rubies # => '1.9.1,1.9.2'
|
12
|
+
# rspec.test_pattern # => 'spec/**/*_spec.rb'
|
13
|
+
#
|
14
|
+
def initialize(options={})
|
15
|
+
super(options)
|
16
|
+
@test_pattern = 'spec/**/*_spec.rb'
|
17
|
+
end
|
18
|
+
|
19
|
+
# Construct all the commands for each ruby
|
20
|
+
# First, try to find the rspec one binary, and if don't have installed
|
21
|
+
# try to find rspec two, and raise/puts an Error if don't find it.
|
22
|
+
# After that, verifying if the user have a Gemfile, and if has,
|
23
|
+
# run with "bundle exec" command, else will run normally
|
24
|
+
#
|
25
|
+
def construct_rubies_commands(file=nil)
|
26
|
+
commands = {}
|
27
|
+
environments do |environment, ruby_version|
|
28
|
+
rspec_binary = search_rspec_two(environment)
|
29
|
+
rspec_binary = search_rspec_one(environment) unless have_binary?(rspec_binary)
|
30
|
+
commands[ruby_version] = construct_command(
|
31
|
+
:for => ruby_version,
|
32
|
+
:binary => rspec_binary,
|
33
|
+
:file => file,
|
34
|
+
:environment => environment)
|
35
|
+
end
|
36
|
+
commands
|
37
|
+
end
|
38
|
+
|
39
|
+
def search_files(file_pattern)
|
40
|
+
all_files.grep(/#{file_pattern}/i).join(' ')
|
41
|
+
end
|
42
|
+
|
43
|
+
def sucess?
|
44
|
+
return false if failure? or pending?
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def failure?
|
49
|
+
@failures > 0
|
50
|
+
end
|
51
|
+
|
52
|
+
def pending?
|
53
|
+
@pending > 0 and not failure?
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module InfinityTest
|
2
|
+
module TestLibrary
|
3
|
+
class TestUnit < TestFramework
|
4
|
+
parse_results :tests => /(\d+) tests/, :assertions => /(\d+) assertions/,
|
5
|
+
:failures => /(\d+) failures/, :errors => /(\d+) errors/
|
6
|
+
|
7
|
+
def initialize(options={})
|
8
|
+
super(options)
|
9
|
+
@test_pattern = 'test/**/*_test.rb'
|
10
|
+
end
|
11
|
+
|
12
|
+
def construct_rubies_commands(file=nil)
|
13
|
+
command = {}
|
14
|
+
environments do |environment, ruby_version|
|
15
|
+
command[ruby_version] = construct_command(
|
16
|
+
:for => ruby_version,
|
17
|
+
:load_path => 'lib:test',
|
18
|
+
:file => file,
|
19
|
+
:environment => environment,
|
20
|
+
:skip_binary? => true)
|
21
|
+
end
|
22
|
+
command
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_files
|
26
|
+
super.split.unshift(test_loader).sort.join(' ')
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_loader
|
30
|
+
$LOAD_PATH.each do |path|
|
31
|
+
file_path = File.join(path, "infinity_test/test_unit_loader.rb")
|
32
|
+
return file_path if File.exist?(file_path)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def failure?
|
37
|
+
@failures > 0 or @errors > 0
|
38
|
+
end
|
39
|
+
|
40
|
+
def pending?
|
41
|
+
false # Don't have pending in Test::Unit right?? #doubt
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
File without changes
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module InfinityTest
|
4
|
+
module ApplicationLibrary
|
5
|
+
describe Rails do
|
6
|
+
let(:rails) { Rails.new }
|
7
|
+
|
8
|
+
describe '#lib_pattern' do
|
9
|
+
|
10
|
+
it { rails.lib_pattern.should == "^lib/*/(.*)\.rb" }
|
11
|
+
|
12
|
+
it "should be possible to change the library pattern" do
|
13
|
+
rails.lib_pattern = "^another_lib/*/(.*)\.rb"
|
14
|
+
rails.lib_pattern.should == "^another_lib/*/(.*)\.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#test_pattern' do
|
20
|
+
|
21
|
+
it "should return the pattern for Test::Unit" do
|
22
|
+
stub_application_with_test_unit
|
23
|
+
rails.test_pattern.should == "^test/*/(.*)_test.rb"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return the pattern for Rspec " do
|
27
|
+
stub_application_with_rspec
|
28
|
+
rails.test_pattern.should == "^spec/*/(.*)_spec.rb"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#configuration_pattern' do
|
34
|
+
|
35
|
+
it "should set to config/application.rb" do
|
36
|
+
rails.configuration_pattern.should == "^config/application.rb"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should possible to change the configuration_pattern" do
|
40
|
+
rails.configuration_pattern = "^config/environment.rb"
|
41
|
+
rails.configuration_pattern.should == "^config/environment.rb"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#routes_pattern' do
|
47
|
+
|
48
|
+
it "should return the routes_pattern" do
|
49
|
+
rails.routes_pattern.should == "^config/routes\.rb"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should be possible to set the routes pattern" do
|
53
|
+
rails.routes_pattern = "^config/routes_s\.rb"
|
54
|
+
rails.routes_pattern.should == "^config/routes_s\.rb"
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#fixtures_pattern' do
|
60
|
+
|
61
|
+
it "should set the fixtures pattern" do
|
62
|
+
stub_application_with_test_unit
|
63
|
+
rails.fixtures_pattern.should == "^test/fixtures/(.*).yml"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should set a diferent fixtures pattern" do
|
67
|
+
stub_application_with_rspec
|
68
|
+
rails.fixtures_pattern.should == "^spec/fixtures/(.*).yml"
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#controllers_pattern' do
|
74
|
+
|
75
|
+
it "should set the controllers pattern" do
|
76
|
+
rails.controllers_pattern.should == "^app/controllers/(.*)\.rb"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should be possible to set the controllers pattern" do
|
80
|
+
rails.controllers_pattern = "^app/super_controllers/(.*)\.rb"
|
81
|
+
rails.controllers_pattern.should == "^app/super_controllers/(.*)\.rb"
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#helpers_pattern' do
|
87
|
+
it "should return the controllers pattern" do
|
88
|
+
rails.helpers_pattern.should == "^app/helpers/(.*)\.rb"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should be possible to set the controllers pattern" do
|
92
|
+
rails.helpers_pattern = "^app/super_helpers/(.*)\.rb"
|
93
|
+
rails.helpers_pattern.should == "^app/super_helpers/(.*)\.rb"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#mailers_pattern' do
|
98
|
+
|
99
|
+
it "should return the controllers pattern" do
|
100
|
+
rails.mailers_pattern.should == "^app/mailers/(.*)\.rb"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should be possible to set the controllers pattern" do
|
104
|
+
rails.mailers_pattern = "^app/super_mailers/(.*)\.rb"
|
105
|
+
rails.mailers_pattern.should == "^app/super_mailers/(.*)\.rb"
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#application_controller_pattern' do
|
111
|
+
it "should return the application controller" do
|
112
|
+
rails.application_controller_pattern.should == "^app/controllers/application_controller.rb"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#application_helper_pattern' do
|
117
|
+
it "should return the application_helper_pattern" do
|
118
|
+
rails.application_helper_pattern.should == "^app/helpers/application_helper.rb"
|
119
|
+
end
|
120
|
+
it "should be possible to set the application helper pattern" do
|
121
|
+
rails.application_helper_pattern = "my_pattern"
|
122
|
+
rails.application_helper_pattern.should == "my_pattern"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe '#models_pattern' do
|
127
|
+
it "should set the controllers pattern" do
|
128
|
+
rails.models_pattern.should == "^app/models/(.*)\.rb"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should be possible to set the controllers pattern" do
|
132
|
+
rails.models_pattern = "^app/super_models/(.*)\.rb"
|
133
|
+
rails.models_pattern.should == "^app/super_models/(.*)\.rb"
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module InfinityTest
|
4
|
+
module ApplicationLibrary
|
5
|
+
describe RubyGems do
|
6
|
+
let(:rubygems) { RubyGems.new }
|
7
|
+
|
8
|
+
describe '#application' do
|
9
|
+
it { rubygems.application.should equal InfinityTest.application }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#lib_pattern' do
|
13
|
+
|
14
|
+
it { rubygems.lib_pattern.should == "^lib/*/(.*)\.rb" }
|
15
|
+
|
16
|
+
it "should be possible to change the library pattern" do
|
17
|
+
rubygems.lib_pattern = "^another_lib/*/(.*)\.rb"
|
18
|
+
rubygems.lib_pattern.should == "^another_lib/*/(.*)\.rb"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#test_pattern' do
|
24
|
+
|
25
|
+
it "should return the pattern for Test::Unit" do
|
26
|
+
stub_application_with_test_unit
|
27
|
+
rubygems.test_pattern.should == "^test/*/(.*)_test.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return the pattern for Rspec" do
|
31
|
+
stub_application_with_rspec
|
32
|
+
rubygems.test_pattern.should == "^spec/*/(.*)_spec.rb"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#test_helper_pattern' do
|
38
|
+
it "should return the pattern for Test::Unit" do
|
39
|
+
stub_application_with_test_unit
|
40
|
+
rubygems.test_helper_pattern.should == "^test/*/test_helper.rb"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return the pattern for Rspec" do
|
44
|
+
stub_application_with_rspec
|
45
|
+
rubygems.test_helper_pattern.should == "^spec/*/spec_helper.rb"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -3,37 +3,117 @@ require 'spec_helper'
|
|
3
3
|
module InfinityTest
|
4
4
|
describe Application do
|
5
5
|
let(:application) { Application.new }
|
6
|
-
|
6
|
+
let(:config) { Configuration.new }
|
7
|
+
|
7
8
|
before(:each) do
|
8
9
|
@application = Application.new
|
10
|
+
@current_dir = Dir.pwd
|
9
11
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
|
15
|
+
it "should return the rubies in the config" do
|
16
|
+
application_with(:rubies => ['1.8.7']).rubies.should == '1.8.7'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return the rubies in the config" do
|
20
|
+
application_with(:rubies => ['1.9.2']).rubies.should == '1.9.2'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return the watchr script instance" do
|
24
|
+
application_with_rspec.watchr.should be_instance_of(Watchr::Script)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return the same object in the infinity test watchr" do
|
28
|
+
application_with_rspec.watchr.should equal InfinityTest.watchr
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return the before callback" do
|
32
|
+
app = application_with(:test_framework => :rspec)
|
33
|
+
proc = Proc.new { 'To Infinity and beyond!' }
|
34
|
+
app.config.before_run(&proc)
|
35
|
+
app.before_callback.should equal proc
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return the block when set after callback" do
|
39
|
+
app = application_with(:test_framework => :rspec)
|
40
|
+
proc = Proc.new { 'To Infinity and beyond!' }
|
41
|
+
app.config.after_run(&proc)
|
42
|
+
app.after_callback.should equal proc
|
43
|
+
end
|
13
44
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
45
|
+
|
46
|
+
describe '#heuristics' do
|
47
|
+
|
48
|
+
it "should be instance of Heuristics class" do
|
49
|
+
@application.config.heuristics {}
|
50
|
+
@application.heuristics.should be_instance_of(InfinityTest::Heuristics)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be the same heuristics setting in the configuration file" do
|
54
|
+
heuristics = @application.config.heuristics {}
|
55
|
+
heuristics.should equal @application.heuristics
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#add_heuristics!' do
|
61
|
+
|
62
|
+
it "rules should be empty before call add_heuristics! method" do
|
63
|
+
InfinityTest.watchr.rules.should be_empty
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should add rule sto the scope of Watchr::Script" do
|
67
|
+
application.add_heuristics!
|
68
|
+
InfinityTest.watchr.rules.should_not be_empty
|
69
|
+
end
|
70
|
+
|
17
71
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
72
|
+
|
73
|
+
describe '#heuristics_users_high_priority!' do
|
74
|
+
|
75
|
+
before do
|
76
|
+
@application = application_with(:test_framework => :rspec, :app_framework => :rubygems)
|
77
|
+
@application.heuristics.add('my_rule.rb')
|
78
|
+
@application.heuristics.add('other_rule.rb')
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should reverse the rules of watchr" do
|
82
|
+
@application.heuristics_users_high_priority!
|
83
|
+
@application.watchr.patterns[0].should == 'other_rule.rb'
|
84
|
+
@application.watchr.patterns[1].should == 'my_rule.rb'
|
85
|
+
end
|
86
|
+
|
21
87
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
88
|
+
|
89
|
+
describe '#have_gemfile?' do
|
90
|
+
|
91
|
+
it "should return true when Gemfile exists" do
|
92
|
+
application.should_receive(:gemfile).and_return(factory_company_gemfile)
|
93
|
+
application.have_gemfile?.should be_true
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should return false when Gemfile not exists" do
|
97
|
+
application.should_receive(:gemfile).and_return(factory_buzz_gemfile)
|
98
|
+
application.have_gemfile?.should be_false
|
99
|
+
end
|
100
|
+
|
28
101
|
end
|
29
102
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
103
|
+
describe '#skip_bundler?' do
|
104
|
+
|
105
|
+
it "should return true if skip_bundler! is set" do
|
106
|
+
application.config.skip_bundler!
|
107
|
+
application.skip_bundler?.should be_true
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should return false if skip_bundler! is not set" do
|
111
|
+
InfinityTest.should_receive(:configuration).and_return(config)
|
112
|
+
Application.new.skip_bundler?.should be_false
|
113
|
+
end
|
114
|
+
|
35
115
|
end
|
36
|
-
|
116
|
+
|
37
117
|
describe '#image_to_show' do
|
38
118
|
|
39
119
|
before do
|
@@ -59,7 +139,7 @@ module InfinityTest
|
|
59
139
|
end
|
60
140
|
|
61
141
|
def test_should_not_fail!(object)
|
62
|
-
object.test_framework.should_receive(:failure?).and_return(false)
|
142
|
+
object.test_framework.should_receive(:failure?).and_return(false)
|
63
143
|
end
|
64
144
|
|
65
145
|
def test_should_fail!(object)
|
@@ -67,25 +147,25 @@ module InfinityTest
|
|
67
147
|
end
|
68
148
|
|
69
149
|
def test_should_pending!(object)
|
70
|
-
object.test_framework.should_receive(:pending?).and_return(true)
|
150
|
+
object.test_framework.should_receive(:pending?).and_return(true)
|
71
151
|
end
|
72
152
|
|
73
153
|
def test_should_not_pending!(object)
|
74
|
-
object.test_framework.should_receive(:pending?).and_return(false)
|
154
|
+
object.test_framework.should_receive(:pending?).and_return(false)
|
75
155
|
end
|
76
156
|
|
77
157
|
end
|
78
|
-
|
158
|
+
|
79
159
|
describe '#notification_framework' do
|
80
160
|
|
81
161
|
it "should return the Growl notification framework if has :growl" do
|
82
162
|
application.config.notifications :growl
|
83
|
-
application.notification_framework.should
|
163
|
+
application.notification_framework.should equal :growl
|
84
164
|
end
|
85
|
-
|
165
|
+
|
86
166
|
it "should return the Lib Notify if has :lib_notify" do
|
87
167
|
application.config.notifications :lib_notify
|
88
|
-
application.notification_framework.should
|
168
|
+
application.notification_framework.should equal :lib_notify
|
89
169
|
end
|
90
170
|
|
91
171
|
it "should cache notification" do
|
@@ -95,35 +175,40 @@ module InfinityTest
|
|
95
175
|
end
|
96
176
|
|
97
177
|
end
|
98
|
-
|
178
|
+
|
99
179
|
describe '#test_framework' do
|
100
|
-
|
180
|
+
|
101
181
|
before do
|
102
182
|
@application = Application.new
|
103
183
|
end
|
104
|
-
|
184
|
+
|
105
185
|
it "should return the instance of Rspec when test framework is Rspec" do
|
106
186
|
@application.config.use :test_framework => :rspec
|
107
|
-
@application.test_framework.should be_instance_of(InfinityTest::Rspec)
|
187
|
+
@application.test_framework.should be_instance_of(InfinityTest::TestLibrary::Rspec)
|
108
188
|
end
|
109
189
|
|
110
190
|
it "should return the instance of Rspec when test framework is Rspec" do
|
111
191
|
@application.config.use :test_framework => :test_unit
|
112
|
-
@application.test_framework.should be_instance_of(InfinityTest::TestUnit)
|
192
|
+
@application.test_framework.should be_instance_of(InfinityTest::TestLibrary::TestUnit)
|
113
193
|
end
|
114
|
-
|
194
|
+
|
115
195
|
it "should pass all the rubies for the test_framework TestUnit" do
|
116
196
|
@application.config.use :test_framework => :test_unit, :rubies => ['1.9.1', '1.9.2']
|
117
|
-
TestUnit.should_receive(:new).with(:rubies => '1.9.1,1.9.2')
|
197
|
+
InfinityTest::TestLibrary::TestUnit.should_receive(:new).with(:rubies => '1.9.1,1.9.2')
|
118
198
|
@application.test_framework
|
119
199
|
end
|
120
200
|
|
121
201
|
it "should pass all the rubies for the test_framework Rspec" do
|
122
202
|
@application.config.use :test_framework => :rspec, :rubies => ['1.9.1', '1.9.2']
|
123
|
-
Rspec.should_receive(:new).with(:rubies => '1.9.1,1.9.2')
|
203
|
+
InfinityTest::TestLibrary::Rspec.should_receive(:new).with(:rubies => '1.9.1,1.9.2')
|
124
204
|
@application.test_framework
|
125
205
|
end
|
126
|
-
|
206
|
+
|
207
|
+
it "should pass the bacon framework too" do
|
208
|
+
@application.config.use :test_framework => :bacon
|
209
|
+
@application.test_framework.should be_instance_of(InfinityTest::TestLibrary::Bacon)
|
210
|
+
end
|
211
|
+
|
127
212
|
it "should cache the test framework instance" do
|
128
213
|
@application.config.use :test_framework => :rspec
|
129
214
|
test_framework = @application.test_framework
|
@@ -131,33 +216,38 @@ module InfinityTest
|
|
131
216
|
end
|
132
217
|
|
133
218
|
end
|
134
|
-
|
219
|
+
|
135
220
|
describe '#verbose?' do
|
136
221
|
|
137
222
|
it "should return to false when not set verbose" do
|
138
223
|
@application.verbose?.should equal false
|
139
224
|
end
|
140
|
-
|
225
|
+
|
141
226
|
it "should return true when set verbose to true" do
|
142
227
|
@application.config.verbose = true
|
143
228
|
@application.verbose?.should be_true
|
144
229
|
end
|
145
|
-
|
230
|
+
|
146
231
|
end
|
147
232
|
|
148
233
|
describe '#notify!' do
|
149
|
-
|
234
|
+
|
235
|
+
before do
|
236
|
+
@growl = Growl.new
|
237
|
+
end
|
238
|
+
|
150
239
|
it "should do nothing when not have notification framework" do
|
151
240
|
application.should_receive(:notification_framework).and_return(nil)
|
152
241
|
application.notify!(:results => '0 examples', :ruby_version => '1.9.2').should be_nil
|
153
242
|
end
|
154
|
-
|
243
|
+
|
155
244
|
it "should notify when have notification framework" do
|
156
245
|
application.config.notifications :growl
|
157
|
-
application.
|
246
|
+
application.should_receive(:growl).and_return(@growl)
|
247
|
+
@growl.should_receive(:notify!)
|
158
248
|
application.notify!(:results => '0 examples', :ruby_version => '1.8.7')
|
159
249
|
end
|
160
|
-
|
250
|
+
|
161
251
|
end
|
162
252
|
|
163
253
|
describe '#run!' do
|
@@ -168,25 +258,159 @@ module InfinityTest
|
|
168
258
|
application_with_rspec.before_callback.should_receive(:call)
|
169
259
|
run_the_command(application_with_rspec)
|
170
260
|
end
|
171
|
-
|
261
|
+
|
172
262
|
it "should call the after all callback" do
|
173
263
|
application_with_rspec.config.after(&block)
|
174
264
|
application_with_rspec.after_callback.should_receive(:call)
|
175
265
|
run_the_command(application_with_rspec)
|
176
266
|
end
|
177
|
-
|
267
|
+
|
178
268
|
it "should call the before each ruby callback" do
|
179
269
|
application_with_rspec.config.before(:each_ruby, &block)
|
180
270
|
application_with_rspec.before_each_ruby_callback.should_receive(:call)
|
181
271
|
run_the_command(application_with_rspec)
|
182
272
|
end
|
183
|
-
|
273
|
+
|
184
274
|
it "should call the after each ruby callback" do
|
185
275
|
application_with_rspec.config.after(:each_ruby, &block)
|
186
276
|
application_with_rspec.after_each_ruby_callback.should_receive(:call)
|
187
|
-
run_the_command(application_with_rspec)
|
277
|
+
run_the_command(application_with_rspec)
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
|
282
|
+
describe '#global_commands' do
|
283
|
+
|
284
|
+
it "should call construct commands and assign to the global_commands" do
|
285
|
+
@application.should_receive(:construct_commands).and_return(['rvm ...'])
|
286
|
+
@application.global_commands.should == ['rvm ...']
|
287
|
+
end
|
288
|
+
|
289
|
+
it "should cache the global_commands instance variable" do
|
290
|
+
expected = ['rvm 1.9.2']
|
291
|
+
@application.should_receive(:construct_commands).once.and_return(expected)
|
292
|
+
2. times { @application.global_commands.should equal expected }
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
describe '#run_global_commands!' do
|
298
|
+
|
299
|
+
it "should run with the global_commands instance variable command" do
|
300
|
+
@application.stub!(:global_commands).and_return('rvm 1.9.2 ruby -S rspec')
|
301
|
+
@application.should_receive(:run!).with(@application.global_commands).and_return(true)
|
302
|
+
@application.run_global_commands!
|
303
|
+
end
|
304
|
+
|
305
|
+
end
|
306
|
+
|
307
|
+
describe '#construct_commands' do
|
308
|
+
|
309
|
+
it "should call construct_commands on the test_framework" do
|
310
|
+
application.test_framework.should_receive(:construct_commands)
|
311
|
+
application.construct_commands
|
312
|
+
end
|
313
|
+
|
314
|
+
end
|
315
|
+
|
316
|
+
describe "#app framework" do
|
317
|
+
|
318
|
+
it "should return the instance of Rails when app framework is Rails" do
|
319
|
+
application_with_rails.app_framework.should be_instance_of(InfinityTest::ApplicationLibrary::Rails)
|
320
|
+
end
|
321
|
+
|
322
|
+
it "should return the instance of Rubygems when app framework is Rubygems" do
|
323
|
+
application_with_rubygems.app_framework.should be_instance_of(InfinityTest::ApplicationLibrary::RubyGems)
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
describe '#using_test_unit?' do
|
329
|
+
|
330
|
+
it "should return true when using Test::Unit" do
|
331
|
+
app = application_with_test_unit
|
332
|
+
app.using_test_unit?.should be_true
|
333
|
+
end
|
334
|
+
|
335
|
+
it "should return false when using Rspec" do
|
336
|
+
app = application_with_rspec
|
337
|
+
app.using_test_unit?.should be_false
|
188
338
|
end
|
189
|
-
|
339
|
+
|
340
|
+
end
|
341
|
+
|
342
|
+
describe '#run_commands_for_file' do
|
343
|
+
|
344
|
+
it "should run when have a file to run" do
|
345
|
+
@application.test_framework.should_receive(:construct_commands).and_return('rvm 1.9.2 ruby -S rspec')
|
346
|
+
@application.should_receive(:run!)
|
347
|
+
@application.run_commands_for_file('file.rb')
|
348
|
+
end
|
349
|
+
|
350
|
+
it "should not run when file is nil" do
|
351
|
+
@application.should_not_receive(:run!)
|
352
|
+
@application.run_commands_for_file(nil)
|
353
|
+
end
|
354
|
+
|
355
|
+
it "should not run when file is empty string" do
|
356
|
+
@application.should_not_receive(:run!)
|
357
|
+
@application.run_commands_for_file('')
|
358
|
+
end
|
359
|
+
|
360
|
+
end
|
361
|
+
|
362
|
+
describe '#files_to_run!' do
|
363
|
+
|
364
|
+
it "should return all files when option Hash key is :all" do
|
365
|
+
@application.files_to_run!(:all => 'spec_helper').should eql @application.all_test_files.join(' ')
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should return all files when options symbol is :all" do
|
369
|
+
@application.files_to_run!(:all => :files).should eql @application.all_test_files.join(' ')
|
370
|
+
end
|
371
|
+
|
372
|
+
it "should return the test file the matchs with changed logic file" do
|
373
|
+
match_data = /(infinity_test\/heuristics)/.match('infinity_test/heuristics') #<MatchData "infinity_test/heuristics" 1:"infinity_test/heuristics">
|
374
|
+
application_with_rspec.files_to_run!(:test_for => match_data).should include 'spec/infinity_test/heuristics_spec.rb'
|
375
|
+
end
|
376
|
+
|
377
|
+
it "should return the test file the match with the changed file" do
|
378
|
+
match_data = /(infinity_test\/application)/.match('infinity_test/application') #<MatchData "infinity_test/application" 1:"infinity_test/application">
|
379
|
+
application_with_rspec.files_to_run!(:test_for => match_data).should include 'spec/infinity_test/application_spec.rb'
|
380
|
+
end
|
381
|
+
|
382
|
+
it "should return the test file the matchs with the changed file when Test::Unit" do
|
383
|
+
match_data = /(infinity_test\/application)/.match('infinity_test/application') #<MatchData "infinity_test/application" 1:"infinity_test/application">
|
384
|
+
application_with_rspec.files_to_run!(:test_for => match_data).should include 'spec/infinity_test/application_spec.rb'
|
385
|
+
end
|
386
|
+
|
387
|
+
it "should return the test file the matchs with the changed file AND the dir specified" do
|
388
|
+
@application.should_receive(:all_test_files).and_return(["spec/addressbook/people_spec.rb", "spec/people_spec.rb"])
|
389
|
+
match_data = /(people_spec.rb)/.match('people_spec.rb')
|
390
|
+
@application.files_to_run!(:test_for => match_data, :in_dir => 'spec/addressbook').should == "spec/addressbook/people_spec.rb"
|
391
|
+
end
|
392
|
+
|
393
|
+
it "should return all the tests files in the Dir specified" do
|
394
|
+
@application.should_receive(:all_test_files).and_return(["spec/models/post_spec.rb", "spec/models/comment_spec.rb", "spec/people_spec.rb", "spec/controllers/posts_controller_spec.rb"])
|
395
|
+
@application.files_to_run!(:all => :files, :in_dir => 'spec/models').should == "spec/models/post_spec.rb spec/models/comment_spec.rb"
|
396
|
+
end
|
397
|
+
|
398
|
+
it "should return all the tests files in the dir specified as a symbol" do
|
399
|
+
@application.should_receive(:all_test_files).and_return(["spec/models/post_spec.rb", "spec/models/comment_spec.rb", "spec/people_spec.rb", "spec/controllers/posts_controller_spec.rb"])
|
400
|
+
@application.files_to_run!(:all => :files, :in_dir => :models).should == "spec/models/post_spec.rb spec/models/comment_spec.rb"
|
401
|
+
end
|
402
|
+
|
403
|
+
it "should return all the test files in all dirs specified" do
|
404
|
+
@application.should_receive(:all_test_files).and_return(['spec/models/post_spec.rb', 'spec/support/blueprints.rb', 'spec/controllers/comments_controller_spec.rb', 'spec/views/comments/index_spec.rb'])
|
405
|
+
@application.files_to_run!(:all => :files, :in_dir => [:models, :controllers]).should == 'spec/models/post_spec.rb spec/controllers/comments_controller_spec.rb'
|
406
|
+
end
|
407
|
+
|
408
|
+
it "should return all the test files that match with file changed in the dirs specified" do
|
409
|
+
@application.should_receive(:all_test_files).and_return(['spec/models/post_spec.rb', 'spec/controllers/post_controllers_spec.rb', 'spec/views/posts/index_spec.rb'])
|
410
|
+
match_data = /(post)/.match('post')
|
411
|
+
@application.files_to_run!(:test_for => match_data, :in_dir => [:models, :controllers]).should == 'spec/models/post_spec.rb spec/controllers/post_controllers_spec.rb'
|
412
|
+
end
|
413
|
+
|
190
414
|
end
|
191
415
|
|
192
416
|
end
|