infinity_test 0.2.0 → 1.0.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.
Files changed (72) hide show
  1. data/.gitignore +3 -0
  2. data/.infinity_test +30 -2
  3. data/.rspec +2 -0
  4. data/.rvmrc +1 -1
  5. data/Gemfile +10 -2
  6. data/Gemfile.lock +52 -12
  7. data/History.markdown +86 -2
  8. data/LICENSE.txt +22 -0
  9. data/Rakefile +25 -9
  10. data/Readme.markdown +47 -23
  11. data/TODO.markdown +12 -0
  12. data/Tasks +2 -3
  13. data/VERSION.yml +2 -2
  14. data/bin/infinity_test +1 -1
  15. data/features/heuristics.feature +23 -0
  16. data/features/support/env.rb +2 -0
  17. data/images/fuuu/failure.png +0 -0
  18. data/images/fuuu/pending.png +0 -0
  19. data/images/fuuu/sucess.png +0 -0
  20. data/infinity_test.gemspec +62 -29
  21. data/lib/infinity_test.rb +29 -9
  22. data/lib/infinity_test/application.rb +222 -68
  23. data/lib/infinity_test/application_library/rails.rb +94 -0
  24. data/lib/infinity_test/application_library/rubygems.rb +43 -0
  25. data/lib/infinity_test/binary_path.rb +30 -8
  26. data/lib/infinity_test/builder.rb +56 -0
  27. data/lib/infinity_test/command.rb +18 -24
  28. data/lib/infinity_test/configuration.rb +96 -44
  29. data/lib/infinity_test/continuous_testing.rb +17 -39
  30. data/lib/infinity_test/dependencies.rb +76 -41
  31. data/lib/infinity_test/environment.rb +15 -0
  32. data/lib/infinity_test/heuristics.rb +36 -0
  33. data/lib/infinity_test/heuristics_helper.rb +9 -0
  34. data/lib/infinity_test/options.rb +56 -19
  35. data/lib/infinity_test/runner.rb +25 -17
  36. data/lib/infinity_test/test_framework.rb +109 -0
  37. data/lib/infinity_test/test_library/bacon.rb +55 -0
  38. data/lib/infinity_test/test_library/cucumber.rb +22 -0
  39. data/lib/infinity_test/test_library/rspec.rb +58 -0
  40. data/lib/infinity_test/test_library/test_unit.rb +46 -0
  41. data/spec/factories/company/Gemfile +0 -0
  42. data/spec/factories/infinity_test_example +2 -2
  43. data/spec/infinity_test/application_library/rails_spec.rb +140 -0
  44. data/spec/infinity_test/application_library/rubygems_spec.rb +52 -0
  45. data/spec/infinity_test/application_spec.rb +274 -50
  46. data/spec/infinity_test/binary_path_spec.rb +72 -0
  47. data/spec/infinity_test/builder_spec.rb +7 -0
  48. data/spec/infinity_test/command_spec.rb +13 -14
  49. data/spec/infinity_test/configuration_spec.rb +183 -57
  50. data/spec/infinity_test/continuous_testing_spec.rb +19 -1
  51. data/spec/infinity_test/environment_spec.rb +23 -0
  52. data/spec/infinity_test/heuristics_helper_spec.rb +15 -0
  53. data/spec/infinity_test/heuristics_spec.rb +127 -0
  54. data/spec/infinity_test/options_spec.rb +48 -26
  55. data/spec/infinity_test/runner_spec.rb +37 -29
  56. data/spec/infinity_test/test_framework_spec.rb +127 -0
  57. data/spec/infinity_test/test_library/bacon_spec.rb +150 -0
  58. data/spec/infinity_test/test_library/cucumber_spec.rb +8 -0
  59. data/spec/infinity_test/test_library/rspec_spec.rb +185 -0
  60. data/spec/infinity_test/test_library/test_unit_spec.rb +184 -0
  61. data/spec/infinity_test_spec.rb +23 -12
  62. data/spec/spec_helper.rb +86 -30
  63. metadata +62 -32
  64. data/lib/infinity_test/notifications/growl.rb +0 -15
  65. data/lib/infinity_test/notifications/lib_notify.rb +0 -11
  66. data/lib/infinity_test/rspec.rb +0 -87
  67. data/lib/infinity_test/test_unit.rb +0 -74
  68. data/spec/infinity_test/notifications/growl_spec.rb +0 -9
  69. data/spec/infinity_test/notifications/lib_notify_spec.rb +0 -9
  70. data/spec/infinity_test/rspec_spec.rb +0 -189
  71. data/spec/infinity_test/test_unit_spec.rb +0 -182
  72. data/spec/spec.opts +0 -1
