specjour 0.3.1 → 0.4.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 (43) hide show
  1. data/History.markdown +12 -1
  2. data/README.markdown +19 -5
  3. data/Rakefile +3 -35
  4. data/lib/specjour/cucumber/preloader.rb +0 -22
  5. data/lib/specjour/cucumber/runner.rb +5 -9
  6. data/lib/specjour/cucumber.rb +0 -1
  7. data/lib/specjour/db_scrub.rb +15 -10
  8. data/lib/specjour/printer.rb +1 -1
  9. data/lib/specjour/rspec/distributed_formatter.rb +32 -56
  10. data/lib/specjour/rspec/final_report.rb +60 -52
  11. data/lib/specjour/rspec/marshalable_exception.rb +1 -1
  12. data/lib/specjour/rspec/preloader.rb +1 -1
  13. data/lib/specjour/rspec/runner.rb +9 -8
  14. data/lib/specjour/{rspec2 → rspec}/shared_example_group_ext.rb +1 -1
  15. data/lib/specjour/rspec.rb +10 -29
  16. data/lib/specjour/socket_helper.rb +2 -0
  17. data/lib/specjour/worker.rb +2 -2
  18. data/lib/specjour.rb +3 -3
  19. metadata +24 -112
  20. data/.dev +0 -3
  21. data/.document +0 -5
  22. data/.gitignore +0 -25
  23. data/.rvmrc +0 -1
  24. data/Gemfile +0 -2
  25. data/VERSION +0 -1
  26. data/lib/specjour/rspec/marshalable_rspec_failure.rb +0 -21
  27. data/lib/specjour/rspec2/distributed_formatter.rb +0 -48
  28. data/lib/specjour/rspec2/final_report.rb +0 -73
  29. data/lib/specjour/rspec2/runner.rb +0 -12
  30. data/sample/features/fail.feature +0 -31
  31. data/sample/features/pass.feature +0 -31
  32. data/sample/features/step_definitions/sample_steps.rb +0 -26
  33. data/sample/features/undefined.feature +0 -17
  34. data/spec/spec.opts +0 -2
  35. data/spec/spec_helper.rb +0 -20
  36. data/spec/specjour/cli_spec.rb +0 -105
  37. data/spec/specjour/configuration_spec.rb +0 -112
  38. data/spec/specjour/cpu_spec.rb +0 -28
  39. data/spec/specjour/manager_spec.rb +0 -21
  40. data/spec/specjour/printer_spec.rb +0 -101
  41. data/spec/specjour/rsync_daemon_spec.rb +0 -90
  42. data/spec/specjour_spec.rb +0 -18
  43. data/specjour.gemspec +0 -125
data/History.markdown CHANGED
@@ -1,8 +1,19 @@
1
1
  History
2
2
  =======
3
3
 
4
+ 0.4.0 / 2011-03-09
5
+ ------------------
6
+
7
+ l4rk and leshill
8
+
9
+ * [added] Remove Jeweler
10
+ * [added] Use RSpec2 for development
11
+ * [added] Cucumber 0.9+ compatibility
12
+ * [added] RSpec2 compatibility
13
+ * [removed] No longer supporting RSpec 1 and Cucumber 0.8
14
+
4
15
  0.3.1 / 2010-10-16
5
- ----------------
16
+ ------------------
6
17
 
7
18
  #### Fixes
8
19
  * Stopping bonjour actually stops the currently running service
data/README.markdown CHANGED
@@ -104,18 +104,32 @@ By default, the dispatcher looks for managers matching the project's directory n
104
104
 
105
105
  ## Compatibility
106
106
 
107
- * RSpec 1.3.x
108
- * RSpec 2.0.0
109
- * Cucumber 0.8.5
110
- * Cucumber 0.9.2
107
+ * RSpec 2
108
+ * Cucumber 0.9+
111
109
  * Rails 2
112
110
  * Rails 3
113
111
 
