How to test Rails 3 Engines with Cucumber & Rspec?

前端 未结 3 1665
小鲜肉
小鲜肉 2021-02-01 06:22

I apologize if this question is slightly subjective... I am trying to figure out the best way to test Rails 3 Engines with Cucumber & Rspec. In order to test the engine a r

3条回答
  •  旧巷少年郎
    2021-02-01 06:57

    Rails 3.1 (will) generate a pretty good scaffold for engines. I'd recommend using RVM to create a new gemset called edge and switch to it:

    rvm gemset create edge
    rvm use @edge
    

    Then install edge rails:

    git clone git://github.com/rails/rails.git
    cd rails
    rake install
    

    From there, you can follow Piotr Sarnacki's mountable app tutorial, replacing calls such as:

    bundle exec ./bin/rails plugin new ../blog --edge --mountable
    

    With simply:

    rails plugin new blog --mountable --full
    

    The mountable option makes the application mountable, whilst the full option makes it an engine with tests already built-in. To test the engine, this generator generates a folder in test called dummy which contains a small Rails application. You can see how this is loaded in test/test_helper.rb.

    Then it's up to you to massage the data to do what it needs to in order to work. I would recommend copying over the cucumber files from a standard rails g cucumber:install into the project and then messing about with it until it works. I've done this once before so I know it's possible, but I cannot find the code right now.

    Let me know how you go.

提交回复
热议问题