Skip to content

Commit

Permalink
Create simple action for displaying all contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
davydovanton committed Mar 20, 2017
1 parent 41fc1b1 commit 12cb5e7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/web/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
#
# Example:
# get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
get '/contributors', to: 'contributors#index'
8 changes: 8 additions & 0 deletions apps/web/controllers/contributors/index.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Web::Controllers::Contributors
class Index
include Web::Action

def call(params)
end
end
end
Empty file.
5 changes: 5 additions & 0 deletions apps/web/views/contributors/index.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Web::Views::Contributors
class Index
include Web::View
end
end
11 changes: 11 additions & 0 deletions spec/web/controllers/contributors/index_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require_relative '../../../../apps/web/controllers/contributors/index'

RSpec.describe Web::Controllers::Contributors::Index do
let(:action) { described_class.new }
let(:params) { Hash[] }

it 'is successful' do
response = action.call(params)
expect(response[0]).to eq 200
end
end
15 changes: 15 additions & 0 deletions spec/web/views/contributors/index_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require_relative '../../../../apps/web/views/contributors/index'

RSpec.describe Web::Views::Contributors::Index do
let(:exposures) { Hash[foo: 'bar'] }
let(:template) { Hanami::View::Template.new('apps/web/templates/contributors/index.html.slim') }
let(:view) { described_class.new(template, exposures) }
let(:rendered) { view.render }

it 'exposes #foo' do
pending 'This is an auto-generated test. Edit it and add your own tests.'

# Example
expect(view.foo).to eq exposures.fetch(:foo)
end
end

0 comments on commit 12cb5e7

Please sign in to comment.