tconsole 1.1.0pre2 → 1.1.0pre3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -29,6 +29,10 @@ willing to merge it in, though.
29
29
  Installing tconsole
30
30
  ------
31
31
  gem install tconsole
32
+
33
+ Prereleases of tconsole come out pretty frequently. You can install the latest prerelease version with:
34
+
35
+ gem installt console --pre
32
36
 
33
37
  How to use tconsole
34
38
  ------
@@ -72,12 +76,12 @@ If you want to focus in on a particular subset of your tests, like units, functi
72
76
  If you'd like to just run the tests that are related to recent changes
73
77
  you've made:
74
78
 
75
- > recent
79
+ > recent
76
80
 
77
81
  Or if you'd like to run the tests for changes you've made since your
78
82
  last commit:
79
83
 
80
- > uncommitted
84
+ > uncommitted
81
85
 
82
86
  You can also focus in on just the tests in a given filename by entering a test file name into tconsole:
83
87
 
@@ -92,6 +96,32 @@ That command will load up the user_test.rb file and then only run the
92
96
  test named test_that_user_is_healthy. You can add a specific test name
93
97
  argument to any tconsole command that runs tests.
94
98
 
99
+ There are a few special ! commands that use data from past test runs. The `!failed` command will rerun all of your files
100
+ that included failing tests in the last test run:
101
+
102
+ > !failed
103
+
104
+ There's also a `!timings` command that will show you a listing of your last test run's test times, sorted to help you
105
+ improve slow tests:
106
+
107
+ > !timings
108
+
109
+ Timings from last run:
110
+
111
+ 0.042632s PostTest#test_new_post_should_not_be_published
112
+ 0.033892s PostTest#test_post_should_have_a_title
113
+ 0.033134s PostsControllerTest#test_can_reach_all_posts
114
+ 0.007098s PostsControllerTest#test_grabs_posts
115
+ 0.006212s PostsControllerTest#test_displays_published_posts_by_default
116
+ 0.006107s PostTest#test_post_cannot_have_an_empty_body
117
+ 0.002197s PostTest#test_post_should_have_a_publish_date_set_when_published
118
+ 0.001937s PostTest#test_post_cannot_have_an_empty_title
119
+ 0.001232s PostTest#test_post_should_have_an_initial_state
120
+ 0.001128s PostTest#test_post's_state_should_change_when_published
121
+ 0.001056s PostTest#test_returning_only_published_posts
122
+ 0.000923s PostTest#test_post_should_have_respond_to_published_appropriately
123
+ 0.00077s PostTest#test_post_should_have_a_body
124
+
95
125
  If you update your environment, maybe by editing your Gemfile or changing one of your application's configuration files, you can use the `reload` command to reload the entire environment:
96
126
 
97
127
  > reload
@@ -12,23 +12,15 @@ module TConsole
12
12
  end
13
13
 
14
14
  def load_environment
15
- puts
16
- puts "Loading Rails environment..."
15
+ result = false
16
+
17
17
  time = Benchmark.realtime do
18
+
18
19
  begin
19
- # Ruby environment loading is shamelessly borrowed from spork
20
- ENV["RAILS_ENV"] ||= "test"
21
- $:.unshift("./test")
22
-
23
- # This is definitely based on Sporks rails startup code. I tried initially to use Rake to get things done
24
- # and match the test environment a bit better, but it didn't work out well at all
25
- # TODO: Figure out how ot get rake db:test:load and rake test:prepare working in this context
26
- require "./config/application"
27
- ::Rails.application
28
- ::Rails::Engine.class_eval do
29
- def eager_load!
30
- # turn off eager_loading, all together
31
- end
20
+ if is_rails?
21
+ result = load_rails_environment
22
+ else
23
+ result = load_non_rails_environment
32
24
  end
33
25
  rescue Exception => e
34
26
  puts "Error - Loading your environment failed: #{e.message}"
@@ -44,7 +36,43 @@ module TConsole
44
36
  puts "Environment loaded in #{time}s."
45
37
  puts
46
38
 
