Skip to content

Commit

Permalink
first stabs at getting rspec back up to snuff
Browse files Browse the repository at this point in the history
  • Loading branch information
HamptonMakes committed Nov 5, 2015
1 parent 006b892 commit 138455b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
12 changes: 6 additions & 6 deletions Rakefile
@@ -1,20 +1,20 @@
require 'rake'
require 'rake/rdoctask'
require 'spec/rake/spectask'
require 'rdoc/task'
require 'rspec/core/rake_task'

desc 'Default: run specs.'
task :default => :spec

spec_files = Rake::FileList["spec/**/*_spec.rb"]

desc "Run specs"
Spec::Rake::SpecTask.new do |t|
t.spec_files = spec_files
t.spec_opts = ["-c"]
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = "spec/**/*_spec.rb"
t.rspec_opts = ["-c"]
end

desc "Generate code coverage"
Spec::Rake::SpecTask.new(:coverage) do |t|
RSpec::Core::RakeTask.new(:coverage) do |t|
t.spec_files = spec_files
t.rcov = true
t.rcov_opts = ['--exclude', 'spec,/var/lib/gems']
Expand Down
3 changes: 2 additions & 1 deletion TODO
@@ -1 +1,2 @@
* Generators need to be ported to Thor http://guides.rubyonrails.org/generators.html
* Generators need to be ported to the new syntax http://guides.rubyonrails.org/generators.html
* Add better strong parameters support
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.0.1
2.0.0
34 changes: 15 additions & 19 deletions spec/spec_helper.rb
Expand Up @@ -2,18 +2,14 @@

require 'rubygems'

require 'rack'
require "rails/all"
require 'rack/test'
require 'rails/test_help'
require 'rspec/rails'

begin
%w[spec rails/version action_pack active_record resourceful/maker
spec/rspec-rails/redirect_to spec/rspec-rails/render_template
action_controller action_controller/test_process action_controller/integration].each &method(:require)
rescue LoadError # If we are on rails3, these should work
require 'action_controller/testing/process'
require 'action_controller/testing/integration'
require 'active_support/testing/test_case'
end

Spec::Runner.configure do |config|
RSpec::Runner.configure do |config|
config.mock_with :mocha
end

Expand Down Expand Up @@ -226,13 +222,13 @@ def action_method(action)
end

module ControllerMethods
# From rspec-rails ControllerExampleGroup
# From rspec-rails ControllerExampleGroup

def render(options=nil, deprecated_status_or_extra_options=nil, &block)
if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
deprecated_status_or_extra_options = {}
end

unless block_given?
if @template.respond_to?(:finder)
(class << @template.finder; self; end).class_eval do
Expand All @@ -248,7 +244,7 @@ def render(options=nil, deprecated_status_or_extra_options=nil, &block)
@first_render ||= args[0] unless args[0] =~ /^layouts/
@_first_render ||= args[0] unless args[0] =~ /^layouts/
end

define_method :_pick_template do |*args|
@_first_render ||= args[0] unless args[0] =~ /^layouts/
PickedTemplate.new
Expand All @@ -258,13 +254,13 @@ def render(options=nil, deprecated_status_or_extra_options=nil, &block)

super(options, deprecated_status_or_extra_options, &block)
end

class PickedTemplate
def render_template(*ignore_args); end
def render_partial(*ignore_args); end
end
end

end

module Spec::Example::ExampleGroupMethods
Expand All @@ -275,7 +271,7 @@ def should_render_html(action)
response.content_type.should == 'text/html'
end
end

def should_render_js(action)
it "should render JS for #{action_string(action)}" do
action_method(action)[action, action_params(action, :format => 'js')]
Expand Down Expand Up @@ -311,7 +307,7 @@ class IntegrationExampleGroup < Spec::Example::ExampleGroup
include ActionController::TestProcess
include ActionController::Assertions
include RailsMocks

# Need this helper, because we made current_objects private
def current_objects
controller.instance_eval("current_objects")
Expand All @@ -321,7 +317,7 @@ def current_objects
def current_object
controller.instance_eval("current_object")
end

ExampleGroupFactory.register(:integration, self)
end
end

0 comments on commit 138455b

Please sign in to comment.