Advertisement
Guest User

Untitled

a guest
Oct 13th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. context 'with event_type is available create event' do
  2. let(:event_type) { EventType.where( name: 'visit_site').first }
  3. assert_difference 'Event.count' do
  4. Event.fire_event(event_type, @sponge,{})
  5. end
  6. end
  7.  
  8. RSpec.configure do |config|
  9. ...
  10. config.include AssertDifference
  11. end
  12.  
  13. it 'event count should change' do
  14. assert_difference 'Event.count' do
  15. ...
  16. end
  17. end
  18.  
  19. context 'with event_type is available create event' do
  20. let(:event_type) { EventType.where( name: 'visit_site').first }
  21.  
  22. it "changes event counter" do
  23. expect { Event.fire_event(event_type, @sponge,{}) }.to change { Event.count }
  24. end
  25. end # with event_type is available create event
  26.  
  27. RSpec.describe "UsersSignups", type: :request do
  28. describe "signing up with invalid information" do
  29. it "should not work and should go back to the signup form" do
  30. get signup_path
  31. expect do
  32. post users_path, user: {
  33. first_name: "",
  34. last_name: "miki",
  35. email: "user@triculi",
  36. password: "buajaja",
  37. password_confirmation: "juababa"
  38. }
  39. end.to_not change{ User.count }
  40. expect(response).to render_template(:new)
  41. expect(response.body).to include('errors')
  42. end
  43. end
  44.  
  45. describe "signing up with valid information" do
  46. it "should work and should redirect to user's show view" do
  47. get signup_path
  48. expect do
  49. post_via_redirect users_path, user: {
  50. first_name: "Julito",
  51. last_name: "Triculi",
  52. email: "triculito@mail.com",
  53. password: "worldtriculi",
  54. password_confirmation: "worldtriculi"
  55. }
  56. end.to change{ User.count }.from(0).to(1)
  57. expect(response).to render_template(:show)
  58. expect(flash[:success]).to_not be(nil)
  59. end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement