Module: Teaspoon

Defined in:
lib/teaspoon/driver/browserstack.rb,
lib/teaspoon/suite.rb,
lib/teaspoon-devkit.rb,
lib/teaspoon/driver.rb,
lib/teaspoon/engine.rb,
lib/teaspoon/result.rb,
lib/teaspoon/runner.rb,
lib/teaspoon/server.rb,
lib/teaspoon/console.rb,
lib/teaspoon/utility.rb,
lib/teaspoon/version.rb,
lib/teaspoon/coverage.rb,
lib/teaspoon/exporter.rb,
lib/teaspoon/registry.rb,
lib/teaspoon/formatter.rb,
lib/teaspoon/framework.rb,
lib/teaspoon/deprecated.rb,
lib/teaspoon/exceptions.rb,
lib/teaspoon/driver/base.rb,
lib/teaspoon/environment.rb,
lib/teaspoon/command_line.rb,
lib/teaspoon/configuration.rb,
lib/teaspoon/formatter/dot.rb,
lib/teaspoon/formatter/tap.rb,
lib/teaspoon/formatter/base.rb,
lib/teaspoon/formatter/json.rb,
lib/teaspoon/framework/base.rb,
lib/teaspoon/driver/selenium.rb,
lib/teaspoon/formatter/clean.rb,
lib/teaspoon/formatter/junit.rb,
lib/teaspoon/formatter/pride.rb,
lib/teaspoon/formatter/tap_y.rb,
lib/teaspoon/instrumentation.rb,
lib/teaspoon/driver/phantomjs.rb,
lib/teaspoon/formatter/snowday.rb,
lib/teaspoon/formatter/teamcity.rb,
lib/teaspoon/formatter/rspec_html.rb,
lib/teaspoon/registry/has_default.rb,
lib/teaspoon/formatter/documentation.rb,
lib/teaspoon/formatter/swayze_or_oprah.rb,
lib/teaspoon/formatter/modules/report_module.rb,
lib/generators/teaspoon/install/install_generator.rb

Overview

