Sha256: bf199238825ad3279a05c594a164e372110dda7c1d491a1e6b9e30faada99183

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

module Volt
  class << self
    def spec_setup(app_path = '.')
      require 'volt'

      ENV['SERVER'] = 'true'
      ENV['VOLT_ENV'] = 'test'

      require 'volt/boot'

      # Require in app
      Volt.boot(app_path)

      unless RUBY_PLATFORM == 'opal'
        require 'volt/spec/capybara'

        setup_capybara(app_path)
      end


      # Setup the spec collection accessors
      # RSpec.shared_context "volt collections", {} do
      RSpec.shared_examples_for 'volt collections', {} do
        # Page conflicts with capybara's page method, so we call it the_page for now.
        # TODO: we need a better solution for page

        let(:the_page) { Model.new }
        let(:store) do
          @__store_accessed = true
          $page ||= Page.new
          $page.store
        end

        after do
          if @__store_accessed
            # Clear the database after each spec where we use store
            # @@db ||= Volt::DataStore.fetch
            # puts "DB CLASS: #{@@db.inspect}"
            # @@db.drop_database
            ::DataStore.new.drop_database

            $page.instance_variable_set('@store', nil)
          end
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
volt-0.9.0.pre3 lib/volt/spec/setup.rb
volt-0.9.0.pre2 lib/volt/spec/setup.rb
volt-0.9.0.pre1 lib/volt/spec/setup.rb
volt-0.8.27.beta9 lib/volt/spec/setup.rb
volt-0.8.27.beta8 lib/volt/spec/setup.rb
volt-0.8.27.beta7 lib/volt/spec/setup.rb