Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. FactoryGirl.define do
  2. factory :user do
  3. email "mail@mail.com"
  4. password "foobarrr"
  5. password_confirmation "foobarrr"
  6. end
  7.  
  8. factory :poll do
  9. topic "What your name?"
  10.  
  11. trait :vote_option1 do
  12. association :vote_option, title: "Dima"
  13. end
  14.  
  15. trait :vote_option2 do
  16. association :vote_option, title: "Sasha"
  17. end
  18. end
  19. end
  20.  
  21. require 'rails_helper'
  22.  
  23.  
  24. RSpec.describe Poll, type: :model do
  25. let(:user) { FactoryGirl.create(:user) }
  26.  
  27. #subject { @poll }
  28.  
  29. #it { should respond_to(:topic) }
  30. #it {should be_valid}
  31.  
  32.  
  33. describe "wrong information" do
  34. describe "less than or equal 1 vote option" do
  35. before do
  36. FactoryGirl.create(:poll, :vote_option1)
  37.  
  38. end
  39.  
  40. it { should_not be_valid }
  41. end
  42. end
  43.  
  44. end
  45.  
  46. ...........................
  47. group :test do
  48. gem 'capybara', '~> 2.4.4'
  49. gem 'selenium-webdriver', '~> 2.46.2'
  50. gem 'factory_girl_rails', '~> 4.5.0'
  51. end
  52.  
  53. FactoryGirl.define do
  54. factory :user do
  55. email "mail@mail.com"
  56. password "foobarrr"
  57. password_confirmation "foobarrr"
  58. end
  59.  
  60. factory :poll do
  61. topic "What your name?"
  62.  
  63. trait :vote_option1 do
  64. association :vote_option, title: "Dima"
  65. end
  66.  
  67. trait :vote_option2 do
  68. association :vote_option, title: "Sasha"
  69. end
  70.  
  71. factory :poll_with_vote1, traits: [:vote_option1]
  72. factory :poll_with_vote2, traits: [:vote_option2]
  73. end
  74. end
  75.  
  76. describe "wrong information" do
  77. describe "less than or equal 1 vote option" do
  78. before do
  79. FactoryGirl.create(:poll_with_vote1)
  80. end
  81.  
  82. it { should_not be_valid }
  83. end
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement