Permalink
Browse files

Remove the `interface` configuration option

A future version will support all Mocha configuration options,
but configuration will be done in JS, not Ruby.
  • Loading branch information...
1 parent a0e02ab commit 6ba8f13199dfda3caf5eb5239385cac8ade42f8d @jfirebaugh committed Apr 2, 2012
View
@@ -5,6 +5,8 @@
* Update vendored copies of mocha (1.0.0+) and chai (0.5.2+)
* jQuery is no longer included by default
* Fully remove and replace the #konacha element (#23)
+* Remove the `interface` configuration option. A future version will support
+ all Mocha configuration options, but configuration will be done in JS, not Ruby.
# 0.10.0
View
@@ -96,15 +96,13 @@ Konacha can be configured in an initializer, e.g. `config/initializers/konacha.r
Konacha.configure do |config|
config.spec_dir = "spec/javascripts"
- config.interface = :bdd
config.driver = :selenium
end if defined?(Konacha)
The `defined?` check is necessary to avoid a dependency on Konacha in the production
environment.
-The `spec_dir` option tells Konacha where to find JavaScript specs. The `interface`
-option specifies the test interface used by Mocha (see below). `driver` names a
+The `spec_dir` option tells Konacha where to find JavaScript specs. `driver` names a
Capybara driver used for the `run` task (try `:webkit`, after installing
[capybara-webkit](https://github.com/thoughtbot/capybara-webkit)).
@@ -113,18 +111,8 @@ The values above are the defaults.
## Test Interface and Assertions
Konacha includes a vendored copy of mocha.js and the [chai](http://chaijs.com/)
-assertion libraries.
-
-By default, it will assume that you want to use Mocha's "BDD" test interface, which
+assertion libraries. It configures Mocha to use the "BDD" test interface, which
provides `describe()`, `it()`, `before()`, `after()`, `beforeEach()`, and `afterEach()`.
-If you want to use the TDD or QUnit interfaces instead, set the `interface`
-configuration option in an initializer:
-
- Konacha.configure do |config|
- config.interface = :tdd # Or :qunit
- end if defined?(Konacha)
-
-Mocha's 'exports' interface is not supported.
Konacha will make all three of chai's assertion styles available to you: `expect`,
`should`, and `assert`. See the chai documentation for the details.
@@ -148,9 +136,6 @@ to the page body and instead append it to this test div:
it "... should have been removed before the next starts", ->
$('#test h1#added').length.should.equal(0)
-Note: this functionality is available only for the "BDD" (default) and "TDD" mocha interfaces,
-and not for the "exports" or "QUnit" interfaces.
-
## Templates / Fixtures
Konacha has no template (a.k.a. HTML fixture) support of its own. Instead, we suggest you use
@@ -7,29 +7,19 @@
<%= stylesheet_link_tag "konacha", :debug => false %>
<%= javascript_include_tag "mocha", "chai", "konacha/#{Konacha.mode}", :debug => false %>
<script>
- (function () {
- var ui = <%= raw Konacha.interface.to_json %>;
+ mocha.setup({ui: "bdd", reporter: Konacha.Reporter});
- mocha.setup({ui: ui, reporter: Konacha.Reporter});
+ beforeEach(function () {
+ var e = document.getElementById('konacha'),
+ p = e.parentNode;
- var reset = function () {
- var e = document.getElementById('konacha'),
- p = e.parentNode;
+ p.removeChild(e);
- p.removeChild(e);
+ e = document.createElement("div");
+ e.id = "konacha";
- e = document.createElement("div");
- e.id = "konacha";
-
- p.appendChild(e);
- };
-
- if (ui == "bdd") {
- beforeEach(reset);
- } else if (ui == "tdd") {
- setup(reset);
- }
- })();
+ p.appendChild(e);
+ });
var expect = chai.expect,
should = chai.should(),
View
@@ -26,7 +26,7 @@ def configure
yield config
end
- delegate :port, :spec_dir, :interface, :application, :driver, :to => :config
+ delegate :port, :spec_dir, :application, :driver, :to => :config
def spec_root
File.join(Rails.root, config.spec_dir)
View
@@ -23,7 +23,6 @@ def self.application(app)
options.spec_dir ||= "spec/javascripts"
options.port ||= 3500
- options.interface ||= :bdd
options.application ||= self.class.application(app)
options.driver ||= :selenium
@@ -24,7 +24,4 @@
# Expands the lines which load the assets
config.assets.debug = true
-
- config.assets.paths.concat([Rails.root.join("spec/tdd"),
- Rails.root.join("spec/qunit")])
end
@@ -1,10 +0,0 @@
-function ok(expr, msg) {
- if (!expr) throw new Error(msg);
-}
-
-suite('QUnit');
-
-test('qunit test', function(){
- var arr = [1,2,3];
- ok(arr.length == 3);
-});
@@ -1,5 +0,0 @@
-suite('TDD', function(){
- test('tdd test', function () {
- assert.equal(-1, [1, 2, 3].indexOf(4));
- });
-});
View
@@ -1,36 +0,0 @@
-require 'spec_helper'
-
-describe Konacha, :type => :request do
- before do
- Konacha.mode = :server
- end
-
- after do
- Konacha.configure do |config|
- config.interface = :bdd
- config.spec_dir = "spec/javascripts"
- end
- end
-
- it "supports Mocha's TDD interface" do
- Konacha.configure do |config|
- config.interface = :tdd
- config.spec_dir = "spec/tdd"
- end
-
- visit "/tdd_spec"
- page.should have_content("tdd test")
- page.should have_css(".test.pass")
- end
-
- it "supports Mocha's QUnit interface" do
- Konacha.configure do |config|
- config.interface = :qunit
- config.spec_dir = "spec/qunit"
- end
-
- visit "/qunit_spec"
- page.should have_content("qunit test")
- page.should have_css(".test.pass")
- end
-end
View
@@ -4,12 +4,6 @@
describe ".config" do
subject { Konacha.config }
- describe ".interface" do
- it "defaults to :bdd interface" do
- subject.interface.should == :bdd
- end
- end
-
describe ".spec_dir" do
it "defaults to 'spec/javascripts'" do
subject.spec_dir.should == "spec/javascripts"

0 comments on commit 6ba8f13

Please sign in to comment.