Though others have probably been doing something similar for years, it wasn't until today that I realized that there was no reasonable reason why I couldn't, as long as both my rails application and my cfwheels app could reach the same database, then I could use Cucumber, with fixtures, models and DatabaseCleaner, to test the application with some ability to adjust the test data as I went along. Heck, I could even use the models in some step definitions if I wanted to.
I develop on a Mac Book Pro with VMWare running a SQL Server instance. I have previously developed a Rails application that connects to SQL Server and uses Cucumber for testing, so I know that can be done.
So, I created a new Rails app
user$ rails new cfw_cucumber_tests
I edited the Gemfile and added the following (since this 'app' will only be used to run cuc tests, I didn't need to group these statements in a development or test area):
gem 'cucumber'
gem 'cucumber-rails'
gem 'capybara'gem 'database_cleaner'gem 'activerecord-sqlserver-adapter'
I ran bundle install to ensure I had the gems. Then I ran
rails generate cucumber:install
to bootstrap the cucumber setup.
I had already added an entry in my hosts file that points to the local host, so I modified my cucumber env file with the following:
require 'cucumber/rails'
require 'capybara'
require 'capybara/dsl'
require 'capybara/cucumber'
Capybara.default_driver = :selenium
Capybara.app_host = 'http://isaac.local'
World(Capybara)
I wrote a quick test to see if I could get it to open the browser and point to the login page of the application.
Scenario: I can see the home page
Given I am starting on the home page
with the following step:
Given /^I am starting on the home page$/ do
visit('/index.cfm/login')
endAnd lo behold, my CFWheels app opened. More on actually running real tests and setting up fixtures in the next post.
No comments:
Post a Comment