@@ -2,6 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  module InfinityTest
4
4
  describe ContinuousTesting do
5
+ let(:continuous_testing) { ContinuousTesting.new }
6
+ it "should keep the application object" do
7
+ continuous_testing.application.should equal InfinityTest.application
8
+ end
9
+
10
+ it "should keep the watchr object" do
11
+ continuous_testing.watchr.should equal InfinityTest.watchr
12
+ end
13
+
14
+ describe '#initialize_watchr!' do
15
+
16
+ it "should call add_signal and run_with_watchr!" do
17
+ continuous_testing.should_receive(:add_signal)
18
+ continuous_testing.should_receive(:run_with_watchr!)
19
+ continuous_testing.initialize_watchr!
20
+ end
21
+
22
+ end
5
23
 
6
24
  end
7
- end
25
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe Environment do
5
+ include Environment
6
+ describe '#environments' do
7
+ it "should raise a exception if not passed a block" do
8
+ expect { environments }.should raise_exception
9
+ end
10
+
11
+ it "should run in the scope of RVM environment" do
12
+ pending
13
+ expect {
14
+ environments do |environment, ruby_version|
15
+ environment.should be_instance_of(RVM::Environment)
16
+ end
17
+ }.to_not raise_exception
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe HeuristicsHelper do
5
+ include HeuristicsHelper
6
+
7
+ describe '#heuristics' do
8
+ it "should be instance of InfinityTest Heuristics" do
9
+ heuristics do
10
+ end.should be_instance_of(InfinityTest::Heuristics)
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,127 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+ describe Heuristics do
5
+
6
+ before do
7
+ @application = application_with_rspec
8
+ InfinityTest.stub!(:watchr).and_return(Watchr::Script.new)
9
+ InfinityTest.stub!(:application).and_return(@application)
10
+ @heuristics = Heuristics.new
11
+ end
12
+
13
+ describe '#initialize' do
14
+
15
+ it "should create the patterns instance of Hash" do
16
+ @heuristics.patterns.should be_instance_of(Hash)
17
+ end
18
+
19
+ it "should create the script instance variable" do
20
+ @heuristics.script.should be_instance_of(Watchr::Script)
21
+ end
22
+
23
+ it "should have empty rules" do
24
+ @heuristics.script.rules.should be_empty
25
+ end
26
+
27
+ end
28
+
29
+ describe '#add' do
30
+
31
+ it "should add the watch method and persist the pattern" do
32
+ @heuristics.add("^lib/*/(.*)\.rb")
33
+ @heuristics.script.rules.should have(1).items
34
+ end
35
+
36
+ it "should add the pattern to #patterns instance" do
37
+ @heuristics.add(/^(test|spec)\/fixtures\/(.*).yml$/)
38
+ @heuristics.should have_pattern(/^(test|spec)\/fixtures\/(.*).yml$/)
39
+ end
40
+
41
+ it "should add other pattern to #patterns instance" do
42
+ @heuristics.add("^lib/*/(.*)\.rb")
43
+ @heuristics.should have_pattern("^lib/*/(.*)\.rb")
44
+ end
45
+
46
+ it "should add the block object to #patterns instance" do
47
+ proc = Proc.new { 'a' }
48
+ @heuristics.add("^lib/*/(.*)\.rb", &proc)
49
+ @heuristics.patterns.should have_value(proc)
50
+ end
51
+
52
+ end
53
+
54
+ describe '#all' do
55
+
56
+ it "should return all the patterns" do
57
+ @heuristics.add('^lib/*_spec.rb')
58
+ @heuristics.all.should eql ['^lib/*_spec.rb']
59
+ end
60
+
61
+ it "should return all the patterns the InfinityTest will watch" do
62
+ @heuristics.add('^config/application.rb')
63
+ @heuristics.add('^spec/spec_helper.rb')
64
+ @heuristics.all.should have(2).items
65
+ end
66
+
67
+ it "should include all the patterns the InfinityTest will watch each" do
68
+ @heuristics.add '^config/application.rb'
69
+ @heuristics.add '^spec/spec_helper.rb'
70
+ all = @heuristics.all
71
+ all.should include '^config/application.rb'
72
+ all.should include '^spec/spec_helper.rb'
73
+ end
74
+
75
+ end
76
+
77
+ describe '#run' do
78
+
79
+ let(:binary_path_match_data) { match_data = /(infinity_test\/binary_path)/.match('infinity_test/binary_path') }
80
+
81
+ it "should call the contruct commands for test file" do
82
+ @application.should_receive(:run_commands_for_file).with('spec/infinity_test/binary_path_spec.rb')
83
+ @heuristics.run(:test_for => binary_path_match_data)
84
+ end
85
+
86
+ it "should run all the test files" do
87
+ @application.should_receive(:run_commands_for_file).with(@application.all_test_files.join(' '))
88
+ @heuristics.run(:all => :files)
89
+ end
90
+
91
+ end
92
+
93
+ describe '#remove' do
94
+
95
+ before do
96
+ @heuristics.add('^lib/*/(.*)_spec.rb')
97
+ @heuristics.add('^spec/*/(.*)_spec.rb')
98
+ end
99
+
100
+ it { @heuristics.patterns.should have(2).items }
101
+
102
+ it { @heuristics.script.rules.should have(2).items }
103
+
104
+ it "should remove the pattern from patterns" do
105
+ @heuristics.remove('^lib/*/(.*)_spec.rb')
106
+ @heuristics.should_not have_pattern('^lib/*/(.*)_spec.rb')
107
+ end
108
+
109
+ it "should remove the rules from watchr" do
110
+ @heuristics.remove('^lib/*/(.*)_spec.rb')
111
+ @heuristics.script.rules.should have(1).items
112
+ end
113
+
114
+ it "should remove all the rules from watchr" do
115
+ @heuristics.remove :all
116
+ @heuristics.script.rules.should be_empty
117
+ end
118
+
119
+ it "should remove all the patterns" do
120
+ @heuristics.remove :all
121
+ @heuristics.patterns.should be_empty
122
+ end
123
+
124
+ end
125
+
126
+ end
127
+ end
@@ -2,68 +2,90 @@ require 'spec_helper'
2
2
 
