Skip to content

Commit

Permalink
configure rspec with disable_monkey_patching!
Browse files Browse the repository at this point in the history
  • Loading branch information
Fivell committed Feb 17, 2017
1 parent 66b74fb commit 124c163
Show file tree
Hide file tree
Showing 99 changed files with 462 additions and 461 deletions.
2 changes: 1 addition & 1 deletion spec/bug_report_templates_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'

describe 'bug_report_templates' do
RSpec.describe 'bug_report_templates' do
subject do
Bundler.with_clean_env do
Dir.chdir(chdir_path) do
Expand Down
5 changes: 3 additions & 2 deletions spec/rails_helper.rb
Expand Up @@ -84,9 +84,9 @@ def with_translation(translation)

require ENV['RAILS_ROOT'] + '/config/environment'

require 'rspec/rails'
require 'RSpec.rails'

# Prevent Test::Unit's AutoRunner from executing during RSpec's rake task on
# Prevent Test::Unit's AutoRunner from executing during RSpec.s rake task on
# JRuby
Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)

Expand All @@ -101,6 +101,7 @@ def with_translation(translation)
ActiveAdmin.application.current_user_method = false

RSpec.configure do |config|
config.disable_monkey_patching!
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.render_views = false
Expand Down
6 changes: 3 additions & 3 deletions spec/requests/default_namespace_spec.rb
@@ -1,12 +1,12 @@
require 'rails_helper'

describe ActiveAdmin::Application, type: :request do
RSpec.describe ActiveAdmin::Application, type: :request do

include Rails.application.routes.url_helpers

[false, nil].each do |value|

describe "with a #{value} default namespace" do
RSpec.describe "with a #{value} default namespace" do

before(:all) do
@__original_application = ActiveAdmin.application
Expand All @@ -33,7 +33,7 @@

end

describe "with a test default namespace" do
RSpec.describe "with a test default namespace" do

before(:all) do
@__original_application = ActiveAdmin.application
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/javascript_spec.rb
Expand Up @@ -7,7 +7,7 @@
RbConfig::CONFIG['host_os'].include?('darwin') ? `/usr/libexec/java_home` : `which java`
java_installed = $?.success?

