jasminerice 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,11 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'rails', '3.1.0.rc4'
3
+ gem 'rails', '3.1.0'
4
4
 
5
5
  # Bundle edge Rails instead:
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
7
 
8
+ gemspec
8
9
 
9
- if RUBY_VERSION < '1.9'
10
+ platforms :ruby_18 do
10
11
  gem "ruby-debug", ">= 0.10.3"
11
12
  end
data/Gemfile.lock CHANGED
@@ -1,87 +1,110 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jasminerice (0.0.7)
5
+ haml
6
+
1
7
  GEM
2
8
  remote: http://rubygems.org/
3
9
  specs:
4
- actionmailer (3.1.0.rc4)
5
- actionpack (= 3.1.0.rc4)
10
+ actionmailer (3.1.0)
11
+ actionpack (= 3.1.0)
6
12
  mail (~> 2.3.0)
7
- actionpack (3.1.0.rc4)
8
- activemodel (= 3.1.0.rc4)
9
- activesupport (= 3.1.0.rc4)
13
+ actionpack (3.1.0)
14
+ activemodel (= 3.1.0)
15
+ activesupport (= 3.1.0)
10
16
  builder (~> 3.0.0)
11
17
  erubis (~> 2.7.0)
12
18
  i18n (~> 0.6)
13
- rack (~> 1.3.0)
14
- rack-cache (~> 1.0.1)
15
- rack-mount (~> 0.8.1)
16
- rack-test (~> 0.6.0)
17
- sprockets (~> 2.0.0.beta.10)
18
- tzinfo (~> 0.3.27)
19
- activemodel (3.1.0.rc4)
20
- activesupport (= 3.1.0.rc4)
21
- bcrypt-ruby (~> 2.1.4)
19
+ rack (~> 1.3.2)
20
+ rack-cache (~> 1.0.3)
21
+ rack-mount (~> 0.8.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.0.0)
24
+ activemodel (3.1.0)
25
+ activesupport (= 3.1.0)
26
+ bcrypt-ruby (~> 3.0.0)
22
27
  builder (~> 3.0.0)
23
28
  i18n (~> 0.6)
24
- activerecord (3.1.0.rc4)
25
- activemodel (= 3.1.0.rc4)
26
- activesupport (= 3.1.0.rc4)
27
- arel (~> 2.1.1)
28
- tzinfo (~> 0.3.27)
29
- activeresource (3.1.0.rc4)
30
- activemodel (= 3.1.0.rc4)
31
- activesupport (= 3.1.0.rc4)
32
- activesupport (3.1.0.rc4)
29
+ activerecord (3.1.0)
30
+ activemodel (= 3.1.0)
31
+ activesupport (= 3.1.0)
32
+ arel (~> 2.2.1)
33
+ tzinfo (~> 0.3.29)
34
+ activeresource (3.1.0)
35
+ activemodel (= 3.1.0)
36
+ activesupport (= 3.1.0)
37
+ activesupport (3.1.0)
33
38
  multi_json (~> 1.0)
34
- arel (2.1.1)
35
- bcrypt-ruby (2.1.4)
39
+ arel (2.2.1)
40
+ bcrypt-ruby (3.0.1)
41
+ bcrypt-ruby (3.0.1-java)
36
42
  builder (3.0.0)
43
+ columnize (0.3.4)
37
44
  erubis (2.7.0)
38
- hike (1.1.0)
45
+ haml (3.1.3)
46
+ hike (1.2.1)
39
47
  i18n (0.6.0)
48
+ json (1.6.1)
49
+ json (1.6.1-java)
50
+ linecache (0.46)
51
+ rbx-require-relative (> 0.0.4)
40
52
  mail (2.3.0)
41
53
  i18n (>= 0.4.0)
42
54
  mime-types (~> 1.16)
43
55
  treetop (~> 1.4.8)
44
- mime-types (1.16)
56
+ mime-types (1.17.2)
45
57
  multi_json (1.0.3)
46
- polyglot (0.3.1)
47
- rack (1.3.0)
48
- rack-cache (1.0.2)
58
+ polyglot (0.3.2)
59
+ rack (1.3.5)
60
+ rack-cache (1.0.3)
49
61
  rack (>= 0.4)
50
- rack-mount (0.8.1)
62
+ rack-mount (0.8.3)
51
63
  rack (>= 1.0.0)
52
64
  rack-ssl (1.3.2)
53
65
  rack
54
- rack-test (0.6.0)
66
+ rack-test (0.6.1)
55
67
  rack (>= 1.0)
56
- rails (3.1.0.rc4)
57
- actionmailer (= 3.1.0.rc4)
58
- actionpack (= 3.1.0.rc4)
59
- activerecord (= 3.1.0.rc4)
60
- activeresource (= 3.1.0.rc4)
61
- activesupport (= 3.1.0.rc4)
68
+ rails (3.1.0)
69
+ actionmailer (= 3.1.0)
70
+ actionpack (= 3.1.0)
71
+ activerecord (= 3.1.0)
72
+ activeresource (= 3.1.0)
73
+ activesupport (= 3.1.0)
62
74
  bundler (~> 1.0)
63
- railties (= 3.1.0.rc4)
64
- railties (3.1.0.rc4)
65
- actionpack (= 3.1.0.rc4)
66
- activesupport (= 3.1.0.rc4)
75
+ railties (= 3.1.0)
76
+ railties (3.1.0)
77
+ actionpack (= 3.1.0)
78
+ activesupport (= 3.1.0)
67
79
  rack-ssl (~> 1.3.2)
68
80
  rake (>= 0.8.7)
69
81
  rdoc (~> 3.4)
70
82
  thor (~> 0.14.6)
71
- rake (0.9.2)
72
- rdoc (3.6.1)
73
- sprockets (2.0.0.beta.10)
74
- hike (~> 1.0)
83
+ rake (0.9.2.2)
84
+ rbx-require-relative (0.0.5)
85
+ rdoc (3.11)
86
+ json (~> 1.4)
87
+ ruby-debug (0.10.4)
88
+ columnize (>= 0.1)
89
+ ruby-debug-base (~> 0.10.4.0)
90
+ ruby-debug-base (0.10.4)
91
+ linecache (>= 0.3)
92
+ sprockets (2.0.3)
93
+ hike (~> 1.2)
75
94
  rack (~> 1.0)
76
- tilt (!= 1.3.0, ~> 1.1)
95
+ tilt (~> 1.1, != 1.3.0)
77
96
  thor (0.14.6)
78
- tilt (1.3.2)
79
- treetop (1.4.9)
97
+ tilt (1.3.3)
98
+ treetop (1.4.10)
99
+ polyglot
80
100
  polyglot (>= 0.3.1)
81
- tzinfo (0.3.28)
101
+ tzinfo (0.3.30)
82
102
 
83
103
  PLATFORMS
104
+ java
84
105
  ruby
85
106
 
86
107
  DEPENDENCIES
87
- rails (= 3.1.0.rc4)
108
+ jasminerice!
109
+ rails (= 3.1.0)
110
+ ruby-debug (>= 0.10.3)
data/README.md CHANGED
@@ -1,80 +1,117 @@
1
1
  Jasminerice
2
2
  ===========
3
3
 