3
3
  module InfinityTest
4
4
  describe Options do
5
-
5
+
6
6
  context "when parsing" do
7
-
7
+
8
8
  it "should parse --rspec and return rspec" do
9
9
  parse_options('--rspec')
10
10
  @options[:test_framework].should equal :rspec
11
11
  end
12
-
12
+
13
13
  it "should not return rspec as test framework when not parse rspec" do
14
14
  parse_options('--test-unit')
15
15
  @options[:test_framework].should_not equal :rspec
16
16
  end
17
-
17
+
18
+ it "should parse --bacon and return bacon" do
19
+ parse_options('--bacon')
20
+ @options[:test_framework].should equal :bacon
21
+ end
22
+
23
+ it "should not parse --test-unit" do
24
+ parse_options('--rspec')
25
+ @options[:test_framework].should_not equal :bacon
26
+ end
27
+
18
28
  it "should parse --test-unit and return test_unit" do
19
29
  parse_options('--test-unit')
20
30
  @options[:test_framework].should equal :test_unit
21
31
  end
22
-
32
+
23
33
  it "should not parse --test-unit" do
24
34
  parse_options('--rspec')
25
35
  @options[:test_framework].should_not equal :test_unit
26
36
  end
27
-
37
+
28
38
  it "should parse --rvm-versions and return an array" do
