Module: Ajax::RSpec

Defined in:
lib/ajax/rspec.rb,
lib/ajax/rspec/helpers.rb,
lib/ajax/rspec/extension.rb

Overview

RSpec integration. Add a before filter to disable Ajax before all tests. Make the methods in Ajax::RSpec::Extension available in your example groups.

Call Ajax::RSpec.setup to retry adding the test integration. This can be useful if RSpec is not defined at the time that Ajax is initialized.

Defined Under Namespace

Modules: Extension, Helpers

Class Method Summary collapse

Class Method Details

.setupObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ajax/rspec.rb', line 10

def self.setup
  if defined?(::RSpec)
    ::RSpec.configure do |c|
      c.include(Ajax::RSpec::Extension)
      c.before :all do
        Ajax.enabled = false
      end
    end
  elsif defined?(::Spec::Runner)
    ::Spec::Runner.configure do |c|
      c.include(Ajax::RSpec::Extension)
      c.before :all do
        Ajax.enabled = false
      end
    end
  elsif defined?(ActiveSupport::TestCase)
    ActiveSupport::TestCase.send(:include, Ajax::RSpec::Extension) unless ActiveSupport::TestCase.include?(Ajax::RSpec::Extension)
  end
end