RSS Amplifier

Recent Questions - Software Engineering Stack Exchange · Apr 14, 2014

Rails engine testing - use dummy app or real parent app?

0
Sign in to vote or save

This page did not load. You can still read it on the original site — the toolbar below keeps your place in the directory.

I'm using Rails engines to break up a big app into smaller pieces. The parent app mostly handles users and authentication. In one of my engine tests I want to log in a user before each test. How should I access this user log in functionality, which exists in the parent app, from the engine? It seems there are two options: 1) Build user authentication into the dummy app. When you run rails plugin…

I'm using Rails engines to break up a big app into smaller pieces. The parent app mostly handles users and authentication.

In one of my engine tests I want to log in a user before each test. How should I access this user log in functionality, which exists in the parent app, from the engine?

It seems there are two options:

1) Build user authentication into the dummy app. When you run rails plugin new app_name --mountable a "dummy app" - just a plain Rails app - is created in your test folder. During tests the engine is mounted on to this dummy app. For feature (integration, acceptance, what-have-you) tests, I thought it would be good to use real objects whenever possible. So I was planning on using a factory to create a real user and then log in that user. To do this with the dummy app, I would need to build that user functionality in.

This seems like a pain because if the real parent app changes, I need to change this dummy app as well.

2) Put all my tests in the parent app. This will work fine, I think, but it seems fishy. I feel like I should put my engine tests in the engine.

Read on softwareengineering.stackexchange.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.