4
- Utilizing (jasmine)[http://pivotal.github.com/jasmine/] and taking full advantage
5
- of the Rails 3.1 asset pipeline jasmine rice removes any excuse YOU have for
6
- not testing your out of control sprawl of coffeescript files.
7
- This project rocks and uses MIT-LICENSE.
4
+ Utilizing [Jasmine](http://pivotal.github.com/jasmine/) and taking full advantage
5
+ of the Rails 3.1 asset pipeline. Jasminerice removes any excuse YOU have for
6
+ not testing your out of control sprawl of CoffeeScript files.
7
+ This project rocks and uses the MIT-LICENSE.
8
8
 
9
- Setup For Rails 3.1
10
- -------------------
9
+ Headless Testing
10
+ ----------------
11
11
 
12
- This is a gem specifically for Rails 3.1. Just include it in
13
- your Gemfile so
12
+ See [guard-jasmine](https://github.com/netzpirat/guard-jasmine) for details.
14
13
 
15
- gem "jasminerice"
14
+ Installation
15
+ ------------
16
16
 
17
- Now add a route to the end of your config.routes but only for development and test
17
+ This is a gem specifically for Rails 3.1. Just include it in
18
+ your `Gemfile`:
18
19
 
19
- if ["development", "test"].include? Rails.env
20
- mount Jasminerice::Engine => "/jasmine"
21
- end
20
+ ```ruby
21
+ group :development, :test
22
+ gem "jasminerice"
23
+ end
24
+ ```
22
25
 
23
- Create a single file called
26
+ The engine is automatically mounted into your application in the development
27
+ and test environments. If you'd like to change that behavior, you can
28
+ override the array `Jasminerice.environments` in an initializer.
24
29
 
25
- specs/javascripts/spec.js.coffee
30
+ Usage
31
+ -----
26
32
 
27
- with the following content
33
+ ### CoffeeScripts
28
34
 
29
- #=require_tree ./
35
+ Create a file `spec/javascripts/spec.js.coffee` with the following content:
30
36
 
31
- This pulls in all your
37
+ #=require_tree ./
32
38
 
33
- specs/javascripts/*_spec.js.coffee
34
- specs/javascripts/*_spec.js
35
- specs/javascripts/*_spec.js.erb
36
- etc
39
+ This pulls in all your specs from the `javascripts` directory into Jasmine:
37
40
 
38
- into jasmine. For example
41
+ ```bash
42
+ spec/javascripts/*_spec.js.coffee
43
+ spec/javascripts/*_spec.js
44
+ spec/javascripts/*_spec.js.erb
45
+ ```
39
46
 
40
- spec/javascripts/foo.js.coffe
47
+ The Rails 3.1 asset pipeline using [Sprockets](https://github.com/sstephenson/sprockets)
48
+ and [Tilt](https://github.com/rtomayko/tilt) ensure conversion.
41
49
 
42
- #= require foo
43
- #= require bar
50
+ As well you can use the `#require` dependency mechanisms in your specs to
51
+ pull dependencies. Here's an example `spec/javascripts/foo.js.coffee`:
44
52
 
45
- describe "Foo", ->
53
+ ```coffeescript
54
+ #= require foo
55
+ #= require bar
46
56
 
47
- it "it is not bar", ->
48
- v = new Foo()
57
+ describe "Foo", ->
58
+ it "it is not bar", ->
59
+ v = new Foo()
60
+ expect(v.bar()).toEqual(false)
49
61
 
50
- expect(v.bar()).toEqual(false)
62
+ describe "Bar", ->
63
+ it "it is not foo", ->
64
+ v = new Bar()
65
+ expect(v.foo()).toEqual(false)
66
+ ```
51
67
 
52
- describe "Bar", ->
68
+ ### Stylesheets
53
69
 
54
- it "it is not foo", ->
55
- v = new Bar()
70
+ For including stylesheets in your specs, Jasminerice uses `spec/javascripts/spec.css`.
71
+ Use Sprockets directives to include the right css files:
56
72
 
57
- expect(v.foo()).toEqual(false)
73
+ ```css
74
+ /*
75
+ *= require application
76
+ */
77
+ ```
58
78
 
79
+ ### Fixtures
59
80
 
60
- The Rails 3.1 asset pipeline using sprockets and tilt
61
- ensure conversion. As well you can use the #require
62
- dependency mechanisms
81
+ Jasminerice makes files located in the `spec/javascripts/fixtures` directory available
82
+ as fixture. For example, a file `spec/javascripts/fixtures/baz.html.haml` with the
83
+ following content:
63
84
 
64
- Now start your server
85
+ ```haml
86
+ %h2 Test Fixture
87
+ %p Using fixtures
88
+ ```
65
89
 
66
- rails s
90
+ is made available under the URL `/jasmine/fixtures/baz`. Since Jasminerice automatically
91
+ makes a patched version of [jasmine-jquery](https://github.com/velesin/jasmine-jquery)
92
+ available in your specs, you can load the `baz` fixture in your spec with:
67
93
 
68
- Goto
94
+ ```coffeescript
95
+ loadFixtures 'baz'
96
+ ```
69
97
 
70
- http://localhost:3000/jasmine
98
+ ### Start server
71
99
 
72
- and there are your specs.
100
+ Now start your server
73
101
 
74
- Questions:
102
+ ```bash
103
+ rails s
104
+ ```
75
105
 
76
- bradphelan@xtargets.com
106
+ Goto
77
107
 
108
+ ```bash
109
+ http://localhost:3000/jasmine
110
+ ```
78
111
 
112
+ and there are your specs.
79
113
 
114
+ Author
115
+ ------
80
116
 
117
+ * Brad Phelan (bradphelan@xtargets.com)
data/Rakefile CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env rake
2
2
  begin
3
- require 'bundler/setup'
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
4
5
  rescue LoadError
5
6
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
7
  end
8
+
7
9
  begin
8
10
  require 'rdoc/task'
9
11
  rescue LoadError
@@ -1,17 +1,22 @@
1
1
  #=require jasmine
2
2
  #=require jasmine-html
3
- #=require jasmine-jquery-1.2.0
3
+ #=require jasmine-jquery-1.3.1
4
4
 
5
5
  (->
6
6
  execJasmine = ->
7
7
  jasmineEnv.execute()
8
8
  jasmineEnv = jasmine.getEnv()
9
9
  jasmineEnv.updateInterval = 1000
10
+
11
+ window.jsApiReporter = new jasmine.JsApiReporter()
10
12
  trivialReporter = new jasmine.TrivialReporter()
13
+
11
14
  jasmineEnv.addReporter trivialReporter
15
+ jasmineEnv.addReporter jsApiReporter
16
+
12
17
  jasmineEnv.specFilter = (spec) ->
13
18
  trivialReporter.specFilter spec
14
-
19
+
15
20
  currentWindowOnload = window.onload
16
21
  window.onload = ->
17
22
  currentWindowOnload() if currentWindowOnload
@@ -1,5 +1,5 @@
1
1
  module Jasminerice
2
- class SpecController < ApplicationController
2
+ class SpecController < Jasminerice::ApplicationController
3
3
  layout false
4
4
 
5
5
  def index
@@ -2,6 +2,7 @@
2
2
  %head
3
3
  %title Jasmine Spec Runner
4
4
  = stylesheet_link_tag "jasmine"
5
+ = stylesheet_link_tag "spec"
5
6
  = javascript_include_tag "jasminerice", :debug => Rails.env.development?
6
7
  = javascript_include_tag "spec", :debug => Rails.env.development?
7
8
  = csrf_meta_tags
data/config/routes.rb CHANGED
@@ -6,3 +6,9 @@ Jasminerice::Engine.routes.draw do
6
6
 
7
7
  root :to => "spec#index"
8
8
  end
9
+
10
+ Rails.application.routes.draw do
11
+ if Jasminerice.environments.include? Rails.env
12
+ mount Jasminerice::Engine => "/jasmine"
13
+ end
14
+ end
data/jasminerice.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.description = "Full support for the Rails 3.1 asset pipeline when bdd'ing your coffeescript or javascript using jasmine"
7
7
  s.files = `git ls-files`.split "\n"
8
8
  s.authors = ["Brad Phelan"]
9
- s.version = "0.0.7"
9
+ s.version = "0.0.8"
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.add_dependency( 'haml' )
12
12
  end
data/lib/jasminerice.rb CHANGED
@@ -2,4 +2,6 @@ require "jasminerice/engine"
2
2
  require 'haml'
3
3
 
4
4
  module Jasminerice
5
+ mattr_accessor :environments
6
+ self.environments = %w(development test)
5
7
  end
@@ -2,6 +2,10 @@ var readFixtures = function() {
2
2
  return jasmine.getFixtures().proxyCallTo_('read', arguments);
3
3
  };
4
4
 
5
+ var preloadFixtures = function() {
6
+ jasmine.getFixtures().proxyCallTo_('preload', arguments);
7
+ };
8
+
5
9
  var loadFixtures = function() {
6
10
  jasmine.getFixtures().proxyCallTo_('load', arguments);
7
11
  };
@@ -35,6 +39,10 @@ jasmine.Fixtures.prototype.set = function(html) {
35
39
  this.createContainer_(html);
36
40
  };
37
41
 
42
+ jasmine.Fixtures.prototype.preload = function() {
43
+ this.read.apply(this, arguments);
44
+ };
45
+
38
46
  jasmine.Fixtures.prototype.load = function() {
39
47
  this.cleanUp();
40
48
  this.createContainer_(this.read.apply(this, arguments));
@@ -56,21 +64,26 @@ jasmine.Fixtures.prototype.clearCache = function() {
56
64
  };
57
65
 
58
66
  jasmine.Fixtures.prototype.cleanUp = function() {
59
- $('#' + this.containerId).remove();
67
+ jQuery('#' + this.containerId).remove();
60
68
  };
61
69
 
62
70
  jasmine.Fixtures.prototype.sandbox = function(attributes) {
63
71
  var attributesToSet = attributes || {};
64
- return $('<div id="sandbox" />').attr(attributesToSet);
72
+ return jQuery('<div id="sandbox" />').attr(attributesToSet);
65
73
  };
66
74
 
67
75
  jasmine.Fixtures.prototype.createContainer_ = function(html) {
68
- var container = $('<div id="' + this.containerId + '" />');
69
- container.html(html);
70
- $('body').append(container);
76
+ var container;
77
+ if(html instanceof jQuery) {
78
+ container = jQuery('<div id="' + this.containerId + '" />');
79
+ container.html(html);
80
+ } else {
81
+ container = '<div id="' + this.containerId + '">' + html + '</div>'
82
+ }
83
+ jQuery('body').append(container);
71
84
  };
72
85
 
73
- jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
86
+ jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
74
87
  if (typeof this.fixturesCache_[url] == 'undefined') {
75
88
  this.loadFixtureIntoCache_(url);
76
89
  }
@@ -80,13 +93,16 @@ jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
80
93
  jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
81
94
  var self = this;
82
95
  var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl;
83
- $.ajax({
96
+ jQuery.ajax({
84
97
  async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
85
98
  cache: false,
86
99
  dataType: 'html',
87
100
  url: url,
88
101
  success: function(data) {
89
102
  self.fixturesCache_[relativeUrl] = data;
103
+ },
104
+ error: function(jqXHR, status, errorThrown) {
105
+ throw Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')');
90
106
  }
91
107
  });
92
108
  };
@@ -99,11 +115,11 @@ jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments)
99
115
  jasmine.JQuery = function() {};
100
116
 
101
117
  jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
102
- return $('<div/>').append(html).html();
118
+ return jQuery('<div/>').append(html).html();
103
119
  };
104
120
 
105
121
  jasmine.JQuery.elementToString = function(element) {
106
- return $('<div />').append(element.clone()).html();
122
+ return jQuery('<div />').append(element.clone()).html();
107
123
  };
108
124
 
109
125
  jasmine.JQuery.matchersClass = {};
@@ -119,7 +135,7 @@ jasmine.JQuery.matchersClass = {};
119
135
  var handler = function(e) {
120
136
  data.spiedEvents[[selector, eventName]] = e;
121
137
  };
122
- $(selector).bind(eventName, handler);
138
+ jQuery(selector).bind(eventName, handler);
123
139
  data.handlers.push(handler);
124
140
  },
125
141
 
@@ -200,9 +216,27 @@ jasmine.JQuery.matchersClass = {};
200
216
  return this.actual.find(selector).size() > 0;
201
217
  },
202
218
 
203
- toBeDisabled: function(selector){
204
- return this.actual.attr("disabled") == true;
205
- }
219
+ toBeDisabled: function(selector){
220
+ return this.actual.is(':disabled');
221
+ },
222
+
223
+ // tests the existence of a specific event binding
224
+ toHandle: function(eventName) {
225
+ var events = this.actual.data("events");
226
+ return events && events[eventName].length > 0;
227
+ },
228
+
229
+ // tests the existence of a specific event binding + handler
230
+ toHandleWith: function(eventName, eventHandler) {
231
+ var stack = this.actual.data("events")[eventName];
232
+ var i;
233
+ for (i = 0; i < stack.length; i++) {
234
+ if (stack[i].handler == eventHandler) {
235
+ return true;
236
+ }
237
+ }
238
+ return false;
239
+ }
206
240
  };
207
241
 
208
242
  var hasProperty = function(actualValue, expectedValue) {
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jasminerice
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.7
5
+ version: 0.0.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brad Phelan
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-26 00:00:00 Z
13
+ date: 2011-11-04 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: haml
@@ -54,7 +54,7 @@ files:
54
54
  - lib/tasks/jasminerice_tasks.rake
55
55
  - vendor/assets/images/jasmine_favicon.png
56
56
  - vendor/assets/javascripts/jasmine-html.js
57
- - vendor/assets/javascripts/jasmine-jquery-1.2.0.js
57
+ - vendor/assets/javascripts/jasmine-jquery-1.3.1.js
58
58
  - vendor/assets/javascripts/jasmine.js
59
59
  - vendor/assets/stylesheets/jasmine.css
60
60
  homepage: