Guest User

Untitled

a guest
Feb 28th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. ## The post inside test_site_creation works, but not in the TestingDSL... !?
  2. require "#{File.dirname(__FILE__)}/../test_helper"
  3. class NewUserSiteCreationTest < ActionController::IntegrationTest
  4. fixtures :users, :roles, :roles_users
  5.  
  6. def test_site_creation
  7. self.host = "demo.example.com"
  8.  
  9. new_session do |u|
  10. u.signup(:login => 'quire')
  11.  
  12. u.activate
  13. u.login(:login => 'quire', :password => 'test')
  14. u.create_page(:title => 'home', :template_id => 1, :theme_id => 2)
  15. end
  16. end
  17.  
  18. private
  19. module TestingDSL
  20. include TestMethods
  21. attr_reader :activation_email
  22. def signup(options)
  23. raise "needs a login" unless options[:login]
  24. options[:email] = options[:login] + "@example.com" unless options[:email]
  25. options[:domain] = options[:login] + ".example.com" unless options[:domain]
  26. options[:name] = options[:login] unless options[:name]
  27.  
  28. options[:last_name] = "Smith" unless options[:last_name]
  29. options[:password] = 'test' unless options[:password]
  30. options[:password_confirmation] = options[:password] unless options[:password_confirmation]
  31.  
  32. assert_increases User, :count do
  33. !! post users_path, :user => options
  34. assert_redirected_to login_url
  35. end
  36.  
  37. assert_not_nil @activation_email = ActionMailer::Base.deliveries.last
  38. end
  39.  
  40. #...
  41. end
  42.  
  43. def new_session
  44. open_session do |sess|
  45. sess.extend(TestingDSL)
  46. yield sess if block_given?
  47. end
  48. end
  49. end
  50.  
  51. ##Error message
  52. 1) Error:
  53. test_site_creation(NewUserSiteCreationTest):
  54. ArgumentError: wrong number of arguments (0 for 1)
  55. /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:241:in `accept'
  56. /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:241:in `process'
  57. /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:157:in `post'
  58. ./test/integration/new_user_site_creation_test.rb:32:in `signup'
  59. /home/daniel/dev/config/../lib/authenticated_test_helper.rb:38:in `assert_difference'
  60. ./test/integration/../test_helper.rb:13:in `assert_increases'
  61. ./test/integration/new_user_site_creation_test.rb:31:in `signup'
  62. ./test/integration/new_user_site_creation_test.rb:9:in `test_site_creation'
  63. ./test/integration/new_user_site_creation_test.rb:62:in `new_session'
  64. /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:529:in `open_session'
  65. ./test/integration/new_user_site_creation_test.rb:60:in `new_session'
  66. ./test/integration/new_user_site_creation_test.rb:8:in `test_site_creation'
  67. /home/daniel/dev/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:453:in `run'
Add Comment
Please, Sign In to add comment