29
39
  parse_options('--rubies=1.8.6,1.8.7')
30
40
  @options[:rubies].should eql '1.8.6,1.8.7'
31
41
  end
32
-
42
+
33
43
  it "should parse --rvm-versions with dashes" do
34
44
  parse_options('--rubies=1.8.7-p249,1.9.1-p378')
35
45
  @options[:rubies].should eql '1.8.7-p249,1.9.1-p378'
36
46
  end
37
-
47
+
38
48
  it "should parse --verbose" do
39
49
  parse_options('--verbose')
40
50
  @options[:verbose].should be_true
41
51
  end
42
-
43
- end
44
52
 
45
- describe "#rspec?" do
53
+ it "should parse --skip-bundler" do
54
+ parse_options('--skip-bundler')
55
+ @options[:skip_bundler?].should be_true
56
+ end
46
57
 
47
- it "should return true if using rspec" do
48
- parse_options('--rspec')
49
- @options.rspec?.should be_true
58
+ it "should return false for --skip-bundler option" do
59
+ parse_options('--rails')
60
+ @options[:skip_bundler?].should be_false
50
61
  end
51
-
52
- it "should explicity return false if not using rspec" do
53
- parse_options('--test-unit')
54
- @options.rspec?.should be_false
62
+
63
+ it "should return rails as app framework when parse rails" do
64
+ parse_options('--rails')
65
+ @options[:app_framework].should equal :rails
55
66
  end
56
-
57
- it "should not return nil when not using rspec" do
58
- parse_options('--rubies=1.8.6')
59
- @options.rspec?.should_not be_nil
67
+
68
+ it "should return rubygems as app framework when parse rubygems" do
69
+ parse_options('--rubygems')
70
+ @options[:app_framework].should equal :rubygems
60
71
  end
61
-
72
+
73
+ it "should parse the cucumber option" do
74
+ pending
75
+ parse_options('--cucumber')
76
+ @options[:cucumber].should be_true
77
+ end
78
+
79
+ it "should parse the patterns options" do
80
+ parse_options('--heuristics')
81
+ @options[:show_heuristics?].should be_true
82
+ end
83
+
62
84
  end
63
-
85
+
64
86
  def parse_options(*arguments)
65
87
  @options = InfinityTest::Options.new(arguments)
66
88
  end
67
-
89
+
68
90
  end
69
- end
91
+ end
@@ -1,34 +1,42 @@
1
1
  require 'spec_helper'
2
2
 
3
- module InfinityTest
4
- describe Runner do
5
-
6
- let(:runner_class) { InfinityTest::Runner }
7
-
8
- context "on default values" do
9
-
10
- it "commands should have a empty Array" do
11
- runner_class.new({:test_framework => :rspec}).commands.should eql []
12
- end
13
-
14
- it "should set the application object" do
15
- runner_class.new({:test_framework => :test_unit}).application.should be_instance_of(Application)
16
- end
17
-
3
+ describe InfinityTest::Runner do
4
+
5
+ let(:runner_class) { InfinityTest::Runner }
6
+
7
+ describe '#initialize' do
8
+
9
+ it "should set the application object" do
10
+ runner_class.new(['--test-unit']).application.should be_instance_of(InfinityTest::Application)
11
+ end
12
+
13
+ it "should set the Option Object" do
14
+ runner_class.new(['--rspec']).options.should be_instance_of(InfinityTest::Options)
15
+ end
16
+
17
+ end
18
+
19
+ describe '#run!' do
20
+ let(:heuristics_runner) { runner_class.new(['--heuristics']) }
21
+
22
+ it "should call list heuristics" do
23
+ heuristics_runner.should_receive(:list_heuristics!)
24
+ heuristics_runner.run!
18
25
  end
19
-
20
- describe "#start_continuous_testing!" do
21
- let(:empty_runner) { InfinityTest::Runner.new({}) }
22
- let(:mock_continuous_testing) { @mock ||= mock(ContinuousTesting) }
23
-
24
- it "should call start for Continuous Testing" do
25
- application = application_with_rspec
26
- ContinuousTesting.should_receive(:new).and_return(mock_continuous_testing)
27
- mock_continuous_testing.should_receive(:start!)
28
- empty_runner.start_continuous_testing!
29
- end
30
-
26
+
27
+ end
28
+
29
+ describe "#start_continuous_testing!" do
30
+ let(:empty_runner) { InfinityTest::Runner.new([]) }
31
+ let(:mock_continuous_testing) { @mock ||= mock(InfinityTest::ContinuousTesting) }
32
+
33
+ it "should call start for Continuous Testing" do
34
+ application = application_with_rspec
35
+ InfinityTest::ContinuousTesting.should_receive(:new).and_return(mock_continuous_testing)
36
+ mock_continuous_testing.should_receive(:start!)
37
+ empty_runner.start_continuous_testing!
31
38
  end
32
-
39
+
33
40
  end
34
- end
41
+
42
+ end
@@ -0,0 +1,127 @@
1
+ require 'spec_helper'
2
+
3
+ module InfinityTest
4
+
5
+ class SomeFramework < TestFramework
6
+ parse_results :examples => /(\d+) example/, :failures => /(\d+) failure/, :pending => /(\d+) pending/
7
+ end
8
+
9
+ class OtherFramework < TestFramework
10
+ parse_results :tests => /(\d+) tests/, :assertions => /(\d+) assertions/, :failures => /(\d+) failures/, :errors => /(\d+) errors/
11
+ end
12
+
13
+ describe "Test Framework" do
14
+
15
+ let(:some_framework) { SomeFramework.new }
16
+ let(:other_framework) { OtherFramework.new }
17
+
18
+ describe '#application' do
19
+ it { some_framework.application.should equal InfinityTest.application}
20
+ it { other_framework.application.should equal InfinityTest.application}
21
+ end
22
+
23
+ describe '#parse_results' do
24
+
25
+ it "should create the examples instance variable" do
26
+ some_framework.parse_results("0 examples, 0 failures, 0 pending")
27
+ some_framework.examples.should == 0
28
+ end
29
+
30
+ it "should create the tests instance variable" do
31
+ other_framework.parse_results("120 tests, 200 assertions, 0 failures, 0 errors")
32
+ other_framework.tests.should == 120
33
+ end
34
+
35
+ it "should create the assertions instance variable" do
36
+ other_framework.parse_results("120 tests, 200 assertions, 0 failures, 0 errors")
37
+ other_framework.assertions.should == 200
38
+ end
39
+
40
+ it "should create the failures instance variable" do
41
+ some_framework.parse_results("0 examples, 1 failures, 0 pending")
42
+ some_framework.failures.should == 1
43
+ end
44
+
45
+ it "should create the failures instance variable" do
46
+ other_framework.parse_results("120 tests, 200 assertions, 10 failures, 0 errors")
47
+ other_framework.failures.should == 10
48
+ end
49
+
50
+ it "should create the pending instance variable" do
51
+ some_framework.parse_results("0 examples, 0 failures, 1 pending")
52
+ some_framework.pending.should == 1
53
+ end
54
+
55
+ it "should create the example instance variable" do
56
+ some_framework.parse_results(" ..... \n10 examples, 0 failures, 0 pending")
57
+ some_framework.examples.should == 10
58
+ end
59
+
60
+ it "should create a message based in the keys of framework" do
61
+ some_framework.parse_results(".....\n200 examples, 0 failures, 1 pending")
62
+ some_framework.message.should == "200 examples, 0 failures, 1 pending"
63
+ end
64
+
65
+ it "should create a error message to runtime errors and similars" do
66
+ some_framework.parse_results("RunTimeError: undefined method 'my_method' ...")
67
+ some_framework.message.should == "An exception occurred"
68
+ end
69
+
70
+ it "should parse the results correctly(when not have in last line)" do
71
+ other_framework.parse_results("....\n10 tests, 35 assertions, 0 failures, 0 errors\nTest run options: --seed 18841")
72
+ other_framework.tests.should == 10
73
+ other_framework.assertions.should == 35
74
+ end
75
+
76
+ it "should clear the term ansi colors strings" do
77
+ other_framework.parse_results("seconds\n\e[33m406 tests, 34 assertions, 0 failures, 2 errors\e[0m\n")
78
+ other_framework.message.should == "406 tests, 34 assertions, 0 failures, 2 errors"
79
+ end
80
+
81
+ it "should clear the term ansi colors strings" do
82
+ some_framework.parse_results("seconds\n\e[33m406 examples, 0 failures, 2 pending\e[0m\n")
83
+ some_framework.message.should == "406 examples, 0 failures, 2 pending"
84
+ end
85
+
86
+ it "should accept other formats (like Fuubar)" do
87
+ some_framework.parse_results("299 examples: 99% |ooooooooooooooooooooooooooooooooooooooooo | ETA: 00:00:00\r\e[0m\e[31m\e[0m\e[31m297/298: 100% |oooooooooooooooooooooooooooooooooooooooooo| ETA: 00:00:00\r\e[0m\e[31m298/298: 100% |oooooooooooooooooooooooooooooooooooooooooo| Time: 00:00:00\n\e[0m\nPending:\n\e[33m InfinityTest::Environment#environments should run in the scope of RVM environment\e[0m\n\e[90m # No reason given\e[0m\n\e[90m # \e[0m\n\nFinished in 0.43473 seconds\n\e[31m298 examples, 1 failure, 1 pending\e[0m\n")
88
+ some_framework.message.should == "298 examples, 1 failure, 1 pending"
89
+ end
90
+
91
+ it "should raise error when not have patterns" do
92
+ lambda {
93
+ class Abc < TestFramework
94
+ parse_results({})
95
+ end
96
+ }.should raise_exception(ArgumentError, 'patterns should not be empty')
97
+ end
98
+
99
+ end
100
+
101
+ describe '#test_message' do
102
+
103
+ it "should parse the message in the tests results" do
104
+ some_framework.test_message("\n880 examples, 0 failures, 3 pending\n", { :example => /(\d+) example/}).should eql '880 examples, 0 failures, 3 pending'
105
+ end
106
+
107
+ it "should parse the message in the tests results" do
108
+ some_framework.test_message("\n880 examples, 0 failures", { :pending => /(\d+) pending/, :example => /(\d+) example/ }).should eql '880 examples, 0 failures'
109
+ end
110
+
111
+ it "should parse the message in the tests results" do
112
+ some_framework.test_message("\n880 examples, 0 failures", { :pending => /(\d+) pending/, :example => /(\d+) example/, :errors => /(\d+) errors/ }).should eql '880 examples, 0 failures'
113
+ end
114
+
115
+ it "should parse message when ==== is the last line" do
116
+ some_framework.test_message("\n880 examples, 0 failures\n============", { :example => /(\d+) example/}).should == '880 examples, 0 failures'
117
+ end
118
+
119
+ it "should return nil when not have any patterns" do
120
+ other_framework.test_message("NameError: You fail!! by Chuck Norris", { :pending => /(\d+) pending/, :example => /(\d+) example/ }).should be_nil
121
+ end
122
+
123
+ end
124
+
125
+ end
126
+
127
+ end