Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 15th, 2012  |  syntax: None  |  size: 1.64 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. When running rake:cucumber ActiveRecord models cannot access same database as app
  2. Feature: Creating a campaign
  3.  
  4. As someone with too much time on my hands
  5. I want to create a campaign
  6. So that I can monitor my roleplaying campaigns
  7.  
  8. Scenario: Adding a Campaign
  9.     Given I am at the site
  10.     When I create a campaign "The Hills" with a setting "Cali"
  11.     Then the campaign should persist in the system
  12.        
  13. Given /^I create a campaign "([^"]*)" with a setting "([^"]*)"$/ do |name, setting|
  14.   @browser.text_field(:id => "campaign_campaign_name").set name
  15.   @browser.text_field(:id => "campaign_setting").set setting
  16.   @browser.button(:value => "Create Campaign").click
  17.   @campaign_name = name
  18.   @setting = setting
  19. end
  20.  
  21. Then /^the campaign should persist in the system$/ do
  22.   @browser.text.should =~ /#{@campaign_name}/
  23.   @browser.text.should =~ /#{@setting}/
  24.   @database_campaign = Campaign.where(:campaign_name => @campaign_name)[0]
  25.   @database_campaign.campaign_name.should == @campaign_name
  26. end
  27.        
  28. def establish_connection_to_test_database
  29.   begin
  30.     ActiveRecord::Base.establish_connection :test
  31.   rescue
  32.     raise "You have not established a connection to the test database"
  33.   end
  34. end
  35.  
  36. establish_connection_to_test_database
  37.        
  38. Then /^the campaign should persist in the system$/ do
  39.   sleep 1.0
  40.  
  41.   @browser.text.should =~ /#{@campaign_name}/
  42.   @browser.text.should =~ /#{@setting}/
  43.   @database_campaign = Campaign.where(:campaign_name => @campaign_name)[0]
  44.   @database_campaign.campaign_name.should == @campaign_name
  45. end
  46.        
  47. Then /^the campaign should persist in the system$/ do
  48.   @browser.text.should include(@campaign_name)
  49.   @browser.text.should include(@setting)
  50. end