Skip to content

Commit

Permalink
Refactor specs:
Browse files Browse the repository at this point in the history
 * runs on latest rspec (2.6.4)
 * spec_helpers for plugins are now much more straightforward
 * the gui thread is NOT started in specs (though the SWT classes are still loaded)
 * there is a master spec_helper in spec/, which loads the plugin spec_helpers
  • Loading branch information
danlucraft committed Oct 1, 2011
1 parent 9ddf501 commit b690f7c
Show file tree
Hide file tree
Showing 62 changed files with 114 additions and 185 deletions.
12 changes: 2 additions & 10 deletions README.md
Expand Up @@ -59,17 +59,9 @@ To run all specs and all features:

### Specs

On OSX:

$ jruby -J-XstartOnFirstThread -S spec plugins/#{plugin_name}/spec/

On Linux/Windows:

$ jruby -S spec plugins/#{plugin_name}/spec/

To just run all specs:
To run all specs:

$ rake specs
$ rspec plugins/*/spec/

### Features

Expand Down
38 changes: 3 additions & 35 deletions Rakefile
@@ -1,13 +1,8 @@
require 'bundler'
REDCAR_VERSION = "0.12.0dev" # also change in lib/redcar.rb!
require 'fileutils'

# explitely use rspec < 2.0
gem 'rspec', '<2.0'
require 'spec/rake/spectask'
require 'cucumber/rake/task'
require "rake/gempackagetask"
require "rake/rdoctask"

Dir[File.expand_path("../lib/tasks/*.rake", __FILE__)].each { |f| load f }

if RUBY_PLATFORM =~ /mswin|mingw/
Expand Down Expand Up @@ -136,13 +131,8 @@ task :default => ["specs", "cucumber"]

desc "Run all specs"
task :specs do
files = Dir['plugins/*/spec/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*/*_spec.rb']
case Config::CONFIG["host_os"]
when "darwin"
sh("jruby -J-XstartOnFirstThread -S bundle exec spec -c #{files.join(" ")} && echo 'done'")
else
sh("jruby -S bundle exec spec -c #{files.join(" ")} && echo 'done'")
end
plugin_spec_dirs = Dir["plugins/*/spec"]
sh("jruby -S bundle exec rspec -c #{plugin_spec_dirs.join(" ")}")
end

desc "Run all features"
Expand Down Expand Up @@ -191,28 +181,6 @@ task :run_ci do
contrl.run
end

desc "Release gem"
task :release => :gem do
require 'aws/s3'
credentials = YAML.load(File.read("/Users/danlucraft/.s3-creds.yaml"))
AWS::S3::Base.establish_connection!(
:access_key_id => credentials['access_key_id'],
:secret_access_key => credentials["secret_access_key"]
)

redcar_bucket = AWS::S3::Bucket.find('redcar')
s3_uploads = {
"vendor/java-mateview/release/java-mateview.jar" => "java-mateview-#{REDCAR_VERSION}.jar",
"plugins/application_swt/lib/dist/application_swt.jar" => "application_swt-#{REDCAR_VERSION}.jar",
"pkg/redcar-#{REDCAR_VERSION}.gem" => "redcar-#{REDCAR_VERSION}.gem"
}

s3_uploads.each do |source, target|
p [source, target]
AWS::S3::S3Object.store(target, open(source), 'redcar', :access => :public_read)
end
end

namespace :redcar do
def hash_with_hash_default
Hash.new {|h,k| h[k] = hash_with_hash_default }
Expand Down
23 changes: 11 additions & 12 deletions lib/redcar.rb
Expand Up @@ -109,7 +109,7 @@ def self.add_plugin_sources(manager)
end
end

def self.load_prerequisites
def self.load_prerequisites(options={})
exit if ARGV.include?("--quit-immediately")
require 'java'

Expand All @@ -130,18 +130,17 @@ def self.load_prerequisites

gem 'swt'
require 'swt/minimal'

unless no_gui_mode?
gui = Redcar::Gui.new("swt")
gui.register_event_loop(Swt::EventLoop.new)
gui.register_features_runner(Swt::CucumberRunner.new)
Redcar.gui = gui

gui = Redcar::Gui.new("swt")
gui.register_event_loop(Swt::EventLoop.new)
gui.register_features_runner(Swt::CucumberRunner.new)
Redcar.gui = gui

plugin_manager.load("splash_screen")
plugin_manager.load("splash_screen")
end
end

def self.load_useful_libraries
end

def self.load_plugins
begin
exit if ARGV.include?("--quit-after-splash")
Expand Down Expand Up @@ -177,8 +176,8 @@ def self.load_threaded
end
end

def self.load_unthreaded
load_prerequisites
def self.load_unthreaded(options={})
load_prerequisites(options)
load_plugins
end

Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/application_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Application do
it "has a name" do
Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/clipboard_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Clipboard do
before do
Expand Down
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
require "spec_helper"

class Redcar::Command
describe Executor do
Expand Down
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
require "spec_helper"

describe Redcar::Command::History do
class HistoryTestCommand1 < Redcar::Command
Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/command_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Command do
describe "a command" do
Expand Down
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
require "spec_helper"

describe "Redcar::Keymap::Builder DSL" do
it "creates a keymap" do
Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/menu/builder_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
require "spec_helper"

describe "Redcar::Menu::Builder DSL" do
it "creates a menu" do
Expand Down
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
require "spec_helper"

