teaspoon 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/MIT.LICENSE +1 -1
  3. data/README.md +46 -377
  4. data/app/assets/javascripts/teaspoon-jasmine.js +200 -194
  5. data/app/assets/javascripts/teaspoon-mocha.js +183 -185
  6. data/app/assets/javascripts/teaspoon-qunit.js +201 -193
  7. data/app/assets/javascripts/teaspoon-teaspoon.js +10 -10
  8. data/app/assets/javascripts/teaspoon/base/fixture.coffee +0 -1
  9. data/app/assets/javascripts/teaspoon/base/hook.coffee +7 -6
  10. data/app/assets/javascripts/teaspoon/qunit.coffee +10 -0
  11. data/app/controllers/teaspoon/suite_controller.rb +3 -4
  12. data/app/views/teaspoon/suite/_boot.html.erb +1 -1
  13. data/app/views/teaspoon/suite/_boot_require_js.html.erb +1 -0
  14. data/bin/teaspoon +1 -1
  15. data/config/routes.rb +4 -14
  16. data/lib/generators/teaspoon/install/install_generator.rb +22 -11
  17. data/lib/generators/teaspoon/install/templates/jasmine/{env_comments.rb → env_comments.rb.tt} +10 -5
  18. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +5 -5
  19. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +5 -5
  20. data/lib/generators/teaspoon/install/templates/mocha/{env_comments.rb → env_comments.rb.tt} +10 -5
  21. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +6 -5
  22. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +6 -5
  23. data/lib/generators/teaspoon/install/templates/qunit/{env_comments.rb → env_comments.rb.tt} +10 -5
  24. data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +5 -5
  25. data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +5 -5
  26. data/lib/tasks/teaspoon.rake +1 -1
  27. data/lib/teaspoon/command_line.rb +37 -40
  28. data/lib/teaspoon/configuration.rb +27 -30
  29. data/lib/teaspoon/configuration.rb.orig +187 -0
  30. data/lib/teaspoon/console.rb +31 -17
  31. data/lib/teaspoon/coverage.rb +2 -3
  32. data/lib/teaspoon/deprecated.rb +13 -8
  33. data/lib/teaspoon/drivers/base.rb +2 -2
  34. data/lib/teaspoon/drivers/capybara_webkit_driver.rb +33 -0
  35. data/lib/teaspoon/drivers/phantomjs/runner.js +2 -2
  36. data/lib/teaspoon/drivers/phantomjs_driver.rb +13 -4
  37. data/lib/teaspoon/drivers/selenium_driver.rb +3 -5
  38. data/lib/teaspoon/engine.rb +33 -5
  39. data/lib/teaspoon/environment.rb +2 -4
  40. data/lib/teaspoon/exceptions.rb +8 -5
  41. data/lib/teaspoon/formatters/base.rb +39 -27
  42. data/lib/teaspoon/formatters/clean_formatter.rb +0 -1
  43. data/lib/teaspoon/formatters/description.rb +36 -0
  44. data/lib/teaspoon/formatters/documentation_formatter.rb +2 -2
  45. data/lib/teaspoon/formatters/json_formatter.rb +1 -2
  46. data/lib/teaspoon/formatters/junit_formatter.rb +20 -20
  47. data/lib/teaspoon/formatters/modules/report_module.rb +4 -4
  48. data/lib/teaspoon/formatters/pride_formatter.rb +0 -1
  49. data/lib/teaspoon/formatters/rspec_html_formatter.rb +463 -0
  50. data/lib/teaspoon/formatters/snowday_formatter.rb +0 -1
  51. data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +5 -4
  52. data/lib/teaspoon/formatters/tap_formatter.rb +2 -3
  53. data/lib/teaspoon/formatters/tap_y_formatter.rb +20 -21
  54. data/lib/teaspoon/formatters/teamcity_formatter.rb +4 -5
  55. data/lib/teaspoon/instrumentation.rb +7 -7
  56. data/lib/teaspoon/result.rb +1 -3
  57. data/lib/teaspoon/runner.rb +1 -2
  58. data/lib/teaspoon/server.rb +2 -1
  59. data/lib/teaspoon/suite.rb +20 -17
  60. data/lib/teaspoon/utility.rb +1 -3
  61. data/lib/teaspoon/version.rb +1 -1
  62. data/spec/dummy/config/application.rb +14 -18
  63. data/spec/dummy/config/boot.rb +2 -6
  64. data/spec/dummy/config/environment.rb +3 -3
  65. data/spec/dummy/config/environments/development.rb +27 -13
  66. data/spec/dummy/config/environments/production.rb +79 -0
  67. data/spec/dummy/config/environments/test.rb +26 -13
  68. data/spec/dummy/config/routes.rb +1 -1
  69. data/spec/dummy/config/secrets.yml +22 -0
  70. data/spec/features/console_reporter_spec.rb +3 -8
  71. data/spec/features/hooks_spec.rb +17 -4
  72. data/spec/features/html_reporter_spec.rb +12 -1
  73. data/spec/features/install_generator_spec.rb +2 -3
  74. data/spec/features/instrumentation_spec.rb +11 -11
  75. data/spec/javascripts/teaspoon/base/teaspoon_spec.coffee +14 -1
  76. data/spec/spec_helper.rb +7 -4
  77. data/spec/teaspoon/command_line_spec.rb +19 -28
  78. data/spec/teaspoon/configuration_spec.rb +22 -14
  79. data/spec/teaspoon/console_spec.rb +79 -63
  80. data/spec/teaspoon/coverage_spec.rb +23 -23
  81. data/spec/teaspoon/drivers/capybara_webkit_driver_spec.rb +39 -0
  82. data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +10 -5
  83. data/spec/teaspoon/drivers/selenium_driver_spec.rb +10 -10
  84. data/spec/teaspoon/environment_spec.rb +28 -20
  85. data/spec/teaspoon/exceptions_spec.rb +4 -4
  86. data/spec/teaspoon/exporter_spec.rb +28 -28
  87. data/spec/teaspoon/formatters/base_spec.rb +29 -29
  88. data/spec/teaspoon/formatters/clean_formatter_spec.rb +1 -1
  89. data/spec/teaspoon/formatters/documentation_formatter_spec.rb +1 -1
  90. data/spec/teaspoon/formatters/dot_formatter_spec.rb +1 -1
  91. data/spec/teaspoon/formatters/json_formatter_spec.rb +7 -7
  92. data/spec/teaspoon/formatters/junit_formatter_spec.rb +10 -10
  93. data/spec/teaspoon/formatters/pride_formatter_spec.rb +1 -1
  94. data/spec/teaspoon/formatters/rspec_html_formatter_spec.rb +107 -0
  95. data/spec/teaspoon/formatters/snowday_formatter_spec.rb +1 -1
  96. data/spec/teaspoon/formatters/tap_formatter_spec.rb +1 -1
  97. data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +1 -1
  98. data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +27 -27
  99. data/spec/teaspoon/instrumentation_spec.rb +35 -29
  100. data/spec/teaspoon/result_spec.rb +40 -36
  101. data/spec/teaspoon/runner_spec.rb +23 -20
  102. data/spec/teaspoon/server_spec.rb +19 -16
  103. data/spec/teaspoon/suite_spec.rb +23 -9
  104. data/spec/teaspoon_env.rb +7 -12
  105. data/test/javascripts/teaspoon/qunit/models_test.coffee +6 -2
  106. data/vendor/assets/javascripts/support/chai-1.10.0.js +4800 -0
  107. data/vendor/assets/javascripts/support/chai-jq-0.0.7.js +524 -0
  108. data/vendor/assets/javascripts/support/chai.js +4435 -4349
  109. metadata +57 -54
  110. data/app/assets/javascripts/teaspoon-angular.js +0 -1299
  111. data/app/assets/javascripts/teaspoon/angular.coffee +0 -55
  112. data/app/assets/javascripts/teaspoon/angular/reporters/console.coffee +0 -11
  113. data/app/assets/javascripts/teaspoon/angular/reporters/html.coffee +0 -21
  114. data/spec/javascripts/angular_helper.coffee +0 -5
  115. data/spec/javascripts/teaspoon/angular/models_aspec.coffee +0 -95
  116. data/spec/javascripts/teaspoon/angular/reporters/html_aspec.coffee +0 -9
  117. data/vendor/assets/javascripts/angular/1.0.5.js +0 -26195
  118. data/vendor/assets/javascripts/angular/MIT-LICENSE +0 -22
@@ -1,27 +1,41 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # In the development environment your application's code is reloaded on
5
5
  # every request. This slows down response time but is perfect for development
6
6
  # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
8
 
9
- # Show full error reports and disable caching
10
- config.consider_all_requests_local = true
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
11
14
  config.action_controller.perform_caching = false
12
15
 
13
- # Print deprecation notices to the Rails logger
14
- config.active_support.deprecation = :log
16
+ # Don't care if the mailer can't send.
17
+ # config.action_mailer.raise_delivery_errors = false
15
18
 
16
- # Only use best-standards-support built into browsers
17
- config.action_dispatch.best_standards_support = :builtin
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
18
21
 
19
- # Do not compress assets
20
- config.assets.compress = false
22
+ # Raise an error on page load if there are pending migrations.
23
+ # config.active_record.migration_error = :page_load
21
24
 
22
- # Expands the lines which load the assets
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
23
28
  config.assets.debug = true
24
29
 
25
- # Eager loading
26
- config.eager_load = false
30
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
+ # yet still be able to expire them through the digest params.
32
+ config.assets.digest = true
33
+
34
+ # Adds additional error checking when serving assets at runtime.
35
+ # Checks for improperly declared sprockets dependencies.
36
+ # Raises helpful error messages.
37
+ config.assets.raise_runtime_errors = true
38
+
39
+ # Raises error for missing translations
40
+ # config.action_view.raise_on_missing_translations = true
27
41
  end
@@ -0,0 +1,79 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like
20
+ # NGINX, varnish or squid.
21
+ # config.action_dispatch.rack_cache = true
22
+
23
+ # Disable serving static files from the `/public` folder by default since
24
+ # Apache or NGINX already handles this.
25
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
26
+
27
+ # Compress JavaScripts and CSS.
28
+ config.assets.js_compressor = :uglifier
29
+ # config.assets.css_compressor = :sass
30
+
31
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
32
+ config.assets.compile = false
33
+
34
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
+ # yet still be able to expire them through the digest params.
36
+ config.assets.digest = true
37
+
38
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
39
+
40
+ # Specifies the header that your server uses for sending files.
41
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43
+
44
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45
+ # config.force_ssl = true
46
+
47
+ # Use the lowest log level to ensure availability of diagnostic information
48
+ # when problems arise.
49
+ config.log_level = :debug
50
+
51
+ # Prepend all log lines with the following tags.
52
+ # config.log_tags = [ :subdomain, :uuid ]
53
+
54
+ # Use a different logger for distributed setups.
55
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
56
+
57
+ # Use a different cache store in production.
58
+ # config.cache_store = :mem_cache_store
59
+
60
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61
+ # config.action_controller.asset_host = 'http://assets.example.com'
62
+
63
+ # Ignore bad email addresses and do not raise email delivery errors.
64
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65
+ # config.action_mailer.raise_delivery_errors = false
66
+
67
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68
+ # the I18n.default_locale when a translation cannot be found).
69
+ config.i18n.fallbacks = true
70
+
71
+ # Send deprecation notices to registered listeners.
72
+ config.active_support.deprecation = :notify
73
+
74
+ # Use default logging formatter so that PID and timestamp are not suppressed.
75
+ config.log_formatter = ::Logger::Formatter.new
76
+
77
+ # Do not dump schema after migrations.
78
+ # config.active_record.dump_schema_after_migration = false
79
+ end
@@ -1,5 +1,5 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # The test environment is used exclusively to run your application's
5
5
  # test suite. You never need to work with it otherwise. Remember that
@@ -7,23 +7,36 @@ Dummy::Application.configure do
7
7
  # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static file server for tests with Cache-Control for performance.
16
+ config.serve_static_files = true
17
+ config.static_cache_control = 'public, max-age=3600'
13
18
 
14
- # Show full error reports and disable caching
15
- config.consider_all_requests_local = true
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
16
21
  config.action_controller.perform_caching = false
17
22
 
18
- # Raise exceptions instead of rendering exception templates
23
+ # Raise exceptions instead of rendering exception templates.
19
24
  config.action_dispatch.show_exceptions = false
20
25
 
21
- # Disable request forgery protection in test environment
22
- config.action_controller.allow_forgery_protection = false
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ # config.action_mailer.delivery_method = :test
23
33
 
