Commit 27832df8 by tady

add turnip

parent ca366ef6
--color --color
-r turnip/rspec
...@@ -96,6 +96,7 @@ group :test do ...@@ -96,6 +96,7 @@ group :test do
gem 'launchy' gem 'launchy'
gem 'poltergeist' gem 'poltergeist'
gem 'coveralls', :require => false gem 'coveralls', :require => false
gem 'turnip'
end end
# tree structure # tree structure
......
...@@ -40,7 +40,7 @@ GEM ...@@ -40,7 +40,7 @@ GEM
arel (4.0.2) arel (4.0.2)
ast (1.1.0) ast (1.1.0)
atomic (1.1.15) atomic (1.1.15)
aws-sdk (1.35.0) aws-sdk (1.36.0)
json (~> 1.4) json (~> 1.4)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
uuidtools (~> 2.1) uuidtools (~> 2.1)
...@@ -124,6 +124,8 @@ GEM ...@@ -124,6 +124,8 @@ GEM
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
ffi (1.9.3) ffi (1.9.3)
formatador (0.2.4) formatador (0.2.4)
gherkin (2.12.2)
multi_json (~> 1.3)
github-markdown (0.6.4) github-markdown (0.6.4)
gmail_xoauth (0.4.1) gmail_xoauth (0.4.1)
oauth (>= 0.3.6) oauth (>= 0.3.6)
...@@ -133,7 +135,7 @@ GEM ...@@ -133,7 +135,7 @@ GEM
lumberjack (~> 1.0) lumberjack (~> 1.0)
pry (>= 0.9.12) pry (>= 0.9.12)
thor (>= 0.18.1) thor (>= 0.18.1)
guard-rspec (4.2.7) guard-rspec (4.2.8)
guard (~> 2.1) guard (~> 2.1)
rspec (>= 2.14, < 4.0) rspec (>= 2.14, < 4.0)
guard-rubocop (1.0.2) guard-rubocop (1.0.2)
...@@ -160,7 +162,7 @@ GEM ...@@ -160,7 +162,7 @@ GEM
launchy (2.4.2) launchy (2.4.2)
addressable (~> 2.3) addressable (~> 2.3)
libv8 (3.16.14.3) libv8 (3.16.14.3)
listen (2.6.2) listen (2.7.0)
celluloid (>= 0.15.2) celluloid (>= 0.15.2)
celluloid-io (>= 0.15.0) celluloid-io (>= 0.15.0)
rb-fsevent (>= 0.9.3) rb-fsevent (>= 0.9.3)
...@@ -182,7 +184,7 @@ GEM ...@@ -182,7 +184,7 @@ GEM
mime-types (1.25.1) mime-types (1.25.1)
mini_portile (0.5.2) mini_portile (0.5.2)
minitest (4.7.5) minitest (4.7.5)
multi_json (1.8.4) multi_json (1.9.0)
multi_xml (0.5.5) multi_xml (0.5.5)
multipart-post (2.0.0) multipart-post (2.0.0)
mysql2 (0.3.15) mysql2 (0.3.15)
...@@ -191,7 +193,7 @@ GEM ...@@ -191,7 +193,7 @@ GEM
net-scp (1.1.2) net-scp (1.1.2)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (2.8.0) net-ssh (2.8.0)
newrelic_rpm (3.7.2.195) newrelic_rpm (3.7.3.199)
nio4r (1.0.0) nio4r (1.0.0)
nokogiri (1.6.1) nokogiri (1.6.1)
mini_portile (~> 0.5.0) mini_portile (~> 0.5.0)
...@@ -218,7 +220,7 @@ GEM ...@@ -218,7 +220,7 @@ GEM
paper_trail (3.0.0) paper_trail (3.0.0)
activerecord (>= 3.0, < 5.0) activerecord (>= 3.0, < 5.0)
activesupport (>= 3.0, < 5.0) activesupport (>= 3.0, < 5.0)
parser (2.1.6) parser (2.1.7)
ast (~> 1.1) ast (~> 1.1)
slop (~> 3.4, >= 3.4.5) slop (~> 3.4, >= 3.4.5)
poltergeist (1.5.0) poltergeist (1.5.0)
...@@ -287,7 +289,8 @@ GEM ...@@ -287,7 +289,8 @@ GEM
parser (~> 2.1.3) parser (~> 2.1.3)
powerpack (~> 0.0.6) powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0) rainbow (>= 1.99.1, < 3.0)
sass (3.2.14) sass (3.3.0)
rake
sass-rails (4.0.1) sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10) sass (>= 3.1.10)
...@@ -333,6 +336,9 @@ GEM ...@@ -333,6 +336,9 @@ GEM
treetop (1.4.15) treetop (1.4.15)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
turnip (1.2.1)
gherkin (>= 2.5)
rspec (>= 2.0, < 4.0)
tzinfo (0.3.38) tzinfo (0.3.38)
uglifier (2.4.0) uglifier (2.4.0)
execjs (>= 0.3.0) execjs (>= 0.3.0)
...@@ -396,5 +402,6 @@ DEPENDENCIES ...@@ -396,5 +402,6 @@ DEPENDENCIES
settingslogic settingslogic
therubyracer therubyracer
thin thin
turnip
uglifier uglifier
validates_email_format_of validates_email_format_of
...@@ -11,4 +11,8 @@ guard :rspec do ...@@ -11,4 +11,8 @@ guard :rspec do
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m| watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
%W(spec/routing/#{m[1]}_routing_spec.rb spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb spec/requests/#{m[1]}_spec.rb) %W(spec/routing/#{m[1]}_routing_spec.rb spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb spec/requests/#{m[1]}_spec.rb)
end end
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end end
Feature: ログインしていないユーザーのアクセス
Scenario: TOPページにアクセス
When visit '/'
Then response code is '200'
Scenario: TOP以外にアクセス
When visit '/posts'
Then response code is '999'
...@@ -8,9 +8,9 @@ describe 'Request via js', js: true do ...@@ -8,9 +8,9 @@ describe 'Request via js', js: true do
let(:user) { FactoryGirl.create(:login_user_1) } let(:user) { FactoryGirl.create(:login_user_1) }
before do before do
@post1 = Post.create title: 'ruby rspec', body: 'This is first espec test: ruby', author_id: user.id @post1 = Post.create title: 'ruby rspec', body: 'This is first espec test: ruby', author_id: user.id, updated_at: Time.new(2014, 1, 1, 12, 0, 0)
@post2 = Post.create title: 'php test', body: 'PHP is very easy', author_id: user.id @post2 = Post.create title: 'php test', body: 'PHP is very easy', author_id: user.id, updated_at: Time.new(2014, 1, 1, 13, 0, 0)
@post3 = Post.create title: 'java java...', body: 'Java is not ruby...', author_id: user.id @post3 = Post.create title: 'java java...', body: 'Java is not ruby...', author_id: user.id, updated_at: Time.new(2014, 1, 1, 14, 0, 0)
end end
before :each do before :each do
...@@ -20,13 +20,13 @@ describe 'Request via js', js: true do ...@@ -20,13 +20,13 @@ describe 'Request via js', js: true do
it 'show first post' do it 'show first post' do
page.save_screenshot(Rails.root.join('tmp', 'screenshots', "a-#{Time.now.strftime('%Y-%m-%d %H%M%S')}.png")) page.save_screenshot(Rails.root.join('tmp', 'screenshots', "a-#{Time.now.strftime('%Y-%m-%d %H%M%S')}.png"))
expect(page.find('.panel-title a').text).to include('ruby rspec') expect(page.find('.panel-title a').text).to include('java java')
end end
it 'click post and show' do it 'click post and show' do
find('.post-list:nth-child(3)').click find('.post-list:nth-child(3)').click
page.save_screenshot(Rails.root.join('tmp', 'screenshots', "b-#{Time.now.strftime('%Y-%m-%d %H%M%S')}.png")) page.save_screenshot(Rails.root.join('tmp', 'screenshots', "b-#{Time.now.strftime('%Y-%m-%d %H%M%S')}.png"))
expect(page.find('.panel-title a').text).to include('java java...') expect(page.find('.panel-title a').text).to include('ruby rspec')
end end
after :each do after :each do
......
...@@ -31,6 +31,12 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } ...@@ -31,6 +31,12 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# If you are not using ActiveRecord, you can remove this line. # If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
# Setting for turnip.
Dir.glob("spec/steps/**/*steps.rb") { |f| load f, true }
require 'turnip'
require 'turnip/capybara'
RSpec.configure do |config| RSpec.configure do |config|
# ## Mock Framework # ## Mock Framework
# #
......
step 'access :site' do |site|
Capybara.app_host = site
end
step 'visit :path' do |path|
visit path
end
step 'response code is :code' do |code|
expect(page.status_code.to_i).to eq(code.to_i)
end
step 'response include :string' do |string|
expect(page).to have_content(string)
end
step 'h1 include :string' do |string|
expect(page.find('h1')).to have_content(string)
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment