For my rails deployers, I wanted to be able to write tests using RSpec. I've been
reworking the rspec-maven-plugin so that this will eventually work in your normal mvn test
build.
RSpec itself is a BDD testing tool, and tries to be fairly useful and self-documenting of
tests.
Here's what I've got so far to spin up a basic VFS-enabled MC, jam in 1 deployer,
and deploy a file.
| require 'deployers/deployer_test_helper'
|
| import org.jboss.rails.core.deployers.AppRailsYamlParsingDeployer
| import org.jboss.rails.core.metadata.RailsApplicationMetaData
|
| describe AppRailsYamlParsingDeployer do
|
| include DeployerTestHelper
|
| def create_deployers
| [
| AppRailsYamlParsingDeployer.new
| ]
| end
|
| before( :each ) do
| setup_microcontainer
| end
|
| it "should create a sub-deployment with pre-attached
RailsApplicationMetaData" do
| deployment = deploy(
"#{BASE_DIR}/src/test/resources/deployments/toplevel/simple-rails.yml" )
| unit = deployment_unit_for( deployment )
|
| sub_deployment = unit.getAttachment( "jboss.rails.root.deployment" )
| sub_deployment.should_not be_nil
| sub_unit = deployment_unit_for( sub_deployment )
|
| meta_data = sub_unit.getAttachment( RailsApplicationMetaData.java_class )
| meta_data.should_not be_nil
| meta_data.getRailsRootPath().should eql( '/Users/bob/oddthesis/oddthesis'
)
| meta_data.getRailsEnv().should eql( 'development' )
| end
|
| end
|
For example, in the above test, the AppRailsYamlParsingDeployer actually doesn't
attach meta-data, but triggers a sub-deployment of another VFS, and attaches the
sub-deployment to the unit of the root deployment. While this might not be
"awesome" in terms of VDF usage, it just shows the ease of mucking about in all
the innards from the Ruby end of things.
If there's any further interest in this, I can break this framework out of the
jboss-rails project into a more generally useful deployer-testing add-on for RSpec users.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4226032#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...