Skip to content

@linojon /gist:189670
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.