public
Last active

code snippets used in the SaasRamp screencast

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
# 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)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.