Skip to content

Commit

Permalink
Merge pull request hanami#71 from gangster/build
Browse files Browse the repository at this point in the history
Fixes 'Displaying Validation Errors' spec example in the Getting Started Guide
Trung Lê committed Jul 4, 2015
2 parents 77b553d + 6366448 commit 45af944
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions source/guides/getting-started.md
Original file line number Diff line number Diff line change
@@ -761,7 +761,7 @@ module Web::Controllers::Books

def call(params)
@book = BookRepository.create(Book.new(params[:book]))

redirect_to '/books'
end
end
@@ -888,17 +888,26 @@ First, we expect a list of errors to be included in the page when `params` conta
require 'spec_helper'
require_relative '../../../../apps/web/views/books/new'

let(:params) { Lotus::Action::Params.new({}) }
let(:exposures) { Hash[params: params] }
let(:template) { Lotus::View::Template.new('apps/web/templates/books/index.html.erb') }
let(:view) { Web::Views::Books::New.new(template, exposures) }
let(:rendered) { view.render }
class NewBookParams < Lotus::Action::Params
param :book do
param :title, presence: true
param :author, presence: true
end
end

describe Web::Views::Books::New do
let(:params) { NewBookParams.new({}) }
let(:exposures) { Hash[params: params] }
let(:template) { Lotus::View::Template.new('apps/web/templates/books/new.html.erb') }
let(:view) { Web::Views::Books::New.new(template, exposures) }
let(:rendered) { view.render }

it 'displays list of errors when params contains errors' do
params.valid? # trigger validations
it 'displays list of errors when params contains errors' do
params.valid? # trigger validations

rendered.must_include('There was a problem with your submission')
rendered.must_include('title is required')
rendered.must_include('There was a problem with your submission')
rendered.must_include('title is required')
end
end
```

0 comments on commit 45af944

Please sign in to comment.