47
- return true
39
+ result
40
+ end
41
+
42
+ def is_rails?
43
+ @rails ||= !!File.exist?("./config/application.rb")
44
+ end
45
+
46
+ def load_rails_environment
47
+ puts
48
+ puts "Loading Rails environment..."
49
+
50
+ # Ruby environment loading is shamelessly borrowed from spork
51
+ ENV["RAILS_ENV"] ||= "test"
52
+ $:.unshift("./test")
53
+
54
+ # This is definitely based on Sporks rails startup code. I tried initially to use Rake to get things done
55
+ # and match the test environment a bit better, but it didn't work out well at all
56
+ # TODO: Figure out how ot get rake db:test:load and rake test:prepare working in this context
57
+ require "./config/application"
58
+ ::Rails.application
59
+ ::Rails::Engine.class_eval do
60
+ def eager_load!
61
+ # turn off eager_loading
62
+ end
63
+ end
64
+
65
+ true
66
+ end
67
+
68
+ def load_non_rails_environment
69
+ $:.unshift("./lib")
70
+ $:.unshift("./test")
71
+
72
+ puts
73
+ puts "Loading environment..."
74
+
75
+ true
48
76
  end
49
77
 
50
78
  def run_tests(globs, name_pattern, message = "Running tests...")
@@ -62,6 +90,7 @@ module TConsole
62
90
  globs.each do |glob|
63
91
  paths.concat(Dir.glob(glob))
64
92
  end
93
+ puts "Paths: #{paths.join(", ")}"
65
94
 
66
95
  paths.each do |path|
67
96
  require File.expand_path(path)
@@ -1,3 +1,3 @@
1
1
  module TConsole
2
- VERSION = "1.1.0pre2"
2
+ VERSION = "1.1.0pre3"
3
3
  end
data/lib/tconsole.rb CHANGED
@@ -56,7 +56,7 @@ module TConsole
56
56
  begin
57
57
  server = Server.new(config)
58
58
 
59
- drb_server = DRb.start_service("drbunix://tmp/tconsole.#{Process.pid}", server)
59
+ drb_server = DRb.start_service("drbunix:/tmp/tconsole.#{Process.pid}", server)
60
60
  DRb.thread.join
61
61
  rescue Interrupt
62
62
  # do nothing here since the outer process will shut things down for us
@@ -64,11 +64,14 @@ module TConsole
64
64
  end
65
65
 
66
66
  # Set up our client connection to the server
67
- server = DRbObject.new_with_uri("drbunix://tmp/tconsole.#{server_pid}")
67
+ server = DRbObject.new_with_uri("drbunix:/tmp/tconsole.#{server_pid}")
68
68
 
69
69
  loaded = false
70
70
  wait_until = Time.now + 10
71
71
  until loaded || Time.now > wait_until
72
+ # Give drb a second to get set up
73
+ sleep(1)
74
+
72
75
  begin
73
76
  running = server.load_environment
74
77
  loaded = true
@@ -162,7 +165,7 @@ module TConsole
162
165
  puts "recent [test_pattern] # Run tests for recently changed files"
163
166
  puts "uncommitted [test_pattern] # Run tests for uncommitted changes"
164
167
  puts "!failed # Runs the last set of failing tests"
165
- puts "!timings # Lists the timings for the last test run, sorted."
168
+ puts "!timings [limit] # Lists the timings for the last test run, sorted."
166
169
  puts "[filename] [test_pattern] # Run the tests contained in the given file"
167
170
  puts "reload # Reload your Rails environment"
168
171
  puts "exit # Exit the console"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tconsole
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0pre2
4
+ version: 1.1.0pre3
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-14 00:00:00.000000000 Z
12
+ date: 2012-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
16
- requirement: &70111282504820 !ruby/object:Gem::Requirement
16
+ requirement: &70275488249920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.0.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70111282504820
24
+ version_requirements: *70275488249920
25
25
  description: ! " tconsole allows Rails developers to easily and quickly run their
26
26
  tests as a whole or in subsets. It forks the testing processes from\n a preloaded
27
27
  test environment to ensure that developers don't have to reload their entire Rails