jasmine-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +134 -0
  2. data/lib/jasmine_rails/version.rb +1 -1
  3. metadata +65 -94
  4. data/README.rdoc +0 -3
data/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # jasmine-rails gem
2
+
3
+ This project is intended to make it a little easier to integrate [Jasmine](https://github.com/pivotal/jasmine/wiki) into your workflow, particularly if you're working in Rails 3.1 or later. (If you're on earlier versions of Rails, I'd suggest directly using the combination of Pivotal's [jasmine gem](https://github.com/pivotal/jasmine-gem) and [jasmine-headless-webkit](http://johnbintz.github.com/jasmine-headless-webkit/).)
4
+
5
+ By bundling this gem and configuring your project, you can expect to:
6
+
7
+ * Be able to run Jasmine specs from the command line (*and fast*) with John Bintz's excellent [jasmine-headless-webkit](http://johnbintz.github.com/jasmine-headless-webkit/)
8
+ * Be able to run Jasmine specs in a browser (wherever you choose to mount the jasmine-rails engine)
9
+ * Write specs or source in [CoffeeScript](http://jashkenas.github.com/coffee-script/), leveraging the [asset pipeline](http://railscasts.com/episodes/279-understanding-the-asset-pipeline) to pre-process it
10
+
11
+ ## Prerequisites
12
+
13
+ Install qt for its headless webkit widget. The easiest way (on a Mac) that I've found is to use [homebrew](https://github.com/mxcl/homebrew):
14
+
15
+ brew install qt
16
+
17
+ For help installing the qt libs on other platforms, the I'd recommend [perusing capybara-webkit driver's documentation](https://github.com/thoughtbot/capybara-webkit), becuse it has the same dependency.
18
+
19
+ ## Adding the gem
20
+
21
+ Add jasmine-rails to your Gemfile, like so
22
+
23
+ group :test, :development do
24
+ gem 'jasmine-rails'
25
+ end
26
+
27
+ Next, run `bundle install`.
28
+
29
+ Now, we'll use the jasmine gem to initialize a jasmine.yml configuration file:
30
+
31
+ bundle exec jasmine init
32
+
33
+ And remove some files the jasmine gem creates that you won't need:
34
+
35
+ rm public/javascripts/Player.js public/javascripts/Song.js spec/javascripts/PlayerSpec.js spec/javascripts/helpers/SpecHelper.js lib/tasks/jasmine.rake
36
+
37
+ Next, edit the generated `spec/javascripts/support/jasmine.yml` file to ensure that it will find all your JavaScript sources and specs. The default file is written for Rails <3.1 so it doesn't know about the asset directories. As an example, mine looks like this:
38
+
39
+ src_files:
40
+ - "vendor/**/*.{js,coffee}"
41
+ - "lib/**/*.{js,coffee}"
42
+ - "app/**/*.{js,coffee}"
43
+
44
+ stylesheets:
45
+ - "vendor/**/*.css"
46
+ - "lib/**/*.css"
47
+ - "app/**/*.css"
48
+
49
+ helpers:
50
+ - "helpers/**/*.{js,coffee}"
51
+
52
+ spec_files:
53
+ - "**/*[Ss]pec.{js,coffee}"
54
+
55
+ src_dir:
56
+
57
+ spec_dir: spec/javascripts
58
+
59
+ ## Running from the command line
60
+
61
+ If you were to run:
62
+
63
+ bundle exec jasmine-headless-webkit --color
64
+
65
+ You'd hopefully see something like:
66
+
67
+ Running Jasmine specs...
68
+
69
+ PASS: 0 tests, 0 failures, 0.001 secs.
70
+
71
+ I encourage you to explore John Bintz's excellent [jasmine-headless-webkit's documentation](http://johnbintz.github.com/jasmine-headless-webkit/) for more ideas, like creating a Rake task or running it on a display-less CI server.
72
+
73
+ If you experience an error at this point, the most likely cause is JavaScript being loaded out of order, or otherwise conflicting with other existing JavaScript in your project. See "Debugging" below.
74
+
75
+ ## Running from your browser
76
+
77
+ Just mount jasmine-rails by adding something like this to your routes.rb:
78
+
79
+ ``` ruby
80
+ mount JasmineRails::Engine => "/specs" unless Rails.env.production?
81
+ ```
82
+
83
+ Now when you run `bundle exec rails s`, and navigate to [http://localhost:3000/specs](http://localhost:3000/specs), you should see a Jasmine spec runner in your browser.
84
+
85
+ ## Debugging
86
+
87
+ ### In your browser
88
+
89
+ In my workflow, I like to work with specs in the command line until I hit a snag and could benefit from debugging in [Web Inspector](http://www.webkit.org/blog/1091/more-web-inspector-updates/) or [Firebug](http://getfirebug.com/) to figure out what's going on.
90
+
91
+ When debugging, I append the query param "**debug_assets=true**" like so: [http://localhost:3000/specs?debug_assets=true](http://localhost:3000/specs?debug_assets=true).
92
+
93
+ This is telling the asset pipeline to include each of your scripts in *individual* `<script>` tags. Seeing each script loaded separately makes debugging much easier for me.
94
+
95
+ ### From the command line
96
+
97
+ Even though they both read from the same config file, it's certainly possible that your specs will pass in the browser and fail from the command line. In this case, you can try to debug or analyze what's going on by using the "--keep" flag from jasmine-headless-webkit.
98
+
99
+ By running:
100
+
101
+ bundle exec jasmine-headless-webkit --keep
102
+
103
+ If the tests fail, jasmine-headless-webkit will leave its generated spec runner HTML file persisted in your rails root folder. It'll be named something like "specrunner.48160.html".
104
+
105
+ ## Guard
106
+
107
+ [Guard](https://github.com/guard/guard) is a great tool for triggering spec runs when files change. To use it, you can bundle these gems:
108
+
109
+ group :test, :development do
110
+ ...
111
+ gem 'guard-rails-assets'
112
+ gem 'guard-jasmine-headless-webkit'
113
+ ...
114
+ end
115
+
116
+ In my Guardfile, this configuration is working well for me:
117
+
118
+ guard 'rails-assets' do
119
+ watch(%r{^.*/assets/.+$})
120
+ watch('config/application.rb')
121
+ end
122
+
123
+ spec_location = "spec/javascripts/%s_spec"
124
+
125
+ guard 'jasmine-headless-webkit' do
126
+ watch(%r{^app/views/.*\.jst$})
127
+ watch(%r{^public/javascripts/(.*)\.js$}) { |m| newest_js_file(spec_location % m[1]) }
128
+ watch(%r{^.*/assets/javascripts/(.*)\.(js|coffee)$}) { |m| newest_js_file(spec_location % m[1]) }
129
+ watch(%r{^spec/javascripts/(.*)_spec\..*}) { |m| newest_js_file(spec_location % m[1]) }
130
+ end
131
+
132
+ Finally, to run guard, just:
133
+
134
+ bundle exec guard
@@ -1,3 +1,3 @@
1
1
  module JasmineRails
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,108 +1,83 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jasmine-rails
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Justin Searls
14
9
  - Mark Van Holstyn
15
10
  - Cory Flanigan
16
11
  autorequire:
17
12
  bindir: bin
18
13
  cert_chain: []
19
-
20
- date: 2011-09-01 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
14
+ date: 2012-02-12 00:00:00.000000000Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
23
17
  name: rails
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &889853470 !ruby/object:Gem::Requirement
26
19
  none: false
27
- requirements:
28
- - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 3
33
- - 1
34
- - 0
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
35
23
  version: 3.1.0
36
24
  type: :runtime
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: jasmine
40
25
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
26
+ version_requirements: *889853470
27
+ - !ruby/object:Gem::Dependency
28
+ name: jasmine
29
+ requirement: &889852800 !ruby/object:Gem::Requirement
42
30
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- hash: 3
47
- segments:
48
- - 0
49
- version: "0"
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
50
35
  type: :runtime
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: jasmine-headless-webkit
54
36
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
37
+ version_requirements: *889852800
38
+ - !ruby/object:Gem::Dependency
39
+ name: jasmine-headless-webkit
40
+ requirement: &889852090 !ruby/object:Gem::Requirement
56
41
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
64
46
  type: :runtime
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- name: rspec
68
47
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
48
+ version_requirements: *889852090
49
+ - !ruby/object:Gem::Dependency
50
+ name: rspec
51
+ requirement: &889851630 !ruby/object:Gem::Requirement
70
52
  none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 3
75
- segments:
76
- - 0
77
- version: "0"
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
78
57
  type: :development
79
- version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- name: gimme
82
58
  prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
59
+ version_requirements: *889851630
60
+ - !ruby/object:Gem::Dependency
61
+ name: gimme
62
+ requirement: &889851010 !ruby/object:Gem::Requirement
84
63
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
- version: "0"
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
92
68
  type: :development
93
- version_requirements: *id005
94
- description: Provides a Jasmine Spec Runner that plays nicely with Rails 3.1 assets and sets up jasmine-headless-webkit
95
- email:
69
+ prerelease: false
70
+ version_requirements: *889851010
71
+ description: Provides a Jasmine Spec Runner that plays nicely with Rails 3.1 assets
72
+ and sets up jasmine-headless-webkit
73
+ email:
96
74
  - searls@gmail.com
97
75
  - mvanholstyn@gmail.com
98
76
  - seeflanigan@gmail.com
99
77
  executables: []
100
-
101
78
  extensions: []
102
-
103
79
  extra_rdoc_files: []
104
-
105
- files:
80
+ files:
106
81
  - app/assets/javascripts/jasmine_rails/application.js
107
82
  - app/assets/stylesheets/jasmine_rails/application.css
108
83
  - app/controllers/jasmine_rails/application_controller.rb
@@ -117,39 +92,35 @@ files:
117
92
  - lib/processes_jasmine_directives.rb
118
93
  - MIT-LICENSE
119
94
  - Rakefile
120
- - README.rdoc
95
+ - README.md
121
96
  homepage: http://github.com/searls/jasmine-rails
122
97
  licenses: []
123
-
124
98
  post_install_message:
125
99
  rdoc_options: []
126
-
127
- require_paths:
100
+ require_paths:
128
101
  - lib
129
- required_ruby_version: !ruby/object:Gem::Requirement
102
+ required_ruby_version: !ruby/object:Gem::Requirement
130
103
  none: false
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- hash: 3
135
- segments:
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ segments:
136
109
  - 0
137
- version: "0"
138
- required_rubygems_version: !ruby/object:Gem::Requirement
110
+ hash: -122910413
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
112
  none: false
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- hash: 3
144
- segments:
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ segments:
145
118
  - 0
146
- version: "0"
119
+ hash: -122910413
147
120
  requirements: []
148
-
149
121
  rubyforge_project:
150
122
  rubygems_version: 1.8.6
151
123
  signing_key:
152
124
  specification_version: 3
153
125
  summary: Makes Jasmine easier on Rails 3.1
154
126
  test_files: []
155
-
data/README.rdoc DELETED
@@ -1,3 +0,0 @@
1
- = JasmineRails
2
-
3
- This project rocks and uses MIT-LICENSE.