infinity_test 1.0.3 → 2.0.0.rc1
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.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +31 -0
- data/.gitignore +3 -0
- data/.rspec +2 -2
- data/AI_INTEGRATION_IDEAS.md +203 -0
- data/Gemfile +3 -15
- data/History.markdown +82 -0
- data/{.infinity_test → INFINITY_TEST} +18 -15
- data/LICENSE.txt +2 -2
- data/README.md +627 -0
- data/Rakefile +1 -65
- data/TODO.markdown +24 -19
- data/bin/infinity_test +1 -4
- data/images/fuuu/pending.png +0 -0
- data/images/fuuu/success.png +0 -0
- data/infinity_test.gemspec +41 -189
- data/lib/infinity_test/core/auto_discover.rb +67 -0
- data/lib/infinity_test/core/base.rb +369 -0
- data/lib/infinity_test/core/callback.rb +59 -0
- data/lib/infinity_test/core/changed_file.rb +13 -0
- data/lib/infinity_test/core/command_builder.rb +48 -0
- data/lib/infinity_test/core/command_runner.rb +62 -0
- data/lib/infinity_test/core/configuration_merge.rb +37 -0
- data/lib/infinity_test/core/continuous_test_server.rb +106 -0
- data/lib/infinity_test/core/load_configuration.rb +48 -0
- data/lib/infinity_test/core/notifier.rb +59 -0
- data/lib/infinity_test/core/options.rb +134 -0
- data/lib/infinity_test/core/runner.rb +18 -0
- data/lib/infinity_test/core/version.rb +5 -0
- data/lib/infinity_test/framework/base.rb +57 -0
- data/lib/infinity_test/framework/padrino.rb +33 -0
- data/lib/infinity_test/framework/rails.rb +35 -0
- data/lib/infinity_test/framework/rubygems.rb +29 -0
- data/lib/infinity_test/framework/shared_example.rb +47 -0
- data/lib/infinity_test/observer/base.rb +40 -0
- data/lib/infinity_test/observer/filewatcher.rb +72 -0
- data/lib/infinity_test/observer/listen.rb +74 -0
- data/lib/infinity_test/observer/shared_example.rb +35 -0
- data/lib/infinity_test/old_dsl/configuration.rb +26 -0
- data/lib/infinity_test/strategy/base.rb +34 -0
- data/lib/infinity_test/strategy/rbenv.rb +32 -0
- data/lib/infinity_test/strategy/ruby_default.rb +20 -0
- data/lib/infinity_test/strategy/rvm.rb +50 -0
- data/lib/infinity_test/strategy/shared_example.rb +32 -0
- data/lib/infinity_test/test_framework/base.rb +64 -0
- data/lib/infinity_test/test_framework/rspec.rb +48 -0
- data/lib/infinity_test/test_framework/shared_example.rb +56 -0
- data/lib/infinity_test/test_framework/test_unit.rb +57 -0
- data/lib/infinity_test.rb +53 -35
- data/spec/infinity_test/core/auto_discover_spec.rb +149 -0
- data/spec/infinity_test/core/base_spec.rb +240 -0
- data/spec/infinity_test/core/callback_spec.rb +89 -0
- data/spec/infinity_test/core/changed_file_spec.rb +26 -0
- data/spec/infinity_test/core/command_builder_spec.rb +38 -0
- data/spec/infinity_test/core/configuration_merge_spec.rb +124 -0
- data/spec/infinity_test/core/continuous_test_server_spec.rb +116 -0
- data/spec/infinity_test/core/load_configuration_spec.rb +43 -0
- data/spec/infinity_test/core/notifier_spec.rb +151 -0
- data/spec/infinity_test/core/options_spec.rb +168 -0
- data/spec/infinity_test/core/runner_spec.rb +17 -0
- data/spec/infinity_test/framework/base_spec.rb +55 -0
- data/spec/infinity_test/framework/padrino_spec.rb +36 -0
- data/spec/infinity_test/framework/rails_spec.rb +36 -0
- data/spec/infinity_test/framework/rubygems_spec.rb +34 -0
- data/spec/infinity_test/observer/base_spec.rb +78 -0
- data/spec/infinity_test/observer/filewatcher_spec.rb +51 -0
- data/spec/infinity_test/observer/listen_spec.rb +50 -0
- data/spec/infinity_test/{builder_spec.rb → strategy/base_spec.rb} +1 -2
- data/spec/infinity_test/strategy/rbenv_spec.rb +53 -0
- data/spec/infinity_test/strategy/ruby_default_spec.rb +32 -0
- data/spec/infinity_test/strategy/rvm_spec.rb +69 -0
- data/spec/infinity_test/test_framework/rspec_spec.rb +119 -0
- data/spec/infinity_test/test_framework/test_unit_spec.rb +193 -0
- data/spec/spec_helper.rb +34 -119
- metadata +272 -176
- data/.rvmrc +0 -1
- data/Gemfile.lock +0 -62
- data/Readme.markdown +0 -147
- data/Tasks +0 -4
- data/VERSION.yml +0 -5
- data/buzz_images/buzz_lightyear.jpg +0 -0
- data/buzz_images/buzz_lightyear_continencia.gif +0 -0
- data/buzz_images/to_infinity_and_beyond.png +0 -0
- data/features/heuristics.feature +0 -23
- data/features/support/env.rb +0 -2
- data/images/fuuu/sucess.png +0 -0
- data/lib/infinity_test/application.rb +0 -362
- data/lib/infinity_test/application_library/rails.rb +0 -94
- data/lib/infinity_test/application_library/rubygems.rb +0 -43
- data/lib/infinity_test/binary_path.rb +0 -43
- data/lib/infinity_test/builder.rb +0 -66
- data/lib/infinity_test/command.rb +0 -58
- data/lib/infinity_test/configuration.rb +0 -277
- data/lib/infinity_test/continuous_testing.rb +0 -40
- data/lib/infinity_test/dependencies.rb +0 -80
- data/lib/infinity_test/environment.rb +0 -15
- data/lib/infinity_test/heuristics.rb +0 -36
- data/lib/infinity_test/heuristics_helper.rb +0 -9
- data/lib/infinity_test/options.rb +0 -96
- data/lib/infinity_test/runner.rb +0 -38
- data/lib/infinity_test/test_framework.rb +0 -110
- data/lib/infinity_test/test_library/bacon.rb +0 -55
- data/lib/infinity_test/test_library/cucumber.rb +0 -22
- data/lib/infinity_test/test_library/rspec.rb +0 -60
- data/lib/infinity_test/test_library/test_unit.rb +0 -52
- data/lib/infinity_test/test_unit_loader.rb +0 -5
- data/spec/factories/buzz/lib/buzz.rb +0 -0
- data/spec/factories/buzz/spec/buzz_spec.rb +0 -0
- data/spec/factories/company/Gemfile +0 -0
- data/spec/factories/company/lib/company.rb +0 -0
- data/spec/factories/company/test/company_test.rb +0 -0
- data/spec/factories/images/failure.png +0 -0
- data/spec/factories/images/pending.png +0 -0
- data/spec/factories/images/sucess.png +0 -0
- data/spec/factories/infinity_test +0 -5
- data/spec/factories/infinity_test_example +0 -7
- data/spec/factories/slinky/spec/slinky/slinky_spec.rb +0 -0
- data/spec/factories/travel/lib/travel.rb +0 -0
- data/spec/factories/travel/test/partner_test.rb +0 -0
- data/spec/factories/travel/test/travel_test.rb +0 -0
- data/spec/factories/wood/lib/wood.rb +0 -0
- data/spec/factories/wood/spec/wood_spec.rb +0 -0
- data/spec/infinity_test/application_library/rails_spec.rb +0 -140
- data/spec/infinity_test/application_library/rubygems_spec.rb +0 -52
- data/spec/infinity_test/application_spec.rb +0 -434
- data/spec/infinity_test/binary_path_spec.rb +0 -72
- data/spec/infinity_test/command_spec.rb +0 -53
- data/spec/infinity_test/configuration_spec.rb +0 -382
- data/spec/infinity_test/continuous_testing_spec.rb +0 -25
- data/spec/infinity_test/environment_spec.rb +0 -23
- data/spec/infinity_test/heuristics_helper_spec.rb +0 -15
- data/spec/infinity_test/heuristics_spec.rb +0 -127
- data/spec/infinity_test/options_spec.rb +0 -111
- data/spec/infinity_test/runner_spec.rb +0 -42
- data/spec/infinity_test/test_framework_spec.rb +0 -127
- data/spec/infinity_test/test_library/bacon_spec.rb +0 -150
- data/spec/infinity_test/test_library/cucumber_spec.rb +0 -8
- data/spec/infinity_test/test_library/rspec_spec.rb +0 -189
- data/spec/infinity_test/test_library/test_unit_spec.rb +0 -184
- data/spec/infinity_test_spec.rb +0 -40
- /data/images/faces/{sucess.png → success.png} +0 -0
- /data/images/hands/{sucess.png → success.png} +0 -0
- /data/images/mario_bros/{sucess.jpg → success.jpg} +0 -0
- /data/images/rails/{sucess.png → success.png} +0 -0
- /data/images/rubies/{sucess.png → success.png} +0 -0
- /data/images/simpson/{sucess.jpg → success.jpg} +0 -0
- /data/images/street_fighter/{sucess.jpg → success.jpg} +0 -0
- /data/images/toy_story/{sucess.png → success.png} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module InfinityTest
|
|
4
|
+
module Strategy
|
|
5
|
+
describe Rbenv do
|
|
6
|
+
let(:base) { BaseFixture.new(test_framework: :rspec) }
|
|
7
|
+
let(:continuous_test_server) { Core::ContinuousTestServer.new(base) }
|
|
8
|
+
subject { Rbenv.new(continuous_test_server) }
|
|
9
|
+
|
|
10
|
+
it_should_behave_like 'a infinity test strategy'
|
|
11
|
+
|
|
12
|
+
describe ".run?" do
|
|
13
|
+
let(:rbenv_dir) { File.expand_path('~/.rbenv') }
|
|
14
|
+
|
|
15
|
+
context "when rubies are specified" do
|
|
16
|
+
before do
|
|
17
|
+
allow(Core::Base).to receive(:rubies).and_return(['2.7.0', '3.0.0'])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "returns true if the user has rbenv installed" do
|
|
21
|
+
expect(File).to receive(:exist?).with(rbenv_dir).and_return(true)
|
|
22
|
+
expect(Rbenv).to be_run
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "returns false if the user does not have rbenv installed" do
|
|
26
|
+
expect(File).to receive(:exist?).with(rbenv_dir).and_return(false)
|
|
27
|
+
expect(Rbenv).not_to be_run
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "when no rubies are specified" do
|
|
32
|
+
before do
|
|
33
|
+
allow(Core::Base).to receive(:rubies).and_return([])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "returns false even if rbenv is installed" do
|
|
37
|
+
expect(Rbenv).not_to be_run
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#run!' do
|
|
43
|
+
before do
|
|
44
|
+
allow(Core::Base).to receive(:rubies).and_return(['2.7.0', '3.0.0'])
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'returns the command for multiple ruby versions' do
|
|
48
|
+
expect(subject.run!).to eq 'RBENV_VERSION=2.7.0 ruby -S rspec spec && RBENV_VERSION=3.0.0 ruby -S rspec spec'
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module InfinityTest
|
|
4
|
+
module Strategy
|
|
5
|
+
describe RubyDefault do
|
|
6
|
+
let(:base) { BaseFixture.new }
|
|
7
|
+
let(:continuous_test_server) { Core::ContinuousTestServer.new(base) }
|
|
8
|
+
subject { RubyDefault.new(continuous_test_server) }
|
|
9
|
+
it_should_behave_like 'a infinity test strategy'
|
|
10
|
+
|
|
11
|
+
describe ".run?" do
|
|
12
|
+
it "returns true when no ruby versions are passed to run tests" do
|
|
13
|
+
allow(Core::Base).to receive(:rubies).and_return([])
|
|
14
|
+
expect(RubyDefault).to be_run
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "returns false when some ruby version is passed to run tests" do
|
|
18
|
+
allow(Core::Base).to receive(:rubies).and_return(['ree', 'jruby'])
|
|
19
|
+
expect(RubyDefault).not_to be_run
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#run!' do
|
|
24
|
+
before { base.test_framework = :rspec }
|
|
25
|
+
|
|
26
|
+
it 'returns the command' do
|
|
27
|
+
expect(subject.run!).to eq 'ruby -S rspec spec'
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module InfinityTest
|
|
4
|
+
module Strategy
|
|
5
|
+
describe Rvm do
|
|
6
|
+
let(:base) { BaseFixture.new(test_framework: :rspec) }
|
|
7
|
+
let(:continuous_test_server) { Core::ContinuousTestServer.new(base) }
|
|
8
|
+
subject { Rvm.new(continuous_test_server) }
|
|
9
|
+
|
|
10
|
+
it_should_behave_like 'a infinity test strategy'
|
|
11
|
+
|
|
12
|
+
describe ".run?" do
|
|
13
|
+
context "when rubies are specified" do
|
|
14
|
+
before do
|
|
15
|
+
allow(Core::Base).to receive(:rubies).and_return(['2.7.0', '3.0.0'])
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "returns true if the user has RVM installed in users home" do
|
|
19
|
+
expect(Rvm).to receive(:installed_users_home?).and_return(true)
|
|
20
|
+
expect(Rvm).to be_run
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "returns true if the user has RVM installed system wide" do
|
|
24
|
+
expect(Rvm).to receive(:installed_users_home?).and_return(false)
|
|
25
|
+
expect(Rvm).to receive(:installed_system_wide?).and_return(true)
|
|
26
|
+
expect(Rvm).to be_run
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "returns false if the user does not have RVM installed" do
|
|
30
|
+
expect(Rvm).to receive(:installed_users_home?).and_return(false)
|
|
31
|
+
expect(Rvm).to receive(:installed_system_wide?).and_return(false)
|
|
32
|
+
expect(Rvm).not_to be_run
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "when no rubies are specified" do
|
|
37
|
+
before do
|
|
38
|
+
allow(Core::Base).to receive(:rubies).and_return([])
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "returns false even if RVM is installed" do
|
|
42
|
+
expect(Rvm).not_to be_run
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe '#run!' do
|
|
48
|
+
before do
|
|
49
|
+
allow(Core::Base).to receive(:rubies).and_return(['2.7.0', '3.0.0'])
|
|
50
|
+
allow(Core::Base).to receive(:gemset).and_return(nil)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'returns the command for multiple ruby versions' do
|
|
54
|
+
expect(subject.run!).to eq 'rvm 2.7.0 do ruby -S rspec spec && rvm 3.0.0 do ruby -S rspec spec'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context 'with gemset' do
|
|
58
|
+
before do
|
|
59
|
+
allow(Core::Base).to receive(:gemset).and_return('infinity_test')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'includes gemset in the command' do
|
|
63
|
+
expect(subject.run!).to eq 'rvm 2.7.0@infinity_test do ruby -S rspec spec && rvm 3.0.0@infinity_test do ruby -S rspec spec'
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module InfinityTest
|
|
4
|
+
module TestFramework
|
|
5
|
+
describe Rspec do
|
|
6
|
+
it_should_behave_like 'a infinity test test framework'
|
|
7
|
+
|
|
8
|
+
describe "#test_dir" do
|
|
9
|
+
it "returns spec as test dir" do
|
|
10
|
+
expect(subject.test_dir).to eq 'spec'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '#test_files' do
|
|
15
|
+
context 'when is empty' do
|
|
16
|
+
it 'returns the test dir' do
|
|
17
|
+
expect(subject.test_files).to eq 'spec'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'when assign the test files' do
|
|
22
|
+
it 'returns the assigned value' do
|
|
23
|
+
subject.test_files = 'framework/base_spec.rb'
|
|
24
|
+
expect(subject.test_files).to eq 'framework/base_spec.rb'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "#test_helper_file" do
|
|
30
|
+
it "is the spec helper" do
|
|
31
|
+
expect(subject.test_helper_file).to eq 'spec/spec_helper.rb'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "#binary" do
|
|
36
|
+
it "returns rspec as binary" do
|
|
37
|
+
expect(subject.binary).to eq 'rspec'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe '#test_message' do
|
|
42
|
+
subject(:rspec) { Rspec.new }
|
|
43
|
+
|
|
44
|
+
it 'returns the final specs results' do
|
|
45
|
+
rspec.test_message = "Finished in 2.19 seconds\n\e[33m162 examples, 0 failures, 8 pending\e[0m\n"
|
|
46
|
+
expect(rspec.test_message).to eq '162 examples, 0 failures, 8 pending'
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '#success?' do
|
|
51
|
+
subject(:rspec) { Rspec.new }
|
|
52
|
+
|
|
53
|
+
context 'when is test message with ZERO failures and ZERO pending' do
|
|
54
|
+
before do
|
|
55
|
+
rspec.test_message = "162 examples, 0 failures, 0 pending"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'returns true' do
|
|
59
|
+
expect(rspec).to be_success
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context 'when is test message with ONE failure and ZERO pending' do
|
|
64
|
+
before do
|
|
65
|
+
rspec.test_message = "162 examples, 1 failures, 0 pending"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'returns false' do
|
|
69
|
+
expect(rspec).to_not be_success
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context 'when is test message with ZERO failures and ONE pending' do
|
|
74
|
+
before do
|
|
75
|
+
rspec.test_message = "162 examples, 0 failures, 1 pending"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'returns false' do
|
|
79
|
+
expect(rspec).to_not be_success
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe '#failure?' do
|
|
85
|
+
subject(:rspec) { Rspec.new }
|
|
86
|
+
|
|
87
|
+
context 'when is test message with ONE failure and ZERO pending' do
|
|
88
|
+
before do
|
|
89
|
+
rspec.test_message = "162 examples, 1 failures, 0 pending"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'returns true' do
|
|
93
|
+
expect(rspec).to be_failure
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context 'when is test message with ZERO failures and ZERO pending' do
|
|
98
|
+
before do
|
|
99
|
+
rspec.test_message = "162 examples, 0 failures, 0 pending"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'returns false' do
|
|
103
|
+
expect(rspec).to_not be_failure
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context 'when is test message with ZERO failures and ONE pending' do
|
|
108
|
+
before do
|
|
109
|
+
rspec.test_message = "162 examples, 0 failures, 1 pending"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'returns false' do
|
|
113
|
+
expect(rspec).to_not be_failure
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module InfinityTest
|
|
4
|
+
module TestFramework
|
|
5
|
+
describe TestUnit do
|
|
6
|
+
it_should_behave_like 'a infinity test test framework'
|
|
7
|
+
|
|
8
|
+
describe "#test_dir" do
|
|
9
|
+
it "returns test as test dir" do
|
|
10
|
+
expect(subject.test_dir).to eq 'test'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "can be set to a custom directory" do
|
|
14
|
+
subject.test_dir = 'custom_test'
|
|
15
|
+
expect(subject.test_dir).to eq 'custom_test'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#test_files' do
|
|
20
|
+
context 'when is empty' do
|
|
21
|
+
it 'returns the test dir' do
|
|
22
|
+
expect(subject.test_files).to eq 'test'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context 'when assign the test files' do
|
|
27
|
+
it 'returns the assigned value' do
|
|
28
|
+
subject.test_files = 'test/models/user_test.rb'
|
|
29
|
+
expect(subject.test_files).to eq 'test/models/user_test.rb'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "#test_helper_file" do
|
|
35
|
+
it "is the test helper" do
|
|
36
|
+
expect(subject.test_helper_file).to eq 'test/test_helper.rb'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '#binary' do
|
|
41
|
+
it 'returns ruby as binary' do
|
|
42
|
+
expect(subject.binary).to eq 'ruby'
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#test_message' do
|
|
47
|
+
subject(:test_unit) { TestUnit.new }
|
|
48
|
+
|
|
49
|
+
it 'returns the final test results' do
|
|
50
|
+
test_unit.test_message = "Finished in 0.001s, 1000.0 runs/s.\n10 runs, 15 assertions, 0 failures, 0 errors, 0 skips\n"
|
|
51
|
+
expect(test_unit.test_message).to eq '10 runs, 15 assertions, 0 failures, 0 errors, 0 skips'
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe '#success?' do
|
|
56
|
+
subject(:test_unit) { TestUnit.new }
|
|
57
|
+
|
|
58
|
+
context 'when test message has ZERO failures, ZERO errors, and ZERO skips' do
|
|
59
|
+
before do
|
|
60
|
+
test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 0 skips"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'returns true' do
|
|
64
|
+
expect(test_unit).to be_success
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context 'when test message has ONE failure' do
|
|
69
|
+
before do
|
|
70
|
+
test_unit.test_message = "10 runs, 15 assertions, 1 failures, 0 errors, 0 skips"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'returns false' do
|
|
74
|
+
expect(test_unit).to_not be_success
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context 'when test message has ONE error' do
|
|
79
|
+
before do
|
|
80
|
+
test_unit.test_message = "10 runs, 15 assertions, 0 failures, 1 errors, 0 skips"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'returns false' do
|
|
84
|
+
expect(test_unit).to_not be_success
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
context 'when test message has ONE skip' do
|
|
89
|
+
before do
|
|
90
|
+
test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 1 skips"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'returns false' do
|
|
94
|
+
expect(test_unit).to_not be_success
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe '#failure?' do
|
|
100
|
+
subject(:test_unit) { TestUnit.new }
|
|
101
|
+
|
|
102
|
+
context 'when test message has ONE failure' do
|
|
103
|
+
before do
|
|
104
|
+
test_unit.test_message = "10 runs, 15 assertions, 1 failures, 0 errors, 0 skips"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'returns true' do
|
|
108
|
+
expect(test_unit).to be_failure
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
context 'when test message has ONE error' do
|
|
113
|
+
before do
|
|
114
|
+
test_unit.test_message = "10 runs, 15 assertions, 0 failures, 1 errors, 0 skips"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'returns true' do
|
|
118
|
+
expect(test_unit).to be_failure
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
context 'when test message has ZERO failures and ZERO errors' do
|
|
123
|
+
before do
|
|
124
|
+
test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 0 skips"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'returns false' do
|
|
128
|
+
expect(test_unit).to_not be_failure
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe '#pending?' do
|
|
134
|
+
subject(:test_unit) { TestUnit.new }
|
|
135
|
+
|
|
136
|
+
context 'when test message has ONE skip' do
|
|
137
|
+
before do
|
|
138
|
+
test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 1 skips"
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it 'returns true' do
|
|
142
|
+
expect(test_unit).to be_pending
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
context 'when test message has ZERO skips' do
|
|
147
|
+
before do
|
|
148
|
+
test_unit.test_message = "10 runs, 15 assertions, 0 failures, 0 errors, 0 skips"
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'returns false' do
|
|
152
|
+
expect(test_unit).to_not be_pending
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
describe '.run?' do
|
|
158
|
+
context 'when test directory exists with test files' do
|
|
159
|
+
before do
|
|
160
|
+
allow(File).to receive(:exist?).with('test').and_return(true)
|
|
161
|
+
allow(File).to receive(:exist?).with('test/test_helper.rb').and_return(true)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it 'returns true' do
|
|
165
|
+
expect(TestUnit.run?).to be true
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
context 'when test directory exists with *_test.rb files' do
|
|
170
|
+
before do
|
|
171
|
+
allow(File).to receive(:exist?).with('test').and_return(true)
|
|
172
|
+
allow(File).to receive(:exist?).with('test/test_helper.rb').and_return(false)
|
|
173
|
+
allow(Dir).to receive(:[]).with('test/**/*_test.rb').and_return(['test/user_test.rb'])
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it 'returns true' do
|
|
177
|
+
expect(TestUnit.run?).to be true
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
context 'when test directory does not exist' do
|
|
182
|
+
before do
|
|
183
|
+
allow(File).to receive(:exist?).with('test').and_return(false)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it 'returns false' do
|
|
187
|
+
expect(TestUnit.run?).to be false
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,132 +1,47 @@
|
|
|
1
|
+
if ENV['COVERAGE']
|
|
2
|
+
require 'simplecov'
|
|
3
|
+
SimpleCov.start do
|
|
4
|
+
add_filter 'spec'
|
|
5
|
+
add_filter 'shared_example'
|
|
6
|
+
end
|
|
7
|
+
end
|
|
1
8
|
|
|
2
9
|
require 'infinity_test'
|
|
3
|
-
require '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# add_filter '/spec'
|
|
7
|
-
# add_filter './.infinity_test'
|
|
8
|
-
# end
|
|
10
|
+
require 'ostruct'
|
|
11
|
+
require 'bundler/setup'
|
|
12
|
+
Bundler.require
|
|
9
13
|
|
|
10
14
|
RSpec.configure do |config|
|
|
15
|
+
config.include InfinityTest::Strategy::SharedExample
|
|
16
|
+
config.include InfinityTest::Observer::SharedExample
|
|
17
|
+
config.include InfinityTest::TestFramework::SharedExample
|
|
18
|
+
config.include InfinityTest::Framework::SharedExample
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def stub_application_with_test_unit
|
|
17
|
-
InfinityTest.stub!(:application).and_return(application_with_test_unit)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def application_with(options)
|
|
21
|
-
application = InfinityTest::Application.new
|
|
22
|
-
application.config.use(options)
|
|
23
|
-
application
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def application_with_rspec
|
|
27
|
-
application_with(:test_framework => :rspec)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def application_with_test_unit
|
|
31
|
-
application_with(:test_framework => :test_unit)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def application_with_rails
|
|
35
|
-
application_with(:app_framework => :rails)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def application_with_rubygems
|
|
39
|
-
application_with(:app_framework => :rubygems)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def application_with_growl
|
|
43
|
-
application = InfinityTest::Application.new
|
|
44
|
-
application.config.notifications :growl
|
|
45
|
-
application
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def new_application(options)
|
|
49
|
-
application = InfinityTest::Application.new
|
|
50
|
-
application.config.notifications options[:notifications] if options[:notifications]
|
|
51
|
-
application.config.use(options) if options
|
|
52
|
-
application
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def continuous_testing_with(application)
|
|
56
|
-
InfinityTest::ContinuousTesting.new(:application => application)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def image(basename)
|
|
60
|
-
File.expand_path(File.join(File.dirname(__FILE__), '..', 'images', basename))
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def custom_image(basename)
|
|
64
|
-
File.expand_path(File.join(File.dirname(__FILE__), 'factories', basename))
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def custom_image_dir
|
|
68
|
-
File.expand_path(File.join(File.dirname(__FILE__), 'factories', 'images'))
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def run_the_command(app)
|
|
72
|
-
command = mock(InfinityTest::Command)
|
|
73
|
-
command.should_receive(:results).at_least(:once).and_return('0 examples, 0 failures')
|
|
74
|
-
app.should_receive(:say_the_ruby_version_and_run_the_command!).at_least(:once).and_return(command)
|
|
75
|
-
app.should_receive(:notify!).and_return(nil)
|
|
76
|
-
app.run!(['spec'])
|
|
77
|
-
end
|
|
20
|
+
config.filter_run focus: true
|
|
21
|
+
config.run_all_when_everything_filtered = true
|
|
78
22
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def factory_buzz_gemfile
|
|
84
|
-
File.expand_path(File.join(File.dirname(__FILE__), 'factories', 'buzz', 'Gemfile'))
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def current_env
|
|
88
|
-
@current_env ||= RVM::Environment.current
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def environment_name
|
|
92
|
-
@environment_name ||= current_env.environment_name
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def application_with_gemfile(application)
|
|
96
|
-
application.should_receive(:have_gemfile?).and_return(true)
|
|
97
|
-
application.should_receive(:skip_bundler?).and_return(false)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def application_without_gemfile(application)
|
|
101
|
-
application.should_receive(:have_gemfile?).and_return(false)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
# Factories! Or Fixtures - Whathever
|
|
105
|
-
|
|
106
|
-
def buzz_library(&block)
|
|
107
|
-
factories_for('buzz', &block)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def wood_library(&block)
|
|
111
|
-
factories_for('wood', &block)
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def slinky_library(&block)
|
|
115
|
-
factories_for('slinky', &block)
|
|
23
|
+
config.expect_with :rspec do |c|
|
|
24
|
+
c.syntax = :expect
|
|
116
25
|
end
|
|
26
|
+
end
|
|
117
27
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
end
|
|
28
|
+
class BaseFixture
|
|
29
|
+
attr_accessor :strategy, :test_framework, :framework
|
|
121
30
|
|
|
122
|
-
def
|
|
123
|
-
|
|
31
|
+
def initialize(options={})
|
|
32
|
+
@strategy = options[:strategy]
|
|
33
|
+
@framework = options[:framework]
|
|
34
|
+
@test_framework = options[:test_framework]
|
|
124
35
|
end
|
|
125
|
-
|
|
126
36
|
end
|
|
127
37
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
38
|
+
# Replacement for deprecated silence_stream from ActiveSupport
|
|
39
|
+
def silence_stream(stream)
|
|
40
|
+
old_stream = stream.dup
|
|
41
|
+
stream.reopen(File::NULL)
|
|
42
|
+
stream.sync = true
|
|
43
|
+
yield
|
|
44
|
+
ensure
|
|
45
|
+
stream.reopen(old_stream)
|
|
46
|
+
old_stream.close
|
|
132
47
|
end
|