diff --git a/spec/factories/pastes.rb b/spec/factories/pastes.rb new file mode 100644 index 0000000..dbb069f --- /dev/null +++ b/spec/factories/pastes.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :paste do + content "Test" + end +end diff --git a/spec/features/creates_new_paste_spec.rb b/spec/features/creates_new_paste_spec.rb index c2962e9..4951bce 100644 --- a/spec/features/creates_new_paste_spec.rb +++ b/spec/features/creates_new_paste_spec.rb @@ -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 diff --git a/spec/models/paste_spec.rb b/spec/models/paste_spec.rb index 0ab08e4..82b96d7 100644 --- a/spec/models/paste_spec.rb +++ b/spec/models/paste_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Paste do before do - @paste = Paste.new(content: "Test") + @paste = FactoryGirl.create(:paste) end subject { @paste }