Sha256: 6a91bb337b6389b4bf5fa8600caa43b75070b22f1862ca14653233e8c22695b2

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'rspec'
require 'rack/test'
require 'timecop'

require 'lookout/rack/test'
module Lookout::Rack::Test
  module RSpec
  end
end

require 'lookout/rack/test/rspec/email_helpers'
require 'lookout/rack/test/rspec/fake_request'
require 'lookout/rack/test/rspec/model_examples'

module Lookout
  module Rack
    module Test
      module RSpec
        # Takes one argument, the Models class (or module) that has a .setup and
        # .unsetup method
        def setup_models(models)
          ::RSpec.configure do |c|
            c.around(:each, :speed => :slow) do |example|
              models.setup
              example.run
              models.unsetup
            end
      
            c.before(:all, :speed => :slow) do
              require 'lookout/rack/test/load_factories'
            end
          end
        end
  
        # Takes one argument, the application (e.g., SinatraApplication)
        def setup_routes(application)
          ::RSpec.configure do |c|
            c.include(::Rack::Test::Methods, :type => :route)
  
            require 'lookout/rack/test/rspec/route_helper'
            $application_class = application
            c.include(::RouteHelper, :type => :route)
          end
        end
  
        def configure_rspec
          ::RSpec.configure do |c|
            c.around(:each, :timefreeze => true) do |example|
              ::Timecop.freeze do
                example.run
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookout-rack-test-1.1.0 lib/lookout/rack/test/rspec.rb
lookout-rack-test-1.0.1 lib/lookout/rack/test/rspec.rb