112
+ ## Hacking on Specjour
113
+ If you want to hack on specjour, here is how to test your changes:
114
+
115
+ source .dev
116
+ rake # run the test suite sanely
117
+ specjour # run the test suite with specjour
118
+ cd sample
119
+ specjour # run the cucumber test suite with specjour
120
+
121
+ Then if all is good, go to another app and test your changes on your test suite:
122
+
123
+ gem build specjour.gemspec
124
+ cd /path/to/your/project
125
+ gem install -l /path/to/specjour/latest.gem
126
+ specjour
127
+
114
128
  ## Thanks
115
129
 
116
130
  * shayarnett - Cucumber support, pairing and other various patches
117
131
  * voxdolo - Endless support, alpha testing, various patches
118
- * leshill - Made rsync daemon configurable
132
+ * l4rk and leshill - Removed Jeweler, added support for RSpec 2 and Cucumber 0.9+
119
133
  * testjour - Ripped off your name
120
134
  * parallel\_tests - Made my test suite twice as fast
121
135
 
data/Rakefile CHANGED
@@ -1,42 +1,10 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "specjour"
8
- gem.summary = %Q{Distribute your spec suite amongst your LAN via Bonjour.}
9
- gem.description = %Q{Distribute your spec suite amongst your LAN via Bonjour.}
10
- gem.email = "sandro.turriate@gmail.com"
11
- gem.homepage = "http://github.com/sandro/specjour"
12
- gem.authors = ["Sandro Turriate"]
13
- gem.add_dependency "dnssd", "1.3.4"
14
- gem.add_dependency "thor", ">=0.14.0"
15
- gem.add_development_dependency "rspec", "1.3.0"
16
- gem.add_development_dependency "rr", ">=0.10.11"
17
- gem.add_development_dependency "cucumber", ">=0.9.0"
18
- gem.add_development_dependency "yard", ">=0.5.3"
19
- gem.add_development_dependency "jeweler", ">=1.4.0"
20
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
21
- end
22
- Jeweler::GemcutterTasks.new
23
- rescue LoadError
24
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
- end
26
-
27
- require 'spec/rake/spectask'
28
- Spec::Rake::SpecTask.new(:spec) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.spec_files = FileList['spec/**/*_spec.rb']
31
- end
32
-
33
- Spec::Rake::SpecTask.new(:rcov) do |spec|
34
- spec.libs << 'lib' << 'spec'
35
- spec.pattern = 'spec/**/*_spec.rb'
36
- spec.rcov = true
37
- end
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
38
6
 
39
- task :spec => :check_dependencies
7
+ RSpec::Core::RakeTask.new(:rcov)
40
8
 
41
9
  task :default => :spec
42
10
 
@@ -2,28 +2,6 @@ module Specjour
2
2
  module Cucumber
3
3
  module Preloader
4
4
  def self.load(feature_file)
5
- if CUCUMBER_09x
6
- load_09x
7
- else
8
- load_08x
9
- end
10
- end
11
-
12
- protected
13
-
14
- def self.load_08x
15
- cli = ::Cucumber::Cli::Main.new []
16
- step_mother = cli.class.step_mother
17
-
18
- step_mother.log = cli.configuration.log
19
- step_mother.options = cli.configuration.options
20
- step_mother.load_code_files(cli.configuration.support_to_load)
21
- step_mother.after_configuration(cli.configuration)
22
- features = step_mother.load_plain_text_features(cli.configuration.feature_files)
23
- step_mother.load_code_files(cli.configuration.step_defs_to_load)
24
- end
25
-
26
- def self.load_09x
27
5
  configuration = ::Cucumber::Cli::Configuration.new
28
6
  configuration.parse! []
29
7
  runtime = ::Cucumber::Runtime.new(configuration)
@@ -4,15 +4,11 @@ module Specjour
4
4
  def self.run(feature, output)
5
5
  cli = ::Cucumber::Cli::Main.new(['--format', 'Specjour::Cucumber::DistributedFormatter', feature], output)
6
6
 
7
- if CUCUMBER_09x
8
- Cucumber.runtime.instance_variable_set(:@configuration, cli.configuration)
9
- Cucumber.runtime.instance_eval do
10
- tree_walker = @configuration.build_tree_walker(self)
11
- self.visitor = tree_walker
12
- tree_walker.visit_features(features)
13
- end
14
- else
15
- cli.execute!(::Cucumber::Cli::Main.step_mother)
7
+ Cucumber.runtime.instance_variable_set(:@configuration, cli.configuration)
8
+ Cucumber.runtime.instance_eval do
9
+ tree_walker = @configuration.build_tree_walker(self)
10
+ self.visitor = tree_walker
11
+ tree_walker.visit_features(features)
16
12
  end
17
13
  end
18
14
  end
@@ -10,7 +10,6 @@ module Specjour
10
10
  require 'specjour/cucumber/main_ext'
11
11
  require 'specjour/cucumber/runner'
12
12
 
13
- CUCUMBER_09x = ::Cucumber::VERSION =~ /0\.9\.\d/
14
13
  ::Cucumber::Cli::Options.class_eval { def print_profile_information; end }
15
14
  rescue LoadError
16
15
  end
@@ -1,15 +1,20 @@
1
1
  module Specjour
2
2
  module DbScrub
3
- require 'rake'
4
- if defined?(Rails) && Rails.version =~ /^3/
5
- task(:environment) {}
6
- load 'rails/tasks/misc.rake'
7
- load 'active_record/railties/databases.rake'
8
- else
9
- load 'tasks/misc.rake'
10
- load 'tasks/databases.rake'
11
- Rake::Task["db:structure:dump"].clear
12
- Rake::Task["environment"].clear
3
+
4
+ begin
5
+ require 'rake'
6
+ if defined?(Rails) && Rails.version =~ /^3/
7
+ task(:environment) {}
8
+ load 'rails/tasks/misc.rake'
9
+ load 'active_record/railties/databases.rake'
10
+ else
11
+ load 'tasks/misc.rake'
12
+ load 'tasks/databases.rake'
13
+ Rake::Task["db:structure:dump"].clear
14
+ Rake::Task["environment"].clear
15
+ end
16
+ rescue LoadError
17
+ Specjour.logger.debug "Failed to load Rails rake tasks"
13
18
  end
14
19
 
15
20
  extend self
@@ -99,7 +99,7 @@ module Specjour
99
99
  end
100
100
 
101
101
  def rspec_report
102
- @rspec_report ||= Rspec::FinalReport.new
102
+ @rspec_report ||= RSpec::FinalReport.new
103
103
  end
104
104
 
105
105
  def cucumber_report
@@ -1,72 +1,48 @@
1
- module Specjour::Rspec
2
- class DistributedFormatter < Spec::Runner::Formatter::BaseTextFormatter
3
- require 'specjour/rspec/marshalable_rspec_failure'
4
-
5
- attr_reader :failing_messages, :passing_messages, :pending_messages, :output
6
- attr_reader :duration, :example_count, :failure_count, :pending_count, :pending_examples, :failing_examples
7
-
8
- def initialize(options, output)
9
- @options = options
10
- @output = output
11
- @failing_messages = []
12
- @passing_messages = []
13
- @pending_messages = []
14
- @pending_examples = []
15
- @failing_examples = []
16
- end
17
-
18
- def example_failed(example, counter, failure)
19
- failing_messages << colorize_failure('F', failure)
20
- print_and_flush(failing_messages)
21
- end
22
-
23
- def example_passed(example)
24
- passing_messages << green('.')
25
- print_and_flush(passing_messages)
1
+ module Specjour::RSpec
2
+ class DistributedFormatter < ::RSpec::Core::Formatters::ProgressFormatter
3
+
4
+ def metadata_for_examples
5
+ examples.map do |example|
6
+ metadata = example.metadata
7
+ {
8
+ :execution_result => marshalable_execution_result(example.execution_result),
9
+ :description => metadata[:description],
10
+ :file_path => metadata[:file_path],
11
+ :full_description => metadata[:full_description],
12
+ :line_number => metadata[:line_number],
13
+ :location => metadata[:location]
14
+ }
15
+ end
26
16
  end
