Rails "test" environment has access to non-included methods
<p>I'm using the fantastic <a href="https://github.com/krisleech/wisper/" rel="nofollow">wisper gem</a> to react to changes in my models(Rails 4.1).</p>

<pre class="lang-rb prettyprint-override"><code>Class Transaction &lt; ActiveRecord::Base
  #include Wisper::Publisher
  after_save { broadcast(:transaction_saved)}

end
</code></pre>

<p>Here <code>broadcast</code> is a method provided by the <code>Wisper::Publisher</code> module, the inclusion of which is commented out as you can see above.</p>

<p>Due to all this, I'm not understanding how a test like this one can pass without complaining about "<code>broadcast</code> method missing":</p>

<pre class="lang-rb prettyprint-override"><code>require 'test_helper'
class TransactionTest &lt; ActiveSupport::TestCase
  include GeneralHelper # this doesnt include any other module
  def setup
    @tr = Transaction.create(...)
  end
  def test_transaction_method
    @tr.update_attributes(amount:100)
  end
end
</code></pre>

<p>As expected <code>development/production</code> environments <em>do</em> complain about method missing</p>

<p>-- Update
<code>test/test_helper.rb</code></p>

<pre class="lang-rb prettyprint-override"><code>ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "mocha/mini_test"
require 'minitest/reporters'
Minitest::Reporters.use!(
  Minitest::Reporters::ProgressReporter.new,
  ENV,
  Minitest.backtrace_filter)

# Capybara and poltergeist integration
require "capybara/rails"
require "capybara/poltergeist"
Capybara.javascript_driver = :poltergeist


class ActiveSupport::TestCase
  ActiveRecord::Migration.check_pending!
  include FactoryGirl::Syntax::Methods

  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  #
  # Note: You'll currently still have to declare fixtures explicitly in integration tests
  # -- they do not yet inherit this setting
  fixtures :all

  # Add more helper methods to be used by all tests here...
  def assert_valid(model, msg = nil)
    msg = message(msg) { "Expected #{model} to be valid, but got errors: #{errors}." }
    valid = model.valid?
    errors = model.errors.full_messages.join(', ')
    assert valid, msg
  end
end
</code></pre>

<p><code>Gemfile</code></p>

<pre class="lang-rb prettyprint-override"><code>source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.13'

# Use pg as the database for Active Record
gem 'pg'

# Use SCSS for stylesheets
gem 'sass-rails'#, '~&gt; 4.0.2'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '&gt;= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~&gt; 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-turbolinks'

#gem 'bootstrap-sass'
gem 'font-awesome-rails'
gem 'simple-line-icons-rails'
gem 'active_link_to'

gem 'country_select', github: 'stefanpenner/country_select'
gem 'chronic'

gem 'will_paginate'#, '3.0.4'
gem 'will_paginate-bootstrap'


#Editable
#gem 'bootstrap-editable-rails'
#Encryption
gem 'aes'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~&gt; 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
gem 'bcrypt', '~&gt; 3.1.7'

gem 'redis'
gem 'firebase'
# Use unicorn as the app server
gem 'puma'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

gem 'recipient_interceptor'

group :test, :development do
  #gem 'rspec-rails'
  #gem 'rspec-its'
  gem 'pry'
  gem 'pry-nav'
  gem 'pry-rails'
end

gem 'nokogiri'
gem 'faker'
gem 'haml'
gem 'slim'
gem 'rack-mini-profiler'
gem 'newrelic_rpm'
#gem 'appsignal'

group :test do
  gem 'capybara'
  #gem 'capybara-webkit'
  gem 'factory_girl_rails'
  #gem "connection_pool"
  #gem "launchy"
  gem "minitest"
  gem "minitest-reporters"
  gem "mocha"
  gem "poltergeist"
  #gem "shoulda"
end

gem 'axlsx'
gem 'prawn'
gem 'active_model_serializers'

gem 'card-rails'

gem 'rails_12factor', group: :production
#gem 'twitter-typeahead-rails', :git =&gt; "git://github.com/yourabi/twitter-typeahead-rails.git"
gem 'rack-cors', :require =&gt; 'rack/cors'

gem 'sidekiq'
gem 'rest-client'
gem 'nest'
gem 'redic'
gem 'fog'
gem 'aws-sdk'
gem 'twilio-ruby'
gem 'react-rails', '~&gt; 1.0'
gem 'wisper', '2.0.0.rc1'
gem 'ruby-prof'
gem 'le'
gem 'mechanize'
gem 'mandrill-api'
gem 'business_time'
gem 'paleta'
gem "aftership", "~&gt; 4.3.1"
</code></pre>