Use factory girl (poorly?)

This commit is contained in:
Andrew Tomaka 2014-02-14 16:40:15 -05:00
parent f2dbc7f981
commit 9d2afc431a
3 changed files with 15 additions and 7 deletions

5
spec/factories/pastes.rb Normal file
View file

@ -0,0 +1,5 @@
FactoryGirl.define do
factory :paste do
content "Test"
end
end

View file

@ -1,19 +1,22 @@
require 'spec_helper' require 'spec_helper'
feature 'Creates new paste' do feature 'Creates new paste' do
let(:paste) { FactoryGirl.create(:paste) }
let(:blank_content) { " " }
before { visit new_paste_path }
subject { page }
scenario 'with valid content' do scenario 'with valid content' do
visit new_paste_path fill_in 'Content', with: paste.content
fill_in 'Content', with: 'Test'
click_button 'Paste it!' click_button 'Paste it!'
expect(page).to have_content('Your paste has been added') should have_content('Your paste has been added')
end end
scenario 'with blank content' do scenario 'with blank content' do
visit new_paste_path fill_in 'Content', with: blank_content
fill_in 'Content', with: ' '
click_button 'Paste it!' click_button 'Paste it!'
expect(page).to have_content('There was an error submitting your form') should have_content('There was an error submitting your form')
end end
end end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe Paste do describe Paste do
before do before do
@paste = Paste.new(content: "Test") @paste = FactoryGirl.create(:paste)
end end
subject { @paste } subject { @paste }