Coder Social home page Coder Social logo

jfirebaugh / konacha Goto Github PK

View Code? Open in Web Editor NEW
1.1K 27.0 117.0 1018 KB

Test your Rails application's JavaScript with the mocha test framework and chai assertion library

License: Other

Ruby 82.33% JavaScript 11.22% CSS 2.64% HTML 1.72% CoffeeScript 2.10%

konacha's Introduction

Konacha

Build Status Dependency Status

Konacha ([koh-NAH-cha], a type of green tea) is a Rails engine that allows you to test your JavaScript with the Mocha test framework and chai assertion library.

Konacha in action

It is similar to Jasmine and Evergreen, but does not attempt to be framework agnostic. By sticking with Rails, Konacha can take full advantage of features such as the asset pipeline and engines.

Installation

Add konacha to the :test and :development groups in the Gemfile and bundle install:

group :test, :development do
  gem 'konacha'
end

Usage

Create a spec/javascripts directory and name the files in it with a _spec (or _test) suffix. You can write the specs in either JavaScript or CoffeeScript, using a .js or .js.coffee extension respectively, like you would any other script asset.

Require the assets under test and any other dependencies using Sprockets directives. For example, suppose you wanted to test your cool JavaScript Array#sum method, which you placed in app/assets/javascripts/array_sum.js. Write the specs in JavaScript in the file spec/javascripts/array_sum_spec.js:

//= require array_sum

describe("Array#sum", function() {
  it("returns 0 when the Array is empty", function() {
    [].sum().should.equal(0);
  });

  it("returns the sum of numeric elements", function() {
    [1,2,3].sum().should.equal(6);
  });
});

Or, if you prefer CoffeeScript, in spec/javascripts/array_sum_spec.js.coffee:

#= require array_sum

describe "Array#sum", ->
  it "returns 0 when the Array is empty", ->
    [].sum().should.equal(0)

  it "returns the sum of numeric elements", ->
    [1,2,3].sum().should.equal(6)

Your tests are run inside an iframe. You have the entire <body> element to yourself, and it is automatically reset between tests.

Running (Rake Tasks)

In the Browser

To start a server for your tests, type:

$ bundle exec rake konacha:serve

Then open http://localhost:3500 in your browser, and you will see all your tests running. You can also go to a sub-page to run an individual spec file (e.g. http://localhost:3500/array_sum_spec), or a path to a subdirectory to run a subset of specs (e.g. http://localhost:3500/models).

This is the recommended mode for development, since you can simply hit refresh to reload all your test and asset files. To debug tests, use the debugger statement anywhere in a test to halt execution.

To run code in the JavaScript console, be sure to select the desired iframe first, so your code runs in the correct context.

Selecting the test-context frame in Chrome

You can also add the following to your config/routes.rb to see the specs run at /konacha:

Rails.application.routes.draw do
  mount Konacha::Engine, at: "/konacha" if defined?(Konacha)
end

Command-Line Runner

To run your tests from the command line, type:

$ bundle exec rake konacha:run

To run individual specs, pass a comma separated list of spec file names via the SPEC environment variable.

$ bundle exec rake konacha:run SPEC=foo_spec
$ bundle exec rake konacha:run SPEC=foo_spec,bar_spec,etc_spec

Konacha includes a default formatter modeled upon RSpec's ProgressFormatter. Additionally, Konacha's runner implements the same protocol as RSpec, so many RSpec formatters also work with Konacha.

To specify one or more formatters, provide a comma separated list of class names in the FORMAT environment variable. For example, you can run both Ruby and JavaScript specs with CI integration using ci_reporter:

$ bundle exec rake ci:setup:rspec spec konacha:run FORMAT=CI::Reporter::RSpec

You will need to require any formatters you use. It's a good idea to do this within a defined? check in your Konacha initializer.

To automatically trigger reruns when files change, try guard-konacha.

Spec Helper

Since Konacha integrates with the asset pipeline, using setup helpers in your specs is easy. Just create a spec_helper.js or spec_helper.js.coffee file in spec/javascripts and require it in your tests:

//= require spec_helper
//= require array_sum

describe("Array#sum", function() {
  ...
});

The spec_helper is a good place to set Mocha and Chai options as well, for instance:

// set the Mocha test interface
// see http://mochajs.org/#interfaces
mocha.ui('bdd');

// ignore the following globals during leak detection
mocha.globals(['YUI']);

// or, ignore all leaks
mocha.ignoreLeaks();

// set slow test timeout in ms
mocha.timeout(5);

// Show stack trace on failing assertion.
chai.config.includeStack = true;

Directives and Asset Bundling

We suggest that you explicitly require just the assets necessary for each spec. Konacha runs each spec file in isolation, and requiring things explicitly will help ensure your scripts don't accumulate hidden dependencies and tight coupling.

