daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest May 17th, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## spec_helper.rb
  2.  
  3.   config.global_fixtures = :users, :hubs, :pages, :layouts, :divs, :roles, :rolemaps, :event_categories
  4.  
  5.   module GlobalSpecHelper
  6.     def get_user
  7.       @user = users(:tesla)
  8.     end
  9.  
  10.     def do_login
  11.       get_user
  12.       session[:user_id] = @user.id
  13.     end
  14.   end
  15.  
  16. ## account_spec.rb
  17.  
  18. module AccountSpecHelper
  19.   include GlobalSpecHelper
  20. ...
  21. end
  22.  
  23. describe "Account#create_default_groups" do
  24.   include AccountSpecHelper
  25.  
  26.   before(:each) do
  27.     get_user
  28.   end
  29.  
  30.   it "should ... whatever" do
  31.     ...
  32.   end
  33. end
  34.  
  35. ## output when all specs are run (from TextMate... it's a little more verbose than the command line)
  36.  
  37. Account#create_default_groups
  38. create new groups
  39.  
  40. You have a nil object when you didn't expect it!
  41. You might have expected an instance of ActiveRecord::Base.
  42. The error occurred while evaluating nil.[]
  43.  
  44. trunk/spec/spec_helper.rb:41 :in `get_user'
  45. trunk/spec/models/account_spec.rb:228
  46.  
  47. 39  module GlobalSpecHelper
  48. 40    def get_user
  49. 41      @user = users(:tesla)
  50. 42    end
  51. 43  
  52. 44# gem install syntax to get syntax highlighting
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top