describe 'Javascript', type: :request, if: java_installed do
RSpec.describe 'Javascript', type: :request, if: java_installed do
let(:lint) {
JSLint::Lint.new \
paths: ['public/javascripts/**/*.js'],
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/memory_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'

describe "Memory Leak", type: :request, if: RUBY_ENGINE == 'ruby' do
RSpec.describe "Memory Leak", type: :request, if: RUBY_ENGINE == 'ruby' do
def count_instances_of(klass)
ObjectSpace.each_object(klass) { }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/stylesheets_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'

describe "Stylesheets", type: :request do
RSpec.describe "Stylesheets", type: :request do

require "sprockets"

Expand Down
4 changes: 2 additions & 2 deletions spec/support/active_admin_request_helpers.rb
Expand Up @@ -6,10 +6,10 @@ module ActiveAdminRequestHelpers
extend ActiveSupport::Concern

include ActionDispatch::Integration::Runner
include RSpec::Rails::TestUnitAssertionAdapter
include RSpec.:Rails::TestUnitAssertionAdapter
include ActionDispatch::Assertions
include Capybara::DSL
include RSpec::Matchers
include RSpec.:Matchers

def app
::Rails.application
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/abstract_view_factory_spec.rb
Expand Up @@ -2,12 +2,12 @@

require 'active_admin/abstract_view_factory'

describe ActiveAdmin::AbstractViewFactory do
RSpec.describe ActiveAdmin::AbstractViewFactory do

let(:view_factory){ ActiveAdmin::AbstractViewFactory.new }
let(:view){ Class.new }

describe "registering a new view key" do
RSpec.describe "registering a new view key" do
before do
view_factory.register my_new_view_class: view
end
Expand All @@ -30,7 +30,7 @@
end
end

describe "array syntax access" do
RSpec.describe "array syntax access" do
before do
view_factory.register my_new_view_class: view
end
Expand All @@ -45,7 +45,7 @@
end
end

describe "registering default views" do
RSpec.describe "registering default views" do
before do
ActiveAdmin::AbstractViewFactory.register my_default_view_class: view
end
Expand All @@ -59,7 +59,7 @@
end
end

describe "subclassing the ViewFactory" do
RSpec.describe "subclassing the ViewFactory" do
let(:subclass) do
ActiveAdmin::AbstractViewFactory.register my_subclassed_view: "From Parent"
Class.new(ActiveAdmin::AbstractViewFactory) do
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/action_builder_spec.rb
@@ -1,14 +1,14 @@
require 'rails_helper'

describe 'defining actions from registration blocks', type: :controller do
RSpec.describe 'defining actions from registration blocks', type: :controller do
let(:klass){ Admin::PostsController }
render_views # https://github.com/rspec/rspec-rails/issues/860
render_views # https://github.com/RSpec.RSpec.rails/issues/860

before do
@controller = klass.new
end

describe 'creates a member action' do
RSpec.describe 'creates a member action' do
before do
action!
reload_routes!
Expand Down Expand Up @@ -71,7 +71,7 @@
end
end

describe 'creates a collection action' do
RSpec.describe 'creates a collection action' do
before do
action!
reload_routes!
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/active_admin_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'

describe ActiveAdmin do
RSpec.describe ActiveAdmin do
%w(register register_page unload! load! routes).each do |method|
it "delegates ##{method} to application" do
expect(ActiveAdmin.application).to receive(method)
Expand Down
12 changes: 6 additions & 6 deletions spec/unit/application_spec.rb
@@ -1,11 +1,11 @@
require 'rails_helper'
require 'fileutils'

describe ActiveAdmin::Application do
RSpec.describe ActiveAdmin::Application do

let(:application) do
ActiveAdmin::Application.new.tap do |app|
# Manually override the load paths becuase RSpec messes these up
# Manually override the load paths becuase RSpec.messes these up
app.load_paths = [File.expand_path('app/admin', Rails.root)]
end
end
Expand Down Expand Up @@ -95,7 +95,7 @@
expect(application.order_clause).to eq ActiveAdmin::OrderClause
end

describe "authentication settings" do
RSpec.describe "authentication settings" do

it "should have no default current_user_method" do
expect(application.current_user_method).to eq false
Expand All @@ -114,7 +114,7 @@
end
end

describe "files in load path" do
RSpec.describe "files in load path" do
it "should load files in the first level directory" do
expect(application.files).to include(File.expand_path("app/admin/dashboard.rb", Rails.root))
end
Expand All @@ -127,7 +127,7 @@
end
end

describe "#namespace" do
RSpec.describe "#namespace" do

it "should yield a new namespace" do
application.namespace :new_namespace do |ns|
Expand Down Expand Up @@ -157,7 +157,7 @@
end
end

describe "#register_page" do
RSpec.describe "#register_page" do
it "finds or create the namespace and register the page to it" do
namespace = double
expect(application).to receive(:namespace).with("public").and_return namespace
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/asset_registration_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'

describe ActiveAdmin::AssetRegistration do
RSpec.describe ActiveAdmin::AssetRegistration do
include ActiveAdmin::AssetRegistration

before do
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/authorization/authorization_adapter_spec.rb
@@ -1,18 +1,18 @@
require 'rails_helper'

describe ActiveAdmin::AuthorizationAdapter do
RSpec.describe ActiveAdmin::AuthorizationAdapter do

let(:adapter) { ActiveAdmin::AuthorizationAdapter.new(double, double) }

describe "#authorized?" do
RSpec.describe "#authorized?" do

it "should always return true" do
expect(adapter.authorized?(:read, "Resource")).to eq true
end

end

describe "#scope_collection" do
RSpec.describe "#scope_collection" do

it "should return the collection unscoped" do
collection = double
Expand All @@ -21,7 +21,7 @@

end

describe "using #normalized in a subclass" do
RSpec.describe "using #normalized in a subclass" do

let(:auth_class) do
Class.new(ActiveAdmin::AuthorizationAdapter) do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/authorization/controller_authorization_spec.rb
@@ -1,7 +1,7 @@
require 'rails_helper'
Auth = ActiveAdmin::Authorization

describe Admin::PostsController, "Controller Authorization", type: :controller do
RSpec.describe Admin::PostsController, "Controller Authorization", type: :controller do

let(:authorization){ controller.send(:active_admin_authorization) }

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/authorization/index_overriding_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Admin::PostsController, 'Index overriding', type: :controller do
RSpec.describe Admin::PostsController, 'Index overriding', type: :controller do
before do
controller.instance_eval do
def index
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/auto_link_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'

describe "auto linking resources" do
RSpec.describe "auto linking resources" do
include ActiveAdmin::ViewHelpers::ActiveAdminApplicationHelper
include ActiveAdmin::ViewHelpers::AutoLinkHelper
include ActiveAdmin::ViewHelpers::DisplayHelper
Expand Down
12 changes: 6 additions & 6 deletions spec/unit/batch_actions/resource_spec.rb
@@ -1,14 +1,14 @@
require 'rails_helper'

describe ActiveAdmin::BatchActions::ResourceExtension do
RSpec.describe ActiveAdmin::BatchActions::ResourceExtension do

let(:resource) do
namespace = ActiveAdmin::Namespace.new(ActiveAdmin::Application.new, :admin)
namespace.batch_actions = true
namespace.register(Post)
end

describe "default action" do
RSpec.describe "default action" do

it "should have the default action by default" do
expect(resource.batch_actions.size).to eq 1
Expand All @@ -17,7 +17,7 @@

end

describe "adding a new batch action" do
RSpec.describe "adding a new batch action" do

before do
resource.clear_batch_actions!
Expand All @@ -40,7 +40,7 @@

end

describe "removing batch action" do
RSpec.describe "removing batch action" do

before do
resource.remove_batch_action :destroy
Expand All @@ -52,7 +52,7 @@

end

describe "#display_if_block" do
RSpec.describe "#display_if_block" do

it "should return true by default" do
action = ActiveAdmin::BatchAction.new :default, "Default"
Expand All @@ -66,7 +66,7 @@

end

describe "batch action priority" do
RSpec.describe "batch action priority" do

it "should have a default priority" do
action = ActiveAdmin::BatchAction.new :default, "Default"
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/batch_actions/settings_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'

describe "Batch Actions Settings" do
RSpec.describe "Batch Actions Settings" do
let(:app) { ActiveAdmin::Application.new }
let(:ns) { ActiveAdmin::Namespace.new(app, "Admin") }
let(:post_resource) { ns.register Post }
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/belongs_to_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'

describe ActiveAdmin::Resource::BelongsTo do
RSpec.describe ActiveAdmin::Resource::BelongsTo do

let(:user_config){ ActiveAdmin.register User }
let(:post_config){ ActiveAdmin.register Post do belongs_to :user end }
Expand All @@ -10,7 +10,7 @@
expect(belongs_to.owner).to eq post_config
end

describe "finding the target" do
RSpec.describe "finding the target" do
context "when the resource has been registered" do
it "should return the target resource" do
expect(belongs_to.target).to eq user_config
Expand Down Expand Up @@ -47,7 +47,7 @@ class Blog::Author
expect(belongs_to).to be_optional
end

describe "controller" do
RSpec.describe "controller" do
let(:controller) { post_config.controller.new }
before do
user = User.create!
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/cancan_adapter_spec.rb
@@ -1,8 +1,8 @@
require 'rails_helper'

describe ActiveAdmin::CanCanAdapter do
RSpec.describe ActiveAdmin::CanCanAdapter do

describe "full integration" do
RSpec.describe "full integration" do

let(:application){ ActiveAdmin::Application.new }
let(:namespace){ ActiveAdmin::Namespace.new(application, "Admin") }
Expand Down

0 comments on commit 124c163

Please sign in to comment.