pivotal/jasmine-gem — Issue #57: Rake tasks fail in Rails 3.x Engines
Author: lightcap
Created: 2011-10-12 21:05:12+00:00
State: open

The following trace occurs when trying to run rake from a Rails Engine that only includes `rails/engine` and not all of Rails.

undefined method `version' for Rails:Module
gems/jasmine-1.1.0/lib/jasmine/base.rb:49:in `rails3?'
gems/jasmine-1.1.0/lib/jasmine.rb:12

This happens because of [this check](https://github.com/pivotal/jasmine-gem/blob/master/lib/jasmine/base.rb#L49) in `lib/jasmine/base.rb`:

```ruby
return Rails.version.split(".").first.to_i == 3 if defined? Rails
```

There is no `version` method defined on `Rails` unless you `include 'rails'` which is overkill for an engine. Changing to the following fixes the issue and I'll drop a pull request shortly:

```ruby
return Rails::VERSION::MAJOR.to_i === 3 if defined? Rails::VERSION
```