rspec_generator 0.5.13 → 0.5.14
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.
- data/lib/rspec_on_rails.rb +7 -0
- data/rspec_generator.rb +17 -4
- data/templates/rspec.rake +13 -0
- data/templates/script/rails_spec +11 -0
- data/templates/script/rails_spec_runner +48 -0
- data/templates/spec_helper.rb +1 -1
- data/{lib → templates}/test2spec_help.rb +0 -0
- metadata +7 -4
data/lib/rspec_on_rails.rb
CHANGED
@@ -16,6 +16,12 @@ module Spec
|
|
16
16
|
|
17
17
|
class ExecutionContext
|
18
18
|
include Spec::ControllerExecution
|
19
|
+
include ActionController::TestProcess
|
20
|
+
|
21
|
+
def tag(*opts)
|
22
|
+
opts = opts.size > 1 ? opts.last.merge({ :tag => opts.first.to_s }) : opts.first
|
23
|
+
tag = find_tag(opts)
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
21
27
|
class Context
|
@@ -68,6 +74,7 @@ end
|
|
68
74
|
module ActionController
|
69
75
|
class TestResponse
|
70
76
|
def should_render(expected=nil)
|
77
|
+
expected = expected.to_s unless expected.nil?
|
71
78
|
rendered = expected ? rendered_file(!expected.include?('/')) : rendered_file
|
72
79
|
expected.should_equal rendered
|
73
80
|
end
|
data/rspec_generator.rb
CHANGED
@@ -1,18 +1,31 @@
|
|
1
|
-
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
# This generator adds the basic spec_helper.rb,
|
4
|
+
# rails_spec for faster spec invocation
|
2
5
|
# and rake tasks required to use RSpec with Rails
|
3
6
|
class RspecGenerator < Rails::Generator::Base
|
7
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
8
|
+
Config::CONFIG['ruby_install_name'])
|
9
|
+
|
4
10
|
def initialize(runtime_args, runtime_options = {})
|
5
11
|
super
|
6
12
|
end
|
7
13
|
|
8
14
|
def manifest
|
9
15
|
record do |m|
|
16
|
+
script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
|
17
|
+
|
18
|
+
# The rails_spec runner and client scripts
|
19
|
+
m.file 'script/rails_spec', 'script/rails_spec', script_options
|
20
|
+
m.file 'script/rails_spec_runner', 'script/rails_spec_runner', script_options
|
21
|
+
|
10
22
|
# The spec helper and Rake tasks
|
11
23
|
m.directory 'spec'
|
12
|
-
m.template
|
13
|
-
m.file
|
24
|
+
m.template 'spec_helper.rb', 'spec/spec_helper.rb'
|
25
|
+
m.file 'test2spec.erb', 'spec/test2spec.erb'
|
26
|
+
m.file 'test2spec_help.rb', 'test/test2spec_help.rb'
|
14
27
|
m.directory 'lib/tasks'
|
15
|
-
m.template
|
28
|
+
m.template 'rspec.rake', 'lib/tasks/rspec.rake'
|
16
29
|
|
17
30
|
# Copy out the rspec_model generator
|
18
31
|
m.directory 'vendor/generators/rspec_model/templates'
|
data/templates/rspec.rake
CHANGED
@@ -32,4 +32,17 @@ namespace :spec do
|
|
32
32
|
]
|
33
33
|
t.spec_opts = ["--format", "specdoc"]
|
34
34
|
end
|
35
|
+
|
36
|
+
namespace :db do
|
37
|
+
namespace :fixtures do
|
38
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
39
|
+
task :load => :environment do
|
40
|
+
require 'active_record/fixtures'
|
41
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
42
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
43
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
35
48
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "drb/drb"
|
4
|
+
|
5
|
+
begin
|
6
|
+
DRb.start_service
|
7
|
+
rails_spec_server = DRbObject.new_with_uri("druby://localhost:8989")
|
8
|
+
rails_spec_server.run(ARGV, STDERR, STDOUT)
|
9
|
+
rescue DRb::DRbConnError
|
10
|
+
puts "No rails_spec_runner is running. Please start one via 'script/rails_spec_runner'"
|
11
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../../lib'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'drb/drb'
|
5
|
+
require 'rbconfig'
|
6
|
+
require 'spec'
|
7
|
+
|
8
|
+
module Spec
|
9
|
+
module Runner
|
10
|
+
class RailsSpecServer
|
11
|
+
def run(args, stderr, stdout)
|
12
|
+
puts "HALLO"
|
13
|
+
puts self
|
14
|
+
Dispatcher.reset_application!
|
15
|
+
|
16
|
+
$context_runner = OptionParser.create_context_runner(args, false, stderr, stdout)
|
17
|
+
args.each do |file_or_dir|
|
18
|
+
if File.directory?(file_or_dir)
|
19
|
+
Dir["#{file_or_dir}/**/*.rb"].each do |file|
|
20
|
+
load file
|
21
|
+
end
|
22
|
+
else
|
23
|
+
load file_or_dir
|
24
|
+
end
|
25
|
+
end
|
26
|
+
$context_runner.run(false) unless args.empty?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
puts "Loading Rails environment"
|
32
|
+
|
33
|
+
ENV["RAILS_ENV"] = "test"
|
34
|
+
require File.dirname(__FILE__) + '/../config/environment'
|
35
|
+
Dependencies.mechanism = :load
|
36
|
+
|
37
|
+
def restart_test_server
|
38
|
+
puts "restarting"
|
39
|
+
config = ::Config::CONFIG
|
40
|
+
ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
|
41
|
+
command_line = [ruby, $0, ARGV].flatten.join(' ')
|
42
|
+
exec(command_line)
|
43
|
+
end
|
44
|
+
|
45
|
+
trap("USR2") { restart_test_server }
|
46
|
+
puts "Ready"
|
47
|
+
DRb.start_service("druby://localhost:8989", Spec::Runner::RailsSpecServer.new)
|
48
|
+
DRb.thread.join
|
data/templates/spec_helper.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rspec_generator
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.5.14
|
7
|
+
date: 2006-07-14 00:00:00 -05:00
|
8
8
|
summary: RSpec plugin and generator for Ruby on Rails
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -32,12 +32,13 @@ files:
|
|
32
32
|
- lib/controller_mixin.rb
|
33
33
|
- lib/fixture_loading.rb
|
34
34
|
- lib/rspec_on_rails.rb
|
35
|
-
- lib/test2spec_help.rb
|
36
35
|
- templates/rspec.rake
|
37
36
|
- templates/rspec_controller
|
38
37
|
- templates/rspec_model
|
38
|
+
- templates/script
|
39
39
|
- templates/spec_helper.rb
|
40
40
|
- templates/test2spec.erb
|
41
|
+
- templates/test2spec_help.rb
|
41
42
|
- templates/rspec_controller/rspec_controller_generator.rb
|
42
43
|
- templates/rspec_controller/templates
|
43
44
|
- templates/rspec_controller/USAGE
|
@@ -46,6 +47,8 @@ files:
|
|
46
47
|
- templates/rspec_model/templates
|
47
48
|
- templates/rspec_model/USAGE
|
48
49
|
- templates/rspec_model/templates/model_spec.rb
|
50
|
+
- templates/script/rails_spec
|
51
|
+
- templates/script/rails_spec_runner
|
49
52
|
- CHANGES
|
50
53
|
- Rakefile
|
51
54
|
- README
|
@@ -69,5 +72,5 @@ dependencies:
|
|
69
72
|
requirements:
|
70
73
|
- - "="
|
71
74
|
- !ruby/object:Gem::Version
|
72
|
-
version: 0.5.
|
75
|
+
version: 0.5.14
|
73
76
|
version:
|