Need to have BrowserStackLocal binary (www.browserstack.com/local-testing#command-line) running in the background to use this driver.

Defined Under Namespace

Modules: Driver, Environment, Formatter, Framework, Generators, Registry, SprocketsInstrumentation, Utility Classes: AssetNotServableError, CommandLine, Configuration, Console, Coverage, CoverageResultsNotFoundError, DependencyError, DriverOptionsError, Engine, EnvironmentNotFound, Error, Exporter, Failure, FileWriteError, Instrumentation, IstanbulNotFoundError, MissingDependencyError, NotFoundInRegistry, Result, Runner, RunnerError, Server, ServerError, Suite, SuiteController, UnknownCoverage, UnknownDriver, UnknownFormatter, UnknownFramework, UnknownFrameworkVersion, UnknownSuite, UnspecifiedDependencies, UnspecifiedFramework

Constant Summary collapse

DEV_PATH =
File.expand_path("../../", __FILE__)
SPEC_HELPER =
File.join(DEV_PATH, "spec", "spec_helper")
FIXTURE_PATH =
File.join(DEV_PATH, "spec", "javascripts", "fixtures")
RAKEFILE =
File.join(DEV_PATH, "Rakefile")
RESULT_ATTRS =
[
  :type,
  :suite,
  :label,
  :status,
  :skipped,
  :link,
  :message,
  :trace,
  :elapsed,
  :total,
  :start,
  :level,
  :coverage,
  :original_json,
]
VERSION =
"1.2.1"
@@configured =
false
@@configuration =
Configuration

Class Method Summary collapse

Class Method Details

.abort(message = nil, code = 1) ⇒ Object



8
9
10
11
# File 'lib/teaspoon/utility.rb', line 8

def self.abort(message = nil, code = 1)
  STDOUT.print("#{message}\n") if message
  exit(code)
end

.configure {|@@configuration| ... } ⇒ Object

Yields:

  • (@@configuration)


167
168
169
170
171
# File 'lib/teaspoon/configuration.rb', line 167

def self.configure
  yield @@configuration
  @@configured = true
  @@configuration.override_from_env(ENV)
end

.dep(message, category = nil) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/teaspoon/deprecated.rb', line 11

def self.dep(message, category = nil)
  return if Teaspoon.configured
  if category
    return if @dep_notified[category]
    @dep_notified[category] = true if category
  end
  puts "WARNING: Deprecated - #{message}"
end

.load_teaspoon_tasksObject



18
19
20
21
22
# File 'lib/teaspoon-devkit.rb', line 18

def self.load_teaspoon_tasks
  if !loaded_from_teaspoon_root?
    load File.join(RAKEFILE)
  end
end

.loaded_from_teaspoon_root?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/teaspoon-devkit.rb', line 14

def self.loaded_from_teaspoon_root?
  Dir.pwd == DEV_PATH
end

.require_dummy!Object



7
8
9
10
11
12
# File 'lib/teaspoon-devkit.rb', line 7

def self.require_dummy!
  unless defined?(Rails)
    ENV["RAILS_ROOT"] = File.join(DEV_PATH, "spec", "dummy")
    require File.join(ENV["RAILS_ROOT"], "config", "environment")
  end
end

.rootObject



4
5
6
# File 'lib/teaspoon/utility.rb', line 4

def self.root
  defined?(Rails) ? Rails.root : Pathname.new(Dir.pwd)
end

.setup(&block) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/teaspoon/deprecated.rb', line 2

def self.setup(&block)
  Teaspoon.dep(
    "Teaspoon.setup is deprecated, use Teaspoon.configure instead. The /initializer/teaspoon.rb file should be " +
    "removed, and a new teaspoon_env.rb file should be created by running the install generator."
  )
  configure(&block)
end

.setup_framework_tasks(options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/teaspoon-devkit.rb', line 24

def self.setup_framework_tasks(options)
  extend Rake::DSL

  framework = options[:framework]
  framework_name = options[:framework_name]
  framework_const = options[:framework_const]
  framework_root = options[:framework_root]
  framework_env = options[:framework_env]
  compile_assets = options[:compile_assets]

  namespace :teaspoon do
    namespace framework do
      desc "Run the #{framework_name} code examples"
      RSpec::Core::RakeTask.new(:spec) do |t|
        t.pattern = File.expand_path("spec/**/*_spec.rb", framework_root)
      end

      desc "Run the #{framework_name} javascript tests"
      task :jsspec do
        rails_env = File.expand_path("spec/dummy/config/environment.rb", DEV_PATH)
        cmd = "rake teaspoon TEASPOON_DEVELOPMENT=true TEASPOON_RAILS_ENV=#{rails_env} TEASPOON_ENV=#{framework_env}"

        # we shell out to another command so that it creates a pristine runtime environment
        IO.popen(cmd).each do |line|
          STDOUT.print(line)
        end.close

        exit(1) unless $?.success?
      end

      desc "Builds Teaspoon #{framework_name} into the distribution ready bundle"
      task build: "#{framework}:build:javascripts"

      namespace :build do
        desc "Compile Teaspoon #{framework_name} coffeescripts into javacripts"
        task javascripts: :environment do
          env = Rails.application.assets

          Array(compile_assets).each do |filename|
            asset = env.find_asset("teaspoon/#{filename}")
            base_destination = framework_const.asset_paths.first
            asset.write_to(File.expand_path("teaspoon-#{filename}", base_destination))
          end
        end
      end
    end
  end

  if !loaded_from_teaspoon_root?
    Rake::Task["release"].clear
  end

  desc "Build and push teaspoon-#{framework} to Rubygems\n"
  task "release" => ["build", "release:guard_clean", "release:rubygem_push"] do
  end

  if !loaded_from_teaspoon_root?
    Rake::Task["default"].prerequisites.clear
    Rake::Task["default"].clear

    task default: ["teaspoon:#{framework}:spec", "teaspoon:#{framework}:jsspec"]
  end
end