27
17
 
28
- def example_pending(example, message, deprecated_pending_location=nil)
29
- super
30
- pending_messages << yellow('*')
31
- print_and_flush(pending_messages)
18
+ def noop(*args)
32
19
  end
20
+ alias dump_pending noop
21
+ alias dump_failures noop
22
+ alias start_dump noop
23
+ alias message noop
33
24
 
34
- def dump_summary(duration, example_count, failure_count, pending_count)
35
- @duration = duration
36
- @example_count = example_count
37
- @failure_count = failure_count
38
- @pending_count = pending_count
39
- output.send_message(:rspec_summary=, to_hash)
25
+ def color_enabled?
26
+ true
40
27
  end
41
28
 
42
- def dump_pending
43
- #noop
29
+ def dump_summary(*args)
30
+ output.send_message :rspec_summary=, metadata_for_examples
44
31
  end
45
32
 
46
- def dump_failure(counter, failure)
47
- failing_examples << failure
33
+ def close
34
+ @examples = []
35
+ super
48
36
  end
49
37
 
50
- def start_dump
51
- print_and_flush failing_messages
52
- print_and_flush passing_messages
53
- print_and_flush pending_messages
54
- end
38
+ protected
55
39
 
56
- def to_hash
57
- h = {}
58
- [:duration, :example_count, :failure_count, :pending_count, :pending_examples, :failing_examples].each do |key|
59
- h[key] = send(key)
40
+ def marshalable_execution_result(execution_result)
41
+ if exception = execution_result[:exception]
42
+ execution_result[:exception] = MarshalableException.new(exception)
60
43
  end
61
- h
44
+ execution_result
62
45
  end
63
46
 
64
- protected
65
-
66
- def print_and_flush(messages)
67
- output.print messages.join
68
- output.flush
69
- messages.replace []
70
- end
71
47
  end
72
48
  end
@@ -1,65 +1,73 @@
1
- module Specjour
2
- module Rspec
3
- class FinalReport
4
- attr_reader :duration, :example_count, :failure_count, :pending_count, :pending_examples, :failing_examples
1
+ module Specjour::RSpec
2
+ class FinalReport
3
+ attr_reader :examples
4
+ attr_reader :duration
5
5
 
6
- def initialize
7
- @duration = 0.0
8
- @example_count = 0
9
- @failure_count = 0
10
- @pending_count = 0
11
- @pending_examples = []
12
- @failing_examples = []
13
- end
14
-
15
- def add(stats)
16
- stats.each do |key, value|
17
- if key == :duration
18
- @duration = value.to_f if duration < value.to_f
19
- else
20
- increment(key, value)
21
- end
22
- end
23
- end
6
+ def initialize
7
+ @examples = []
8
+ @duration = 0.0
9
+ ::RSpec.configuration.color_enabled = true
10
+ ::RSpec.configuration.output_stream = $stdout
11
+ end
24
12
 
25
- def exit_status
26
- failing_examples.empty?
13
+ def add(data)
14
+ if data.respond_to?(:has_key?) && data.has_key?(:duration)
15
+ self.duration = data[:duration]
16
+ else
17
+ metadata_for_examples(data)
27
18
  end
19
+ end
28
20
 
29
- def increment(key, value)
30
- current = instance_variable_get("@#{key}")
31
- instance_variable_set("@#{key}", current + value)
32
- end
21
+ def duration=(value)
22
+ @duration = value.to_f if duration < value.to_f
23
+ end
33
24
 
34
- def formatter_options
35
- @formatter_options ||= OpenStruct.new(
36
- :colour => true,
37
- :autospec => false,
38
- :dry_run => false
39
- )
40
- end
25
+ def exit_status
26
+ formatter.failed_examples.empty?
27
+ end
41
28
 
42
- def formatter
43
- @formatter ||= begin
44
- f = Spec::Runner::Formatter::BaseTextFormatter.new(formatter_options, $stdout)
45
- f.instance_variable_set(:@pending_examples, pending_examples)
46
- f
29
+ def metadata_for_examples(metadata_collection)
30
+ examples.concat(
31
+ metadata_collection.map do |partial_metadata|
32
+ example = ::RSpec::Core::Example.allocate
33
+ example.instance_variable_set(:@example_group_class,
34
+ OpenStruct.new(:metadata => {}, :ancestors => [])
35
+ )
36
+ metadata = ::RSpec::Core::Metadata.new
37
+ metadata.merge! partial_metadata
38
+ example.instance_variable_set(:@metadata, metadata)
39
+ example
47
40
  end
48
- end
41
+ )
42
+ end
49
43
 
50
- def summarize
51
- if example_count > 0
52
- formatter.dump_pending
53
- dump_failures
54
- formatter.dump_summary(duration, example_count, failure_count, pending_count)
55
- end
56
- end
44
+ def pending_examples
45
+ ::RSpec.world.find(examples, :execution_result => { :status => 'pending' })
46
+ end
57
47
 
58
- def dump_failures
59
- failing_examples.each_with_index do |failure, index|
60
- formatter.dump_failure index + 1, failure
61
- end
48
+ def failed_examples
49
+ ::RSpec.world.find(examples, :execution_result => { :status => 'failed' })
50
+ end
51
+
52
+ def formatter
53
+ @formatter ||= new_progress_formatter
54
+ end
55
+
56
+ def summarize
57
+ if examples.size > 0
58
+ formatter.start_dump
59
+ formatter.dump_pending
60
+ formatter.dump_failures
61
+ formatter.dump_summary(duration, examples.size, failed_examples.size, pending_examples.size)
62
62
  end
63
63
  end
64
+
65
+ protected
66
+ def new_progress_formatter
67
+ new_formatter = ::RSpec::Core::Formatters::ProgressFormatter.new($stdout)
68
+ new_formatter.instance_variable_set(:@failed_examples, failed_examples)
69
+ new_formatter.instance_variable_set(:@pending_examples, pending_examples)
70
+ new_formatter
71
+ end
64
72
  end
65
73
  end
@@ -1,4 +1,4 @@
1
- module Specjour::Rspec
1
+ module Specjour::RSpec
2
2
  class MarshalableException
3
3
  attr_accessor :message, :backtrace, :class_name
4
4
 
@@ -1,4 +1,4 @@
1
- class Specjour::Rspec::Preloader
1
+ class Specjour::RSpec::Preloader
2
2
  def self.load(spec_file)
3
3
  $LOAD_PATH.unshift File.join(Dir.pwd, 'spec')
4
4
  require spec_file
@@ -1,11 +1,12 @@
1
- module Specjour::Rspec::Runner
1
+ module Specjour::RSpec::Runner
2
2
  def self.run(spec, output)
3
- options = Spec::Runner::OptionParser.parse(
4
- ['--format=Specjour::Rspec::DistributedFormatter', spec],
5
- $stderr,
6
- output
7
- )
8
- Spec::Runner.use options
9
- options.run_examples
3
+ reset
4
+ args = ['--format=Specjour::RSpec::DistributedFormatter', spec]
5
+ ::RSpec::Core::Runner.run_in_process args, $stderr, output
6
+ end
7
+
8
+ def self.reset
9
+ ::RSpec.world.instance_variable_set(:@example_groups, [])
10
+ ::RSpec.configuration.instance_variable_set(:@formatter, nil)
10
11
  end
11
12
  end
@@ -1,4 +1,4 @@
1
- Rspec::Core::SharedExampleGroup.class_eval do
1
+ RSpec::Core::SharedExampleGroup.class_eval do
2
2
 
3
3
  def ensure_shared_example_group_name_not_taken(name)
4
4
  if RSpec.world.shared_example_groups.has_key?(name)
@@ -1,35 +1,16 @@
1
1
  module Specjour
2
- module Rspec
3
- def self.load_rspec1
4
- require 'spec'
5
- require 'spec/runner/formatter/base_text_formatter'
2
+ module RSpec
3
+ require 'rspec/core'
4
+ require 'rspec/core/formatters/progress_formatter'
6
5
 
7
- require 'specjour/rspec/distributed_formatter'
8
- require 'specjour/rspec/final_report'
9
- require 'specjour/rspec/marshalable_exception'
10
- require 'specjour/rspec/preloader'
11
- require 'specjour/rspec/runner'
12
- end
13
-
14
- def self.load_rspec2
15
- require 'rspec/core'
16
- require 'rspec/core/formatters/progress_formatter'
17
-
18
- require 'specjour/rspec/marshalable_exception'
19
- require 'specjour/rspec/preloader'
20
- require 'specjour/rspec2/distributed_formatter'
21
- require 'specjour/rspec2/final_report'
22
- require 'specjour/rspec2/runner'
23
- require 'specjour/rspec2/shared_example_group_ext'
6
+ require 'specjour/rspec/marshalable_exception'
7
+ require 'specjour/rspec/preloader'
8
+ require 'specjour/rspec/distributed_formatter'
9
+ require 'specjour/rspec/final_report'
10
+ require 'specjour/rspec/runner'
11
+ require 'specjour/rspec/shared_example_group_ext'
24
12
 
25
- ::Rspec::Core::Runner.disable_autorun!
26
- end
27
-
28
- begin
29
- load_rspec2
30
- rescue LoadError
31
- load_rspec1
32
- end
13
+ ::RSpec::Core::Runner.disable_autorun!
33
14
 
34
15
  def self.wants_to_quit
35
16
  if defined?(::RSpec) && ::RSpec.respond_to?(:wants_to_quit=)
@@ -4,6 +4,8 @@ module Specjour
4
4
 
5
5
  def ip_from_hostname(hostname)
6
6
  Socket.getaddrinfo(hostname, nil, Socket::AF_INET, Socket::SOCK_STREAM).first.fetch(3)
7
+ rescue SocketError
8
+ hostname
7
9
  end
8
10
 
9
11
  def hostname
@@ -60,7 +60,7 @@ module Specjour
60
60
  end
61
61
 
62
62
  def load_app
63
- Rspec::Preloader.load(preload_spec) if preload_spec
63
+ RSpec::Preloader.load(preload_spec) if preload_spec
64
64
  Cucumber::Preloader.load(preload_feature) if preload_feature
65
65
  rescue StandardError => exception
66
66
  $stderr.puts "Caught exception: #{exception.class} #{exception.message}"
@@ -100,7 +100,7 @@ module Specjour
100
100
  end
101
101
 
102
102
  def run_spec(spec)
103
- Specjour::Rspec::Runner.run(spec, connection)
103
+ Specjour::RSpec::Runner.run(spec, connection)
104
104
  end
105
105
 
106
106
  def send_run_times(run_times)
data/lib/specjour.rb CHANGED
@@ -26,9 +26,9 @@ module Specjour
26
26
  autoload :Worker, 'specjour/worker'
27
27
 
28
28
  autoload :Cucumber, 'specjour/cucumber'
29
- autoload :Rspec, 'specjour/rspec'
29
+ autoload :RSpec, 'specjour/rspec'
30
30
 
31
- VERSION = "0.3.1".freeze
31
+ VERSION = "0.4.0"
32
32
  HOOKS_PATH = "./.specjour/hooks.rb"
33
33
 
34
34
  def self.interrupted?
@@ -37,7 +37,7 @@ module Specjour
37
37
 
38
38
  def self.interrupted=(bool)
39
39
  Cucumber.wants_to_quit
40
- Rspec.wants_to_quit
40
+ RSpec.wants_to_quit
41
41
  @interrupted = bool
42
42
  end
43
43