However, you are free to ignore this advice and require the entire application.js asset bundle in your specs or spec helper, or a bundled subset of assets. Requiring bundled assets works like it does in Rails development mode -- Konacha will detect the complete set of dependencies and generate a separate script tag for each one. You won't have to search through a many thousand line application.js bundle to debug a spec failure.

Configuration

Konacha can be configured in an initializer, e.g. config/initializers/konacha.rb:

Konacha.configure do |config|
  config.spec_dir     = "spec/javascripts"
  config.spec_matcher = /_spec\.|_test\./
  config.stylesheets  = %w(application)
  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. spec_matcher is an object responding to === (most likely a Regexp); it receives a filename and should return true if the file is a spec. The stylesheets option sets the stylesheets to be linked from the <head> of the test runner iframe. driver names a Capybara driver used for the run task. The values above are the defaults.

For PhantomJS support you can use the poltergeist driver. Require capybara/poltergeist in the configure block:

Konacha.configure do |config|
  require 'capybara/poltergeist'
  config.driver = :poltergeist
end if defined?(Konacha)

Test Interface and Assertions

Konacha includes a vendored copy of mocha.js and the chai assertion libraries. By default, it configures Mocha to use the "BDD" test interface, which provides describe(), it(), before(), after(), beforeEach(), and afterEach().

Konacha will make all three of chai's assertion styles available to you: expect, should, and assert. See the chai documentation for the details.

If you use jQuery, you may want to check out chai-jquery for some jQuery-specific assertions. There are a lot of interesting chai matchers out there, see the chai plugins page

To make all these available for your konacha environment, see the Konacha-chai-matchers gem

Templates / Fixtures

Konacha has no template (a.k.a. HTML fixture) support of its own. Instead, we suggest you use Sprocket's built in support for JavaScript template (.jst) files. Add a spec/javascripts/templates directory, place template files there (using any JS template language supported by Sprockets), require them in your spec or spec_helper, and render them into the <body>.

The following example uses EJS. You can use an alternative templating language, like ECO, but you need to add something to your Gemfile in order for Sprokets to define the JST function and make your templates available.

group :development, :test do
  gem "ejs"
end

For example, in spec/javascripts/templates/hello.jst.ejs:

<h1>Hello Konacha!</h1>

In spec_helper.js:

//= require_tree ./templates

And your spec:

//= require spec_helper

describe("templating", function() {
  it("is built in to Sprockets", function() {
    $('body').html(JST['templates/hello']());
    $('body h1').text().should.equal('Hello Konacha!');
  });
});

Upgrading from Konacha 3.x

The only backward-incompatible change in Konacha 4.0 is that Rails versions less than 4.1 are longer supported. Please upgrade to 4.1 or later.

Contributing

git clone git://github.com/jfirebaugh/konacha.git

Run bundle exec rake to run the test suite.

Contributing to Mocha and Chai

The Konacha repository includes the Mocha and Chai repositories as submodules, so you can hack on them directly:

cd mocha # or: cd chai
git checkout master
... hack-hack-hack ...
bundle exec rake assets # make and cp assets based on your changes

Assuming your app's Gemfile points at your Konacha checkout (gem 'konacha', :path => '~/path/to/konacha'), your changes to Mocha and Chai are live in localhost:3500 when you refresh your browser.

You can send pull requests to Mocha and Chai straight out of your submodules.

See Also

Prior art:

Similar projects:

konacha's People

Contributors

alex88 avatar alexkravets avatar aron avatar bmaland avatar burgestrand avatar davidjbeveridge avatar dreamfall avatar florish avatar foxyblocks avatar gsbucks avatar henrik avatar jfirebaugh avatar jnbt avatar johanneswuerbach avatar joliss avatar jonhyman avatar josepjaume avatar kaukas avatar mange avatar markbates avatar matthijsgroen avatar mr0grog avatar oesmith avatar outdooricon avatar rspeicher avatar ryanlower avatar spicycode avatar stevenchanin avatar thejonanshow avatar wifilinker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

konacha's Issues

Konacha with Sinatra/Rack Apps

I've gone and done a prototype of how this would work, and honestly it was fairly simple.

https://github.com/markbates/konacha-sinatra

The prototype has to hack around the Rails Engine stuff, to be "stand alone", but this could more easily be done in Konacha with just a few lines of code to make it happen.

I did the prototype as a stand alone gem because I know there has been discussion of this sort of thing in the past, and it has always ended up with a "not going to happen".

I would like to re-open the discussion here. I'm happy to upgrade Konacha to be Rails and Rack friendly, it wouldn't take long. However, I'll only do it if there's agreement that we should.

Thoughts?

Errors using the :webkit driver

We're trying to use the :webkit driver and so far it's not working. We get parse errors from chai.js, and a few other messages (included below). If you change the driver to the :webkit_debug driver you can see the following output:

$ rake konacha:run                                  
 >> Visit
 >> 1
 >> 31
 >> http://127.0.0.1:49909/log_spec
http://127.0.0.1:49909/assets/chai.js|643|SyntaxError: Parse error
http://127.0.0.1:49909/log_spec|26|ReferenceError: Can't find variable: chai
 << ok
 << 0
 << 
 >> Evaluate
 >> 1
 >> 28
 >> [Konacha.done, Konacha.dots]
 << ok
 << 4
 << null
rake aborted!
undefined method `[]' for nil:NilClass

Tasks: TOP => konacha:run
(See full trace by running task with --trace)

Error communicating with browser process

Hey there. When I run rake konacha:run I get a Selenium error:

rake aborted!
Error communicating with browser process: #<Selenium::WebDriver::Error::JavascriptError: unknown error>

I see Firefox start to launch and quit. I'm running Konacha 1.2.3.

To become framework agnostic

Konacha idea is really great! And so are Chai and Mocha.

But if you want to have your specs running against IE < 9, Chai.js is not an option :(

I took a glance at Konacha source and realized that supporting Jasmine in Konacha would be straightforward with so little effort.

I mean, you don't even need to add support for Jasmine. Actually you don't even have to change your code at all.

Thanks to how engines work already in Rails, all one has to do is create a custom app/views/konacha/specs.html.erb.

So, giving an example on how to use Jasmine in Konacha instead of Chai for IE < 9 support in your documentation would suffice. The only line that should be really mentioned is to point out the usage of spec_include_tag(*@specs):

https://github.com/jfirebaugh/konacha/blob/master/app/views/konacha/specs/specs.html.erb#L33

Another approach would be to show an example adding a filter to SpecsController#specs that would render a different template given a certain param, like in

http://localhost:3500/?type=jasmine

I guess many more aren't using Konacha yet because they didn't realize that using another javascript test framework in Konacha is trivial. Maybe such documentation could help on getting the community to jump into Konacha.

Does it sound crazy?

.coffee extension (without .js) breaks script inclusion

Not an important issue, but here we go anyway:

Adding a foo_spec.coffee (as opposed to foo_spec.js.coffee) puts <script src="/assets/.js" type="text/javascript"></script> into the localhost:8888/ page. According to the README only .js.cofffee should work, right? I'm thinking it should just ignore .coffee files rather than attempting to include it.

really slow response times with konacha:serve

Hi, I'm rails 3.2.6 and I'm I've got about 400 tests. Whenever I hit the konacha server, its taking about 40 seconds before the tests start running, if not longer.

Does anyone have any ideas or suggestions on how to speed this up? Hitting my local development server isn't nearly that slow.

Everything is written in coffeescript, if that makes a difference

Thanks!

guard extension

I went to go write a guard extension, and from the looks of it's slightly more complicated than the 1/2 hour's worth I wanted to spend right now.

Posting this here in case somebody is already working on it or has one done before I get to it. Will open a pull req to add a link to the readme once it's up.

Weird SpecException

Hey John, hey all,

Really quickly, has anybody ever seen a SpecException without backtrace?

I'm getting one on our build server, like so:

  Failed: helpers pluralize
    Konacha::Reporter::SpecException

And I can't reproduce it locally. Any ideas?

Mocha Error detection doesn't work properly with iframe setup

In async tests, mocha has the following code for handling calls to done(err):

// async
if (this.async) {
  try {
    this.fn.call(ctx, function(err){
      if (err instanceof Error) return done(err);
      if (null != err) return done(new Error('done() invoked with non-Error: ' + err));
      done();
    });
  } catch (err) {
    done(err);
  }
  return;
}

The issue I'm currently seeing is that when calling something like done(new Error); from inside the iframe that the instanceof Error check fails because the Error being tested in mocha is different from the one used to create the new object within the iframe. Generally, instanceof doesn't work across contexts/windows like that.

Konacha.run fails when Konacha is mounted as an engine

Issue #85 fixed an issue with Konacha being mountable, but not really working when mounted.

Unfortunately, Konacha.run fails after this patch, but only if the Konacha::Engine has been mounted. When the Capybara-window is launched during Konacha.run, it still uses the mounted path (in my case, /konacha/iframe/…) for specs, but since it’s not running the mounted engine (and actually the runner) that path is wrong.

Just to be clear, patch #85 didn’t break anything that wasn’t already broken, it’s just another issue that has been surfaced in relation to mounting konacha as an engine on a subdirectory.

Reproduce by mounting Konacha as an engine (as seen in #85), and then running rake konacha:run. You can see the invalid paths by starting a rails console, doing Konacha.run, and opening the web inspector.

Disable leak detection

Mocha's leak detection is giving a slew of problems. It happened in issue #19, and it also happened in this test in Konacha's test suite (after I tried removing the jQuery include tag):

screenshot

The top-most line referred to by the stack trace is

this.fail(test, new Error('global leaks detected: ' + leaks.join(', ') + ''));

Note that the second Array#sum test passes fine. I have no idea what's going on, I just know that the leak detection is being really unhelpful.

I say we should set ignoreLeaks = true. I just haven't figured out yet how to set it on the runner object.

Strange behavior when before() is used inside the iframe

I might be misunderstanding something, but it appears that using before() in a test suite overrides the beforeAll in iframe.js.

The first time I define my own 'before', I can still access the one in iframe.js at runtime by executing mocha.suite._beforeAll[0].fn(), but subsequent tests don't run or behave erratically due to the iframe.js beforeAll not executing.

I'd expect before( to act like jQuery event handlers and just add additional functions in the order that they're defined, but it appears that my calls to before are overriding the one in iframe.js, which is needed for proper operation.

hooks, leaks and spec references: a beginner's issues

Hello,

I'm kinda new to konacha, and this doesn't make sense to me at all:

....................FF............

  Failed: undefined "before all" hook
    Error: global leak detected: top

  Failed: undefined "before each" hook
    Error: global leak detected: navigator

where are the FILE:LINE spec references?
what hooks? where should they be defined?
what leaks? (top? navigator? I don't have any of those)

Errors in test code (outside of "it"/"test") are uncaught

throw 'ouch'

describe 'suite', ->
  it 'is never executed', ->

Running this in the browser or with konacha:run reports no failures. It just silently drops the tests after the exception.

I currently always run Konacha tests in the browser, with a JavaScript console open, so I'll see errors like this, but I wonder if there's a way Konacha can catch errors like this and report them.

Just wanted to open an issue to brainstorm.

Runner: Specs should run on single page

As it is, the runner visits the individual spec URL for each spec file.

This eats up a lot of time, and it's not really necessary when we are running all specs anyway. We should use the '/' page instead. Proof of concept:

diff --git a/lib/konacha/runner.rb b/lib/konacha/runner.rb
index 8e5ef28..7a130b6 100644
--- a/lib/konacha/runner.rb
+++ b/lib/konacha/runner.rb
@@ -47,16 +47,17 @@ module Konacha
     end

     def spec_runners
-      @spec_runners ||= Konacha::Spec.all.map { |spec| SpecRunner.new(self, spec) }
+      #@spec_runners ||= Konacha::Spec.all.map { |spec| SpecRunner.new(self, spec.url) }
+      @spec_runners ||= [SpecRunner.new(self, '/')]
     end
   end

   class SpecRunner
-    attr_reader :runner, :spec, :examples
+    attr_reader :runner, :url, :examples

-    def initialize(runner, spec)
+    def initialize(runner, url)
       @runner = runner
-      @spec = spec
+      @url = url
     end

     def session
@@ -68,7 +69,7 @@ module Konacha
     end

     def run
-      session.visit(spec.url)
+      session.visit(url)

       dots_printed = 0
       begin

#test ID might collide with app

I wonder if we should rename #test to something more specific to avoid collisions. I'm thinking #konacha-test or so.

What do you think?

uninitialized constant when running Rake tasks

When running Konacha via the Rake tasks (konacha:serve and konacha:run), I get uninitialized constant errors. However, when running the equivalent code through rails runner (rails runner Koncha.serve and rails runner Konacha.run), it works fine. My best guess is that this is caused by some conflict between Rake and Rails handling missing constants, because the missing constants are controller and model names from Konacha's Rails engine. These should be autoloaded by Rails, but the stack trace includes const_missing from Rake:

/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/ext/module.rb:36:in `const_missing'

Workaround

For those arriving from a search engine, the work-around is to launch Konacha with rails runner:

rails runner Konacha.serve
rails runner Konacha.run

Environment

Ruby is 1.9.3-p194.

$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Most of my dependencies are updated to the latest versions. Specifically, Rails and Konacha are on the latest version.

$ bundle show
Gems included by the bundle:
  * actionmailer (3.2.7)
  * actionpack (3.2.7)
  * activemodel (3.2.7)
  * activerecord (3.2.7)
  * activeresource (3.2.7)
  * activesupport (3.2.7)
  * addressable (2.3.2)
  * arel (3.0.2)
  * builder (3.0.0)
  * bundler (1.2.0.rc)
  * capistrano (2.12.0)
  * capybara (1.1.2)
  * childprocess (0.3.4)
  * coffee-rails (3.2.2)
  * coffee-script (2.2.0)
  * coffee-script-source (1.3.3)
  * commonjs (0.2.6)
  * cookiejar (0.3.0)
  * diff-lcs (1.1.3)
  * eco (1.0.0)
  * eco-source (1.1.0.rc.1)
  * em-http-request (1.0.2)
  * em-socksify (0.2.0)
  * erubis (2.7.0)
  * eventmachine (1.0.0.rc.4)
  * execjs (1.4.0)
  * factory_girl (4.0.0)
  * factory_girl_rails (4.0.0)
  * faraday (0.8.1)
  * ffi (1.0.11)
  * guard (1.3.0)
  * guard-rspec (1.2.1)
  * guard-spork (1.1.0)
  * haml (3.1.6)
  * haml_coffee_assets (1.3.0)
  * highline (1.6.13)
  * hike (1.2.1)
  * http_parser.rb (0.5.3)
  * i18n (0.6.0)
  * journey (1.0.4)
  * jquery-rails (2.0.2)
  * json (1.7.4)
  * kgio (2.7.4)
  * koala (1.5.0)
  * konacha (1.4.1)
  * less (2.2.1)
  * less-rails (2.2.3)
  * less-rails-bootstrap (2.0.12 c4bf5a5)
  * libnotify (0.7.4)
  * libv8 (3.3.10.4)
  * libwebsocket (0.1.5)
  * listen (0.4.7)
  * mail (2.4.4)
  * mime-types (1.19)
  * multi_json (1.3.6)
  * multipart-post (1.1.5)
  * net-scp (1.0.4)
  * net-sftp (2.0.5)
  * net-ssh (2.5.2)
  * net-ssh-gateway (1.1.0)
  * nokogiri (1.5.5)
  * pg (0.14.0)
  * polyglot (0.3.3)
  * rack (1.4.1)
  * rack-cache (1.2)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.2.7)
  * rails_config (0.3.1)
  * railties (3.2.7)
  * rainbows (4.3.1)
  * raindrops (0.10.0)
  * rake (0.9.2.2)
  * rb-fchange (0.0.5)
  * rb-fsevent (0.9.1)
  * rb-inotify (0.8.8)
  * rdoc (3.12)
  * rspec (2.11.0)
  * rspec-core (2.11.1)
  * rspec-expectations (2.11.2)
  * rspec-mocks (2.11.1)
  * rspec-rails (2.11.0)
  * rubyzip (0.9.9)
  * selenium-webdriver (2.25.0)
  * spork (0.9.2)
  * sprockets (2.1.3)
  * therubyracer (0.10.1)
  * thor (0.15.4)
  * tilt (1.3.3)
  * treetop (1.4.10)
  * tzinfo (0.3.33)
  * uglifier (1.2.7)
  * unicorn (4.3.1)
  * xpath (0.1.4)

