Skip to content

Instantly share code, notes, and snippets.

@linojon
Created September 20, 2009 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linojon/189670 to your computer and use it in GitHub Desktop.
Save linojon/189670 to your computer and use it in GitHub Desktop.
code snippets used in the SaasRamp screencast
# Some handy code snippets are used in the SaasRamp screencast (http://www.vaporbase.com/postings/SaasRamp_Screencast)
# File: environment.rb
config.gem 'activemerchant', :lib => 'active_merchant'
config.gem 'money'
config.gem 'state_machine'
config.gem 'lockfile'
config.active_record.observers = :subscription_observer
# File: environments/test.rb
config.gem "rspec", :lib => false, :version => ">= 1.2.0"
config.gem "rspec-rails", :lib => false, :version => ">= 1.2.0"
config.gem "mocha"
# File: spec/spec_helper.rb
require File.dirname(__FILE__) + '/../vendor/plugins/saasramp/spec/acts_as_subscriber_spec'
# File: spec/controllers/users_controller_spec.rb
Subscription.any_instance.stubs(:plan).returns(SubscriptionPlan.default_plan)
# File: features/support/env.rb
# global subscription plans fixtures
# see http://wiki.github.com/aslakhellesoy/cucumber/fixtures
# and http://wiki.github.com/aslakhellesoy/cucumber/hooks
raw = File.read( RAILS_ROOT + '/db/subscription_plans.yml' )
data = YAML.load(raw)[RAILS_ENV].symbolize_keys
data[:plans].each {|params| SubscriptionPlan.create( params ) }
at_exit do
SubscriptionPlan.destroy_all
end
# alternative to save_and_open_page, see vaporbase...
def show_me
# remove: \ # ? & + = %2
name = response.request.request_uri.gsub('&','-').gsub(/[\/\#\?&\+\=(%2)]/,'-') +
"-#{Time.now.to_i}-#{rand(1_000_000)}"
File.open(RAILS_ROOT + "/public/cucumber/#{name}.html", "w"){ |f| f.puts response.body }
system "open -a Firefox.app http://localhost:3000/cucumber/#{name}.html"
end
# File: features/support/paths.rb
when /my profile/
edit_user_path(:current)
when /my subscription/
subscription_path(:current)
when /my plan/
edit_subscription_path(:current)
when /my credit card/
credit_card_subscription_path(:current)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment