-
-
Save hindenbug/8595368 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'lotus/router' | |
| Application = Rack::Builder.new do | |
| router = Lotus::Router.new do | |
| get '/', to: ->(env) { [200, {}, ['Hello World']] }, as: :root | |
| end | |
| run router | |
| end.to_app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source 'https://rubygems.org' | |
| gem 'lotus-router' | |
| group :test do | |
| gem 'rspec' | |
| gem 'capybara' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # spec/features/home_page_spec.rb | |
| require 'spec_helper' | |
| feature 'Home page' do | |
| it 'successfully visits the home page' do | |
| visit '/' | |
| expect(page.body).to match('Hello World') | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rspec/core/rake_task' | |
| RSpec::Core::RakeTask.new(:spec) | |
| task default: :spec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # spec/routing_spec.rb | |
| require 'spec_helper' | |
| describe Application do | |
| let(:application) { Application } | |
| it 'recognizes route path' do | |
| expect(application.path(:root)).to eq('/') | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| mkdir -p spec/features | |
| mv spec_helper.rb spec | |
| mv routing_spec.rb spec | |
| mv home_page_spec.rb spec/features | |
| bundle | |
| # This script will self destruct in 3, 2, 1.. poof! | |
| rm -- "$0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # spec/spec_helper.rb | |
| $:.unshift __dir__ + '/..' | |
| require 'rubygems' | |
| require 'bundler' | |
| Bundler.require(:default, :test) | |
| require 'rspec' | |
| require 'capybara/rspec' | |
| require 'application' | |
| module RSpec | |
| module FeatureExampleGroup | |
| def self.included(group) | |
| group.metadata[:type] = :feature | |
| Capybara.app = Application | |
| end | |
| end | |
| end | |
| RSpec.configure do |c| | |
| def c.escaped_path(*parts) | |
| Regexp.compile(parts.join('[\\\/]') + '[\\\/]') | |
| end | |
| c.color = true | |
| c.include RSpec::FeatureExampleGroup, type: :feature, example_group: { | |
| file_path: c.escaped_path(%w[spec features]) | |
| } | |
| c.include Capybara::DSL, type: :feature | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment