Test rail engine generator with rspec

I am creating a Simpe Gem that includes an installation generator, the generator works fine, but now I want to test it with rspec, I use this gem and try to check my generator, my specification code:

require 'genspec'
require 'rosalie'

describe :install_generator do

  it "should generate model" do
    subject.should generate("message.rb")
  end
end

rosalie is the name can gem, now when I run it I got the error message: / stuff / work / my _projects / rosalie / lib / rosalie / engine.rb: 2: in ``: uninitialized constant Rosalie :: Rails (NameError)

my engine.rb code is:

module Rosalie
  class Engine < Rails::Engine

    initializer "rosalie.models.messageable" do
      ActiveSupport.on_load(:active_record) do
        include Rosalie::Models::Messageable
      end
    end
  end
end

Can anyone help me with this problem?

+5
source share
2 answers

You must download your code before including it anywhere.

Either required, or autoload of the main file.

.

+2

spec_helper.rb spec_helper spec.

require File.expand_path("../dummy/config/environment", __FILE__)
require 'rspec/rails'
+1

All Articles