Stack Traces

Here are the complete stack traces when running Konacha with Rake.

rake konacha:run

$ rake konacha:run
** Invoke konacha:run (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute konacha:run
rake aborted!
uninitialized constant Konacha::Spec
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/ext/module.rb:36:in `const_missing'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/konacha-1.4.1/lib/konacha/runner.rb:50:in `spec_runners'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/konacha-1.4.1/lib/konacha/runner.rb:18:in `run'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/konacha-1.4.1/lib/konacha/runner.rb:6:in `start'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/konacha-1.4.1/lib/konacha.rb:19:in `run'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/konacha-1.4.1/lib/tasks/konacha.rake:9:in `block (2 levels) in <top (required)>'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:205:in `call'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:200:in `each'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_level'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:94:in `each'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/application.rb:63:in `run'
/home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:32:in `<top (required)>'
./bin/rake:16:in `load'
./bin/rake:16:in `<main>'
Tasks: TOP => konacha:run

rake konacha:serve

You have to make a request to http://localhost:3500/ for the error to show up.

$ rake konacha:serve
[2012-08-03 15:31:32] INFO  WEBrick 1.3.1
[2012-08-03 15:31:32] INFO  ruby 1.9.3 (2012-04-20) [x86_64-linux]
[2012-08-03 15:31:32] WARN  TCPServer Error: Address already in use - bind(2)
[2012-08-03 15:31:32] INFO  WEBrick::HTTPServer#start: pid=15708 port=3500
ActionController::RoutingError: uninitialized constant Konacha::SpecsController
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/ext/module.rb:36:in `const_missing'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:230:in `block in constantize'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:229:in `each'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:229:in `constantize'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:554:in `get'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:69:in `controller_reference'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:54:in `controller'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:32:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:600:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:479:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/railtie/configurable.rb:30:in `method_missing'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/urlmap.rb:64:in `block in call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `each'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/showexceptions.rb:24:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
ActionController::RoutingError: uninitialized constant Konacha::SpecsController
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rake/ext/module.rb:36:in `const_missing'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:230:in `block in constantize'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:229:in `each'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:229:in `constantize'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:554:in `get'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:69:in `controller_reference'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:54:in `controller'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:32:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_dispatch/routing/route_set.rb:600:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:479:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/railtie/configurable.rb:30:in `method_missing'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/urlmap.rb:64:in `block in call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `each'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/showexceptions.rb:24:in `call'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
    /home/david/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
[2012-08-03 15:31:59] INFO  going to shutdown ...
[2012-08-03 15:31:59] INFO  WEBrick::HTTPServer#start done.
Your tests are here:
  http://localhost:3500/

Path to konacha iframe is wrong when mounted as an engine

I have Konacha mounted as an engine:

if Rails.env.development?
  mount Konacha::Engine => "/konacha"
end

Visiting /konacha fails because of a loading error, as Konacha is trying to load http://localhost:5000/iframe/path/to/specs, because the path to the iframe in app/views/konacha/specs/parent.html.erb is hard-coded to /iframe/#{spec.asset_name}.

I forked konacha and commited a fix of my own (to use until this issue has been resolved): https://github.com/Burgestrand/konacha/commit/be91083b236451a8d8dd8e015128691d9c7b6064 — however, I’m not comfortable sending a pull request without testing it.

In addition, the konacha specs from a fresh checkout on master (a2166e1) fails for me: https://gist.github.com/4202079. Can not dig further on this at the moment, but the gist is there in case you are curious.

Show app in iframe

This issue just FYI:

I'm trying to help my team mates get started on Ember and Konacha, and one thing that makes the learning curve a lot steeper is not being able to see the app as it's being tested.

I'm thinking I'll try to make Konacha use an iframe instead of the #konacha div, so you can easily drop into the debugger during a test and see what's going on, click into the app and inspect DOM elements, etc.

Here is a mockup of what I'm imagining: http://i.imgur.com/qD8em.png

This is sort of possible with the #konacha div we have at the moment, but the lack of visual feedback and having to click through the DOM hierarchy makes it a lot harder IMO.

My approach would be to have the entire test suite basically running inside the iframe, and have a custom mocha reporter add the reports into the (dumb) top-level frame as it runs. We'll load application.css (by default; configurable) to make the styling come out OK.

Any insights, objections, concerns, let me know. Else you'll hopefully see a pull request in a few days. :)

Using konacha to test another engine

I'm trying to use konacha to test another engine. Konacha is included as a development_dependency in the engine's gemspec and in the best case that would be enough to make everything work. Unfortunately, things are more complicated.

I have gotten part of the way to a working setup by doing some duck punching in the engine's Rakefile. Here are the relevant parts

begin
  require 'bundler/setup'
rescue LoadError
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

task 'load_app' do
  # load_app is defined and invoked in engine.rake, below
  # we have to sneak in our additions so konacha is loaded.

  require 'action_controller/railtie'
  require 'konacha'
  load 'tasks/konacha.rake'

  module Konacha
    def self.spec_root
      MyEngine::Engine.config.root + config.spec_dir
    end
  end

  class Konacha::Engine
    initializer "konacha.engine.environment", after: "konacha.environment" do
      # Rails.application is the dummy app in test/dummy
      Rails.application.config.assets.paths << MyEngine::Engine.config.root + Konacha.config.spec_dir
    end
  end
end

APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'

Still, I'm not there yet. My tests depend on jQuery and jquery_ujs, both of which are provided by the jquery-rails engine. That engine, too, is listed as a dependency in the gemspec, but as all the other dependencies, it it not loaded automatically at the appropriate time.

It would be nice if konacha would in some way support an environment where it is used to test an engine, not an app.

Runner: Async timeout gets reported twice

I'm thinking this might be a bug in the Mocha upstream, but I'm not sure how to create a minimal test case for them, off the top of my head. Have you done this before, John? Else I'll dig into it in two days or so.

describe('async', function() {
  it('fails', function (done) {
    // do not call done()
  });
});

The failure output is

FF

  Failed: fails
    timeout of 2000ms exceeded
    in :

  Failed: fails
    global leak detected: getInterface
    in :

Finished in 6.60 seconds
2 examples, 2 failures

There are three issues:

  1. the bogus leak
  2. the mis-counting (there is only one example)
  3. the empty "in :" line (I think this one is not specific to async tests)

For some funny reason, this doesn't happen in the Konacha dummy app:

diff --git a/spec/dummy/spec/javascripts/failing_spec.js b/spec/dummy/spec/javascripts/failing_spec.js
index feb28d3..8da5b57 100644
--- a/spec/dummy/spec/javascripts/failing_spec.js
+++ b/spec/dummy/spec/javascripts/failing_spec.js
@@ -1,5 +1,11 @@
-describe("failure", function(){
-  it("fails", function(){
+describe("failure", function() {
+  it("fails instantly", function() {
     (2 + 2).should.equal(5);
   });
 });
+
+describe("asynchronous failure", function(done) {
+  it("fails asynchronously", function(done) {
+    // do not call done()
+  });
+});

konacha:run tries to parse over-escaped JSON

the code:

@examples = JSON.parse(session.evaluate_script('Konacha.getResults()')).map do |row|

the stack trace:

756: unexpected token at '"[{"name": "includesDate", "passed": true},...
/Users/ted/.rvm/gems/ruby-1.9.2-p0/gems/json-1.6.5/lib/json/common.rb:148:in parse' /Users/ted/.rvm/gems/ruby-1.9.2-p0/gems/json-1.6.5/lib/json/common.rb:148:inparse'
/Users/ted/.rvm/gems/ruby-1.9.2-p0/gems/konacha-1.1.0/lib/konacha/runner.rb:82:in `run'

Specs fail if a spec removes the #konacha element

If the #konacha element is removed from the document, any following specs fail. Here's code that causes failure:

#= require jquery

describe "Test", ->
  it "removes the konacha element", ->
    $("#konacha").remove()

  it "fails on the next test", ->
    "".should.be.a.instanceOf(String)

This appears to be caused because getElementById returns null, which causes problems when Konacha looks for the parentNode. See:

beforeEach(function () {
  var e = document.getElementById('konacha'),
      p = e.parentNode;

  p.removeChild(e);

  e = document.createElement("div");
  e.id = "konacha";

  p.appendChild(e);
});

Running non-DOM specs outside the browser (headless/ExecJS/Node.js)

Abusing the issue tracker for brainstorming again ...

I'm bothered that we are running specs for plain JS through Selenium. That doesn't seem like the "proper" way to do JS development. I'm wondering whether it would make sense to be able to run such specs outside of the browser (perhaps through ExecJS).

Pro:

  • Headless (without requiring Webkit)
  • Faster (no need to start up Firefox)
  • No brittle Selenium layer in between

Cons:

  • Would need to be able to separate DOM specs from non-DOM specs
  • Still need to start up the Rails stack, so it's not instantaneous, unlike hitting "refresh" on localhost:3500

I'm not saying that we should implemented this -- the pros don't seem to warrant the added complexity. Perhaps it's even out of scope for Konacha. I just wanted to get my vague feeling out in the open that we're "doing it wrong" for plain-JS specs.

Hard to use latest gem via bundler

Hi John,

Tried to use the latest gem in my gemfile with the :git option and it fails because the vendor files are not included directly in the repository. I'm guessing this was a conscious decision that came with including mocha/chai as submodules.

What would you recommend for those of us who would like to use the latest Konacha?

Thanks,
Tanzeeb

uninitialized constant Konacha::Runner::Capybara

Running bundle exec rake konacha:ci on https://github.com/joliss/solitr HEAD raises an error.

** Invoke konacha:ci (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute konacha:ci

rake aborted!
uninitialized constant Konacha::Runner::Capybara
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha/runner.rb:142:in `session'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha/runner.rb:36:in `session'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha/runner.rb:52:in `examples'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha/runner.rb:82:in `dots'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha/runner.rb:132:in `block in dots'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha/runner.rb:132:in `map'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha/runner.rb:132:in `dots'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha/runner.rb:106:in `run'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha/runner.rb:4:in `start'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/konacha.rb:18:in `run'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/konacha-0.9.1/lib/tasks/konacha.rake:9:in `block (2 levels) in <top (required)>'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/task.rb:205:in `call'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/task.rb:200:in `each'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_level'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/application.rb:94:in `each'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/ubuntu/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/rake/application.rb:63:in `run'
/home/ubuntu/.rbenv/versions/1.9.3-p125/bin/rake:32:in `<main>'
Tasks: TOP => konacha:ci

Probably some missing require. I just want to have this filed for now -- I'll try to look into it later.

Clear attributes on #konacha

Presumably events need to be unbound as well.

I'm thinking we should just throw away the old node and create a fresh one (instead of clearing the div).

(Just to get this off my to-do list.)

#test ID might collide with app

I wonder if we should rename #test to something more specific to avoid collisions. I'm thinking #konacha-test or so.

What do you think?

JST cannot be found when running rake konacha:run

Hello!

JST templates work, when I run tests in browser using rake konacha:serve.

But rake konacha:run gives me

..........................Frake aborted!
Error communicating with browser process: #<JSON::ParserError: 399: 
unexpected token at 'before each\\" 
hook\",\"passed\":false,\"message\":\"Can't find variable: JST\"}]"]'>

Tasks: TOP => konacha:run
(See full trace by running task with --trace)

konacha.rb has following lines:

# config/initializers/konacha.rb
require 'capybara/webkit'

Konacha.configure do |config|
  config.spec_dir  = 'spec/javascripts'
  config.driver    = :webkit
end if defined?(Konacha)

Could you, please, give me a hint, if I missed something?

Thanks.

Using Ruby helpers

Hey all,

I'd like to add some JSON fixtures generated by ActiveRecord/active_model_serializers. Basically a sophisticated version of this:

def user_fixture_json
  UserSerializer.new(FactoryGirl.create :user).to_json
end

to be used like this (roughly):

fixtureData = {users: <%= raw user_fixture_json %>}

Any ideas where to put code like this?

You can declare it inside an initializer, but that seems like a really odd place, and it doesn't get automatically reloaded.

Specs run twice when using runner

I currently have 5 spec (1 failing for display). When run with rake konacha:serve and open the browser, all is good.

Moonclerk.Models.Checkout
  has a proper url
  doesn't require duration by default

  #total_amount
    handles null attributes
      expected 0 to equal 2
    computes a total with numbers
    computes a total with strings

When I run with the rake konacha:run I get everything run twice:

∴ rake konacha:run
..F....F..

  Failed: handles null attributes
    expected 0 to equal 2

  Failed: handles null attributes
    expected 0 to equal 2

Finished in 5.56 seconds
10 examples, 2 failures

Ideas?

Chai 1.0.3 is out!

A few bugfixes for deep equality testing and IE compatibility.

Cheers!

New release?

Hey John, time for a new release? Perhaps 1.4.2?

Chai 1.4.0 release

Chai has released version 1.4.0

Relevant Changelog

  • Add most() (alias: lte) and least() (alias: gte) to the API with new chainers "at" and "of".
  • Added support for circular references when checking deep (in)equality.

Timeout Errors with PhantomJS 1.7 and Poltergeist 1.0.2 and Konacha 2.1.0

The title pretty much says it all. Using Konacha 2.1.0, PhantomJS 1.7, and Poltergeist 1.0.2, rake konacha:run task times out.

[markbates@markmini vogon (master)]$ time rake
rake aborted!
Timed out waiting for response to {"name":"visit","args":["http://127.0.0.1:52149/"]}
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/poltergeist-1.0.2/lib/capybara/poltergeist/web_socket_server.rb:147:in `rescue in send'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/poltergeist-1.0.2/lib/capybara/poltergeist/web_socket_server.rb:143:in `send'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/poltergeist-1.0.2/lib/capybara/poltergeist/server.rb:29:in `send'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/poltergeist-1.0.2/lib/capybara/poltergeist/browser.rb:168:in `command'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/poltergeist-1.0.2/lib/capybara/poltergeist/browser.rb:21:in `visit'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/poltergeist-1.0.2/lib/capybara/poltergeist/driver.rb:81:in `visit'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/capybara-1.1.4/lib/capybara/session.rb:157:in `visit'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/konacha-2.1.0/lib/konacha/runner.rb:16:in `run'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/konacha-2.1.0/lib/konacha/runner.rb:6:in `start'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/konacha-2.1.0/lib/konacha.rb:21:in `run'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/gems/konacha-2.1.0/lib/tasks/konacha.rake:9:in `block (2 levels) in <top (required)>'
/Users/markbates/Dropbox/development/reviewed_next/vogon/lib/tasks/tests.rake:13:in `block in <top (required)>'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
/Users/markbates/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => konacha:run
(See full trace by running task with --trace)

real    0m39.626s
user    0m37.850s
sys 0m3.030s

I will happily supply more details as they're needed. The stack trace and error message really give most of the details.

#test div display

As it is, it seems that the #test div is displayed but not styled. I'm wondering if we should try one of the following:

  • Provide for a way to add CSS, so that the #test contents can be styled properly. Or,
  • set "display: none" on #test to avoid messing up the test page, and to speed up the tests.

Test file order is undefined (random)

On localhost:3500, the order in which the test files (iframes) are loaded seems to be random, and it can change between reloads.

So when you hit reload, the test you are looking at might jump around. That's really confusing.

I don't think this is necessarily a blocker for 2.0, but we should still fix it.

frame focus issues with webkit

I have tests that pass with konacha:serve but fail with konacha:run using webkit driver (works with selenium). The following is an example test that fails.

#= require jquery
#= require jquery-ui
it "this should work", ->
  $("<div></div>").dialog()

The error is

undefined|0|TypeError: 'undefined' is not a function
rake aborted!
Error communicating with browser process: can't convert nil into String

The error is a result of Konacha.getEvents() not being defined. It appears the focus is changed to be on the internal iframe instead of the top level window. If I edit lib/konacha/runner.rb to call top.Konacha.getEvents() instead, it appears to work.

I am using the fixtures example in the readme and...

I briefly see a flash of the test running and I end up with a page that contains the contents of my fixture. I'm doing this:

describe 'example', ->
  it 'has some body', ->
    $('body').html("<b>HI!</b>")
    $('body').text().should.equal('HI!')

Can I call something somewhere to get Konacha to show the test results again instead of my fixture?

Renaming Konacha?

All of my team mates seemed to be unsure how to pronounce Konacha.

I'll be heretical and suggest that we might rename it for version 2.

Perhaps some random tea-related easier-to-pronounce name.

Or how about "mocha-rails"? We are including chai of course, but it might still be a fitting name, paralleling jasmine-rails for instance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.