- When running rake:cucumber ActiveRecord models cannot access same database as app
- Feature: Creating a campaign
- As someone with too much time on my hands
- I want to create a campaign
- So that I can monitor my roleplaying campaigns
- Scenario: Adding a Campaign
- Given I am at the site
- When I create a campaign "The Hills" with a setting "Cali"
- Then the campaign should persist in the system
- Given /^I create a campaign "([^"]*)" with a setting "([^"]*)"$/ do |name, setting|
- @browser.text_field(:id => "campaign_campaign_name").set name
- @browser.text_field(:id => "campaign_setting").set setting
- @browser.button(:value => "Create Campaign").click
- @campaign_name = name
- @setting = setting
- end
- Then /^the campaign should persist in the system$/ do
- @browser.text.should =~ /#{@campaign_name}/
- @browser.text.should =~ /#{@setting}/
- @database_campaign = Campaign.where(:campaign_name => @campaign_name)[0]
- @database_campaign.campaign_name.should == @campaign_name
- end
- def establish_connection_to_test_database
- begin
- ActiveRecord::Base.establish_connection :test
- rescue
- raise "You have not established a connection to the test database"
- end
- end
- establish_connection_to_test_database
- Then /^the campaign should persist in the system$/ do
- sleep 1.0
- @browser.text.should =~ /#{@campaign_name}/
- @browser.text.should =~ /#{@setting}/
- @database_campaign = Campaign.where(:campaign_name => @campaign_name)[0]
- @database_campaign.campaign_name.should == @campaign_name
- end
- Then /^the campaign should persist in the system$/ do
- @browser.text.should include(@campaign_name)
- @browser.text.should include(@setting)
- end