Skip to content

Commit

Permalink
introduce turnip
Browse files Browse the repository at this point in the history
  • Loading branch information
muratayusuke committed Feb 8, 2015
1 parent eb58b5e commit df00ce8
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--color
--require spec_helper
--require rails_helper
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gem 'haml-rails'
gem 'pocket-ruby', '~> 0.0.5'
gem 'dotenv-rails'
gem 'bitters', group: :assets
gem 'mtracker'

group :development, :test do
gem 'byebug'
Expand All @@ -23,4 +24,8 @@ group :development, :test do
gem 'rubocop'
gem 'rails_best_practices'
gem 'bullet'
gem 'rspec-rails'
gem 'capybara'
gem 'capybara-webkit'
gem 'turnip'
end
43 changes: 43 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ GEM
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
capybara (2.4.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-webkit (1.4.1)
capybara (>= 2.3.0, < 2.5.0)
json
celluloid (0.16.0)
timers (~> 4.0.0)
code_analyzer (0.4.5)
Expand All @@ -74,6 +83,7 @@ GEM
columnize (0.9.0)
debug_inspector (0.0.2)
debugger-linecache (1.2.0)
diff-lcs (1.2.5)
dotenv (1.0.2)
dotenv-rails (1.0.2)
dotenv (= 1.0.2)
Expand All @@ -85,6 +95,8 @@ GEM
faraday (>= 0.7.4, < 0.10)
ffi (1.9.6)
formatador (0.2.5)
gherkin (2.12.2)
multi_json (~> 1.3)
globalid (0.3.0)
activesupport (>= 4.1.0)
guard (2.11.1)
Expand Down Expand Up @@ -136,6 +148,7 @@ GEM
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1)
mtracker (0.1.0)
multi_json (1.10.1)
multipart-post (1.2.0)
nenv (0.2.0)
Expand Down Expand Up @@ -201,6 +214,26 @@ GEM
rdoc (4.2.0)
json (~> 1.4)
require_all (1.3.2)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-rails (3.1.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
rubocop (0.28.0)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.7, < 3.0)
Expand Down Expand Up @@ -240,6 +273,9 @@ GEM
hitimes
turbolinks (2.5.3)
coffee-rails
turnip (1.2.4)
gherkin (>= 2.5)
rspec (>= 2.14.0, < 4.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.0)
Expand All @@ -251,6 +287,8 @@ GEM
binding_of_caller (>= 0.7.2)
railties (~> 4.0)
sprockets-rails (>= 2.0, < 4.0)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby
Expand All @@ -259,19 +297,24 @@ DEPENDENCIES
bitters
bullet
byebug
capybara
capybara-webkit
coffee-rails (~> 4.1.0)
dotenv-rails
guard-rails
haml-rails
jbuilder (~> 2.0)
jquery-rails
mtracker
pocket-ruby (~> 0.0.5)
rails (= 4.2.0)
rails_best_practices
rspec-rails
rubocop
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
sqlite3
turbolinks
turnip
uglifier (>= 1.3.0)
web-console (~> 2.0)
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks

task default: [:rubocop]
task default: [:turnip, :rubocop]
4 changes: 4 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ class Application < Rails::Application

# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true

# bourbon/bitters
config.assets.paths << `bundle show bourbon`.strip + '/app/assets/stylesheets/'
config.assets.paths << `bundle show bitters`.strip + '/app/assets/stylesheets/'
end
end
9 changes: 9 additions & 0 deletions lib/tasks/turnip.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
unless Rails.env == 'production' || Rails.env == 'staging'
require 'rspec/core/rake_task'

desc 'Run turnip acceptance tests'
RSpec::Core::RakeTask.new(:turnip) do |t|
t.pattern = './spec{,/*/**}/*.feature'
t.rspec_opts = ['-r turnip/rspec']
end
end
4 changes: 4 additions & 0 deletions spec/features/home.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Feature: Top page
Scenario: Show top page without login
When I visit "top" page
Then It should succeed
50 changes: 50 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!

# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.maintain_test_schema!

RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true

# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, :type => :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!
end
7 changes: 7 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'capybara'
require 'capybara/webkit'
require 'turnip'
require 'turnip/capybara'
require 'mtracker'

Dir.glob('spec/**/*steps.rb') { |f| load f, true }
23 changes: 23 additions & 0 deletions spec/steps/web_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
step 'I visit :name page' do |name|
page.driver.browser.authorize 'best10admin', 'best10admin2014'

if name == 'top'
url = '/'
else
url = name
end

visit url
end

step 'It should succeed' do
expect(page.status_code).to eq(200)
end

step 'I should see :text' do |text|
expect(page).to have_content(text)
end

step 'I should see link for :href' do |href|
expect(page).to have_link(href: href)
end

0 comments on commit df00ce8

Please sign in to comment.