24
- # Print deprecation notices to the stderr
34
+ # Randomize the order test cases are executed.
35
+ config.active_support.test_order = :random
36
+
37
+ # Print deprecation notices to the stderr.
25
38
  config.active_support.deprecation = :stderr
26
39
 
27
- # Eager loading
28
- config.eager_load = false
40
+ # Raises error for missing translations
41
+ # config.action_view.raise_on_missing_translations = true
29
42
  end
@@ -1,2 +1,2 @@
1
- Dummy::Application.routes.draw do
1
+ Rails.application.routes.draw do
2
2
  end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: a28312cb73c1f3bc98f5fa393a6d8347d067ef9c24ac90f40e8ea98315d448cfd0ebcf9079b04eb77358afd81522a521ddc1c5bc30b31d3cbf812ef904dd55a2
15
+
16
+ test:
17
+ secret_key_base: 8fe67c730ce5c57f02cb83acf73e4d527b45e805639b2e9f56a6dc7cf579affa4838d75432903bbeb7f4766ec57d8392ff0f42e630615cbc2d564f8242a4471c
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -43,18 +43,13 @@ feature "testing with teaspoon in the console", aruba: true do
43
43
 
44
44
  scenario "displays coverage information" do
45
45
  pending("needs istanbul to be installed") unless Teaspoon::Instrumentation.executable
46
- pending("needs to be figured out")
47
- # for some reason when loaded in the specs the instrumentation isn't working, though it is working in practice
48
- # confirmed that no data is coming through to Teaspoon::Coverage in the result reported by the console reporter
49
- # confirmed that instrument=true is being added to the asset source urls
50
- # which means that our sprockets/rack shim doesn't work in this environment
51
46
  run_simple("bundle exec teaspoon -r ../../spec/teaspoon_env.rb --coverage=default app/assets/javascripts/integration/integration_spec.coffee", false)
52
47
 
53
48
  assert_partial_output("=============================== Coverage summary ===============================", all_output)
54
- assert_partial_output("Statements : 92.31% ( 12/13 )", all_output)
49
+ assert_partial_output("Statements : 95.83% ( 23/24 )", all_output)
55
50
  assert_partial_output("Branches : 100% ( 0/0 )", all_output)
56
- assert_partial_output("Functions : 75% ( 3/4 )", all_output)
57
- assert_partial_output("Lines : 92.31% ( 12/13 )", all_output)
51
+ assert_partial_output("Functions : 92.31% ( 12/13 )", all_output)
52
+ assert_partial_output("Lines : 95.83% ( 23/24 )", all_output)
58
53
  assert_partial_output("================================================================================", all_output)
59
54
  end
60
55
 
@@ -8,11 +8,12 @@ feature "testing hooks in the browser" do
8
8
  let(:app) { Dummy::Application }
9
9
  let(:suites) {{
10
10
  "suite1" => {block: proc{ |suite| suite.hook :before, &proc{ File.write(temp_file, "") } }},
11
- "suite2" => {block: proc{ |suite| suite.hook :after, &proc{ File.write(temp_file, "") } }}
11
+ "suite2" => {block: proc{ |suite| suite.hook :after, &proc{ File.write(temp_file, "") } }},
12
+ "suite3" => {block: proc{ |suite| suite.hook :with_arguments, &proc{ |args| File.write(temp_file, args["message"]) } }},
12
13
  }}
13
14
 
14
15
  before do
15
- Teaspoon.configuration.stub(:suite_configs).and_return(suites)
16
+ allow(Teaspoon.configuration).to receive(:suite_configs).and_return(suites)
16
17
  FileUtils.mkdir_p('tmp')
17
18
  File.delete(temp_file) if File.exists?(temp_file)
18
19
  expect(File.exists?(temp_file)).to eql(false)
@@ -28,7 +29,7 @@ feature "testing hooks in the browser" do
28
29
 
29
30
  scenario "gives me the expected results" do
30
31
  post("/teaspoon/suite1/before")
31
- expect(File.exists?(temp_file)).to be_true
32
+ expect(File.exists?(temp_file)).to be_truthy
32
33
  end
33
34
 
34
35
  end
@@ -39,9 +40,21 @@ feature "testing hooks in the browser" do
39
40
 
40
41
  scenario "gives me the expected results" do
41
42
  post("/teaspoon/suite2/after")
42
- expect(File.exists?(temp_file)).to be_true
43
+ expect(File.exists?(temp_file)).to be_truthy
43
44
  end
44
45
 
45
46
  end
46
47
 
48
+ describe "requesting a before hook with arguments (using POST)" do
49
+ let(:temp_file) { "tmp/before_hook_test" }
50
+ let(:message) { "Hello World" }
51
+ let(:params) do
52
+ { args: { message: message } }
53
+ end
54
+
55
+ scenario "gives me the expected results" do
56
+ post("/teaspoon/suite3/with_arguments", params)
57
+ expect(File.open(temp_file).gets.chomp).to eq(message)
58
+ end
59
+ end
47
60
  end
@@ -5,12 +5,23 @@ feature "testing with teaspoon in the browser", js: true do
5
5
  let(:spec_helper) { nil }
6
6
 
7
7
  before do
8
- Teaspoon.configuration.stub(:suite_configs).and_return "integration" => {block: proc{ |suite|
8
+ Teaspoon::Suite.instance_variable_set(:@all, nil)
9
+ allow(Teaspoon.configuration).to receive(:suite_configs).and_return "integration" => {block: proc{ |suite|
9
10
  suite.matcher = "spec/dummy/app/assets/javascripts/integration/*_spec.{js,js.coffee,coffee}"
10
11
  suite.helper = spec_helper
11
12
  }}
12
13
  end
13
14
 
15
+ scenario "lists the suites" do
16
+ visit "/teaspoon"
17
+
18
+ within("#teaspoon-suite-list") do
19
+ expect(page).to have_text("integration")
20
+ expect(page).to have_text("integration/integration_spec.js")
21
+ end
22
+
23
+ end
24
+
14
25
  scenario "gives me the expected results" do
15
26
  visit "/teaspoon/integration"
16
27
 
@@ -7,7 +7,7 @@ feature "Installation", aruba: true do
7
7
  run_simple("bundle exec rails new testapp --skip-bundle")
8
8
  cd("testapp")
9
9
  append_to_file("Gemfile", %{\ngem "teaspoon", path: "#{File.expand_path('../../../', __FILE__)}"\n})
10
- run_simple("bundle install --local")
10
+ run_simple("bundle install")
11
11
  end
12
12
 
13
13
  describe "running the generator" do
@@ -46,8 +46,7 @@ feature "Installation", aruba: true do
46
46
  scenario "installs using the mocha framework" do
47
47
  run_simple("bundle exec rails generate teaspoon:install --trace --framework=mocha")
48
48
 
49
- check_file_content("spec/teaspoon_env.rb", %{ suite.use_framework :mocha}, true)
50
- check_file_content("spec/teaspoon_env.rb", %{ #suite.javascripts = ["mocha/1.17.1", "teaspoon-mocha"]}, true)
49
+ check_file_content("spec/teaspoon_env.rb", %r{suite\.use_framework :mocha}, true)
51
50
  end
52
51
 
53
52
  end
@@ -6,16 +6,16 @@ feature "instrumenting javascript" do
6
6
  pending("needs istanbul to be installed") unless Teaspoon::Instrumentation.executable
7
7
  end
8
8
 
9
- scenario "requesting with instrument=true adds istanbul instrumentation" do
10
- pending("needs to be figured out")
11
- visit "/assets/instrumented1.js?instrument=true"
12
- expect(html).to include("if (typeof __coverage__ === 'undefined') { __coverage__ = {}; }")
13
- end
14
-
15
- scenario "requesting without instrument=true doesn't do anything" do
16
- pending("needs to be figured out")
17
- visit "/assets/instrumented2.js?instrument=false"
18
- expect(html).to_not include("if (typeof __coverage__ === 'undefined') { __coverage__ = {}; }")
19
- end
9
+ #scenario "requesting with instrument=true adds istanbul instrumentation" do
10
+ # pending("needs to be figured out")
11
+ # visit "/assets/instrumented1.js?instrument=true"
12
+ # expect(html).to include("if (typeof __coverage__ === 'undefined') { __coverage__ = {}; }")
13
+ #end
14
+ #
15
+ #scenario "requesting without instrument=true doesn't do anything" do
16
+ # pending("needs to be figured out")
17
+ # visit "/assets/instrumented2.js?instrument=false"
18
+ # expect(html).to_not include("if (typeof __coverage__ === 'undefined') { __coverage__ = {}; }")
19
+ #end
20
20
 
21
21
  end
@@ -24,7 +24,7 @@ describe "Teaspoon", ->
24
24
  spyOn(Teaspoon, 'reload')
25
25
  @spy = spyOn(Teaspoon, "Runner")
26
26
 
27
- it "allows defering (thus not instantiating the runner)", ->
27
+ it "allows deferring (thus not instantiating the runner)", ->
28
28
  Teaspoon.defer = true
29
29
  Teaspoon.execute()
30
30
  expect(@spy).wasNotCalled()
@@ -32,3 +32,16 @@ describe "Teaspoon", ->
32
32
  it "will execute if it should", ->
33
33
  Teaspoon.execute()
34
34
  expect(@spy).toHaveBeenCalled()
35
+
36
+
37
+ describe ".hook", ->
38
+
39
+ beforeEach ->
40
+ @xhr = jasmine.createSpyObj("xhr", ["open", "setRequestHeader", "send"])
41
+ spyOn(window, "XMLHttpRequest").andReturn(@xhr)
42
+
43
+ it "makes the proper ajax request", ->
44
+ Teaspoon.hook("foo", {bar: "baz"})
45
+ expect(@xhr.open).toHaveBeenCalledWith("POST", "/teaspoon/default/foo", false)
46
+ expect(@xhr.setRequestHeader).toHaveBeenCalledWith("Content-Type", "application/json")
47
+ expect(@xhr.send).toHaveBeenCalledWith('{"args":{"bar":"baz"}}')
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,11 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
1
4
  ENV["RAILS_ENV"] ||= "test"
2
5
  ENV["RAILS_ROOT"] = File.expand_path("../dummy", __FILE__)
3
6
  require File.expand_path("../dummy/config/environment", __FILE__)
4
7
 
5
- require "coveralls"
6
- Coveralls.wear!
7
-
8
8
  require "rspec/rails"
9
- require "rspec/autorun"
10
9
  require "capybara/rails"
11
10
  require "aruba/api"
12
11
 
@@ -19,4 +18,8 @@ RSpec.configure do |config|
19
18
  config.order = "random"
20
19
 
21
20
  config.run_all_when_everything_filtered = true
21
+
22
+ config.mock_with :rspec do |c|
23
+ c.syntax = :expect
24
+ end
22
25
  end
@@ -22,9 +22,9 @@ describe Teaspoon::CommandLine do
22
22
  describe "#initialize" do
23
23
 
24
24
  before do
25
- Teaspoon::Console.stub(:new).and_return(console)
26
- subject.any_instance.stub(:abort)
27
- subject.any_instance.stub(:opt_parser).and_return(parser)
25
+ allow(Teaspoon::Console).to receive(:new).and_return(console)
26
+ allow_any_instance_of(subject).to receive(:abort)
27
+ allow_any_instance_of(subject).to receive(:opt_parser).and_return(parser)
28
28
  end
29
29
 
30
30
  it "assigns @options and adds the files that were parsed out" do
@@ -32,28 +32,28 @@ describe Teaspoon::CommandLine do
32
32
  end
33
33
 
34
34
  it "aborts with a message on Teaspoon::EnvironmentNotFound" do
35
- Teaspoon::Console.should_receive(:new).and_raise(Teaspoon::EnvironmentNotFound)
36
- subject.any_instance.should_receive(:abort).with("Teaspoon::EnvironmentNotFound\nConsider using -r path/to/teaspoon_env\n")
35
+ expect(Teaspoon::Console).to receive(:new).and_raise(Teaspoon::EnvironmentNotFound)
36
+ expect_any_instance_of(subject).to receive(:abort).with("Teaspoon::EnvironmentNotFound\nConsider using -r path/to/teaspoon_env\n")
37
37
  subject.new
38
38
  end
39
39
 
40
40
  it "executes using Teaspoon::Console" do
41
- Teaspoon::Console.should_receive(:new).with(files: ["file1", "file2"])
42
- console.should_receive(:failures?)
41
+ expect(Teaspoon::Console).to receive(:new).with(files: ["file1", "file2"])
42
+ expect(console).to receive(:failures?)
43
43
  subject.new
44
44
  end
45
45
 
46
46
  it "aborts if Teaspoon::Console fails" do
47
- subject.any_instance.should_receive(:abort)
48
- console.should_receive(:failures?).and_return(true)
47
+ expect_any_instance_of(subject).to receive(:abort)
48
+ expect(console).to receive(:failures?).and_return(true)
49
49
  subject.new
50
50
  end
51
51
 
52
52
  it "logs a message and exits on abort" do
53
- STDOUT.should_receive(:print).with("Teaspoon::EnvironmentNotFound\nConsider using -r path/to/teaspoon_env\n")
54
- Teaspoon::Console.should_receive(:new).and_raise(Teaspoon::EnvironmentNotFound)
55
- subject.any_instance.should_receive(:abort).and_call_original
56
- expect { subject.new }.to raise_error SystemExit
53
+ expect(STDOUT).to receive(:print).with("Teaspoon::EnvironmentNotFound\nConsider using -r path/to/teaspoon_env\n")
54
+ expect(Teaspoon::Console).to receive(:new).and_raise(Teaspoon::EnvironmentNotFound)
55
+ expect_any_instance_of(subject).to receive(:abort).and_call_original
56
+ expect { subject.new }.to raise_error(SystemExit)
57
57
  end
58
58
 
59
59
  end
@@ -62,13 +62,13 @@ describe Teaspoon::CommandLine do
62
62
 
63
63
  before do
64
64
  @log = ""
65
- STDOUT.stub(:print) { |s| @log << s }
66
- Teaspoon::Console.stub(:new).and_return(console)
65
+ allow(STDOUT).to receive(:print) { |s| @log << s }
66
+ allow(Teaspoon::Console).to receive(:new).and_return(console)
67
67
  end
68
68
 
69
69
  it "has --help" do
70
70
  suppress_warnings { ARGV = ["--help"] }
71
- expect { subject.new.opt_parser }.to raise_error SystemExit
71
+ expect { subject.new.opt_parser }.to raise_error(SystemExit)
72
72
  expect(@log).to include <<-OUTPUT.strip_heredoc
73
73
  Usage: teaspoon [options] [files]
74
74
 
@@ -76,6 +76,7 @@ describe Teaspoon::CommandLine do
76
76
  -d, --driver DRIVER Specify driver:
77
77
  phantomjs (default)
78
78
  selenium
79
+ capybara_webkit
79
80
  --driver-options OPTIONS Specify driver-specific options to pass into the driver.
80
81
  e.g. "--ssl-protocol=any --ssl-certificates-path=/path/to/certs".
81
82
  Driver options are only supported with phantomjs.
@@ -97,17 +98,7 @@ describe Teaspoon::CommandLine do
97
98
  -c, --[no-]color Enable/Disable color output.
98
99
  -e, --export [OUTPUT_PATH] Exports the test suite as the full HTML (requires wget).
99
100
  -f, --format FORMATTERS Specify formatters (comma separated)
100
- dot (default) - dots
101
- documentation - descriptive documentation
102
- clean - like dots but doesn't log re-run commands
103
- json - json formatter (raw teaspoon)
104
- junit - junit compatible formatter
105
- pride - yay rainbows!
106
- snowday - makes you feel warm inside
107
- swayze_or_oprah - quote from either Patrick Swayze or Oprah Winfrey
108
- tap - test anything protocol formatter
109
- tap_y - tap_yaml, format used by tapout
110
- teamcity - teamcity compatible formatter
101
+ #{Teaspoon::Formatters.known_formatters.map(&:cli_help).join("\n" + (" " * 43))}
111
102
 
112
103
  **** Coverage ****
113
104
 
@@ -122,7 +113,7 @@ describe Teaspoon::CommandLine do
122
113
 
123
114
  it "has --version" do
124
115
  suppress_warnings { ARGV = ["--version"] }
125
- expect { subject.new.opt_parser }.to raise_error SystemExit
116
+ expect { subject.new.opt_parser }.to raise_error(SystemExit)
126
117
  expect(@log).to match(/\d+\.\d+\.\d+\n/)
127
118
  end
128
119