Use factory girl (poorly?)
This commit is contained in:
parent
f2dbc7f981
commit
9d2afc431a
3 changed files with 15 additions and 7 deletions
5
spec/factories/pastes.rb
Normal file
5
spec/factories/pastes.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
FactoryGirl.define do
|
||||
factory :paste do
|
||||
content "Test"
|
||||
end
|
||||
end
|
|
@ -1,19 +1,22 @@
|
|||
require 'spec_helper'
|
||||
|
||||
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
|
||||
visit new_paste_path
|
||||
fill_in 'Content', with: 'Test'
|
||||
fill_in 'Content', with: paste.content
|
||||
click_button 'Paste it!'
|
||||
|
||||
expect(page).to have_content('Your paste has been added')
|
||||
should have_content('Your paste has been added')
|
||||
end
|
||||
|
||||
scenario 'with blank content' do
|
||||
visit new_paste_path
|
||||
fill_in 'Content', with: ' '
|
||||
fill_in 'Content', with: blank_content
|
||||
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
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe Paste do
|
||||
before do
|
||||
@paste = Paste.new(content: "Test")
|
||||
@paste = FactoryGirl.create(:paste)
|
||||
end
|
||||
|
||||
subject { @paste }
|
||||
|
|
Loading…
Reference in a new issue