describe Redcar::Menu::Item do
class DummyCommand; end
Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/menu_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Menu do
class DummyCommand; end
Expand Down
@@ -1,3 +1,5 @@
require "spec_helper"

describe Redcar::NavigationHistory do
module NavigationHistoryTest
class TestEditView
Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/notebook_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Notebook do
describe "with no tabs" do
Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/sensitive_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Sensitive do
class ExampleModel
Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/speedbar_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Speedbar do
it "should let you add labels" do
Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/treebook_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Treebook do

Expand Down
2 changes: 1 addition & 1 deletion plugins/application/spec/application/window_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Window do

Expand Down
10 changes: 4 additions & 6 deletions plugins/application/spec/spec_helper.rb
@@ -1,8 +1,4 @@
$:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
require 'redcar'
Redcar.environment = :test
Redcar.no_gui_mode!
Redcar.load_unthreaded

Dir[File.dirname(__FILE__) + "/application/controllers/*.rb"].each do |fn|
require fn
end
Expand All @@ -15,4 +11,6 @@ def initialize(title)
end

def focus; end
end
end

Redcar.plugin_manager.load("application")
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::ApplicationSWT::Gradient do

Expand Down
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
require "spec_helper"

BindingTranslator = Redcar::ApplicationSWT::Menu::BindingTranslator
describe BindingTranslator do
Expand Down
2 changes: 1 addition & 1 deletion plugins/application_swt/spec/application_swt/menu_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::ApplicationSWT::Menu do
it "should" do
Expand Down
20 changes: 1 addition & 19 deletions plugins/application_swt/spec/spec_helper.rb
@@ -1,20 +1,2 @@
$:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')

require 'redcar'
Redcar.environment = :test
Redcar.load_unthreaded

Spec::Runner.configure do |config|
config.before(:suite) do
end

config.before(:each) do
end

config.after(:each) do
end

config.after(:suite) do
end
end

Redcar.plugin_manager.load("application_swt")
2 changes: 1 addition & 1 deletion plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb
@@ -1,5 +1,5 @@

require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

include Redcar

Expand Down
6 changes: 1 addition & 5 deletions plugins/auto_indenter/spec/spec_helper.rb
@@ -1,5 +1 @@
$:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')

require 'redcar'
Redcar.environment = :test
Redcar.load_unthreaded
Redcar.plugin_manager.load("auto_indenter")
2 changes: 1 addition & 1 deletion plugins/core/spec/core/base_storage_spec.rb
@@ -1,5 +1,5 @@

require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Plugin::BaseStorage do

Expand Down
2 changes: 1 addition & 1 deletion plugins/core/spec/core/gui_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Gui do
before do
Expand Down
3 changes: 2 additions & 1 deletion plugins/core/spec/core/observable_spec.rb
@@ -1,4 +1,5 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")

require "spec_helper"

describe Redcar::Observable do
class SeeMe
Expand Down
2 changes: 1 addition & 1 deletion plugins/core/spec/core/persistent_cache_spec.rb
@@ -1,5 +1,5 @@

require File.join(File.dirname(__FILE__), *%w".. .. lib core persistent_cache")
require "spec_helper"

PersistentCache = Redcar::PersistentCache

Expand Down
2 changes: 1 addition & 1 deletion plugins/core/spec/core/shared_storage_spec.rb
@@ -1,5 +1,5 @@

require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Plugin::SharedStorage do

Expand Down
2 changes: 1 addition & 1 deletion plugins/core/spec/core/storage_spec.rb
@@ -1,5 +1,5 @@

require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Plugin::Storage do

Expand Down
4 changes: 1 addition & 3 deletions plugins/core/spec/core/task_queue_spec.rb
@@ -1,7 +1,5 @@

require 'java'

require File.join(File.dirname(__FILE__), *%w".. spec_helper")
require "spec_helper"

describe Redcar::TaskQueue do
before do
Expand Down
5 changes: 1 addition & 4 deletions plugins/core/spec/spec_helper.rb
@@ -1,8 +1,5 @@
$:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')

require 'redcar'
Redcar.environment = :test
Redcar.load_unthreaded
Redcar.plugin_manager.load("core")

class QuickTask < Redcar::Task
def initialize(id=nil)
Expand Down
2 changes: 1 addition & 1 deletion plugins/declarations/spec/declarations/file_spec.rb
@@ -1,5 +1,5 @@

require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

module Redcar
describe Declarations::File do
Expand Down
6 changes: 1 addition & 5 deletions plugins/declarations/spec/spec_helper.rb
@@ -1,5 +1 @@
$:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')

require 'redcar'
Redcar.environment = :test
Redcar.load_unthreaded
Redcar.plugin_manager.load("declarations")
@@ -1,5 +1,5 @@

require File.join(File.dirname(__FILE__), %w".. .. spec_helper")
require "spec_helper"

describe Redcar::Document::Indentation do
class MockDoc
Expand Down
2 changes: 1 addition & 1 deletion plugins/edit_view/spec/edit_view/document_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::Document do
class TestEditView
Expand Down
5 changes: 1 addition & 4 deletions plugins/edit_view/spec/spec_helper.rb
@@ -1,5 +1,2 @@
$:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')

require 'redcar'
Redcar.environment = :test
Redcar.load_unthreaded
Redcar.plugin_manager.load("edit_view")
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require "spec_helper"

describe Redcar::EditViewSWT::WordMoveListener do
before do
Expand Down

0 comments on commit b690f7c

Please sign in to comment.