Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## The post inside test_site_creation works, but not in the TestingDSL... !?
- require "#{File.dirname(__FILE__)}/../test_helper"
- class NewUserSiteCreationTest < ActionController::IntegrationTest
- fixtures :users, :roles, :roles_users
- def test_site_creation
- self.host = "demo.example.com"
- new_session do |u|
- u.signup(:login => 'quire')
- u.activate
- u.login(:login => 'quire', :password => 'test')
- u.create_page(:title => 'home', :template_id => 1, :theme_id => 2)
- end
- end
- private
- module TestingDSL
- include TestMethods
- attr_reader :activation_email
- def signup(options)
- raise "needs a login" unless options[:login]
- options[:email] = options[:login] + "@example.com" unless options[:email]
- options[:domain] = options[:login] + ".example.com" unless options[:domain]
- options[:name] = options[:login] unless options[:name]
- options[:last_name] = "Smith" unless options[:last_name]
- options[:password] = 'test' unless options[:password]
- options[:password_confirmation] = options[:password] unless options[:password_confirmation]
- assert_increases User, :count do
- !! post users_path, :user => options
- assert_redirected_to login_url
- end
- assert_not_nil @activation_email = ActionMailer::Base.deliveries.last
- end
- #...
- end
- def new_session
- open_session do |sess|
- sess.extend(TestingDSL)
- yield sess if block_given?
- end
- end
- end
- ##Error message
- 1) Error:
- test_site_creation(NewUserSiteCreationTest):
- ArgumentError: wrong number of arguments (0 for 1)
- /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:241:in `accept'
- /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:241:in `process'
- /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:157:in `post'
- ./test/integration/new_user_site_creation_test.rb:32:in `signup'
- /home/daniel/dev/config/../lib/authenticated_test_helper.rb:38:in `assert_difference'
- ./test/integration/../test_helper.rb:13:in `assert_increases'
- ./test/integration/new_user_site_creation_test.rb:31:in `signup'
- ./test/integration/new_user_site_creation_test.rb:9:in `test_site_creation'
- ./test/integration/new_user_site_creation_test.rb:62:in `new_session'
- /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:529:in `open_session'
- ./test/integration/new_user_site_creation_test.rb:60:in `new_session'
- ./test/integration/new_user_site_creation_test.rb:8:in `test_site_creation'
- /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:453:in `run'
Add Comment
Please, Sign In to add comment