Commit d7a715de by Dang Khac Luan

init project

parents
---
BUNDLE_BIN: bin
--color
--require spec_helper
--format documentation
-r turnip/rspec
\ No newline at end of file
source 'https://rubygems.org'
gem 'rspec'
# gem 'rspec-rails'
gem 'capybara'
gem 'capybara-webkit'
gem 'launchy'
# Turnip is a Gherkin extension for RSpec. It allows you to write tests in Gherkin and run them through your RSpec environment. Basically you can write cucumber features in RSpec.
gem 'turnip'
gem 'poltergeist'
gem 'spring'
GEM
remote: https://rubygems.org/
specs:
addressable (2.3.8)
capybara (2.5.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-webkit (1.7.0)
capybara (>= 2.3.0, < 2.6.0)
json
cliver (0.3.2)
diff-lcs (1.2.5)
gherkin (2.12.2)
multi_json (~> 1.3)
json (1.8.3)
launchy (2.4.3)
addressable (~> 2.3)
mime-types (2.6.1)
mini_portile (0.6.2)
multi_json (1.11.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
poltergeist (1.6.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
spring (1.3.6)
turnip (1.3.1)
gherkin (>= 2.5)
rspec (>= 2.14.0, < 4.0)
websocket-driver (0.6.2)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
capybara
capybara-webkit
launchy
poltergeist
rspec
spring
turnip
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('bundler', 'bundler')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'erubis' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('erubis', 'erubis')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'htmldiff' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('diff-lcs', 'htmldiff')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'launchy' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('launchy', 'launchy')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'ldiff' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('diff-lcs', 'ldiff')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'nokogiri' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('nokogiri', 'nokogiri')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rackup' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('rack', 'rackup')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rails' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('railties', 'rails')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('rake', 'rake')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'spring' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('spring', 'spring')
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'thor' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('thor', 'thor')
Feature: api
Background:
Given access 'http://staging.arubaito-ex.jp'
Scenario: visit /premium/api/jobs jobs api
When visit "/premium/api/jobs"
Then response code is "200"
Then response includes "塚田農場"
Then response includes '"brand_id":101'
Then response includes '"company_id":10'
Then response includes '"job_images":[{"url":"https://premiumjob-develop.s3-ap-northeast-1.amazonaws.com/job_images'
Scenario: visit /premium/api/jobs?page=1 jobs api page
When visit "/premium/api/jobs?page=1"
Then response code is "200"
Then response includes "塚田農場"
Scenario: visit /premium/api/job_approval_ids job_approval_ids api page
When visit "/premium/api/job_approval_ids?ids=10000,10001,10002"
Then response code is "200"
Then response includes "10001,10002"
\ No newline at end of file
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
# files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, consider making
# a separate helper file that requires the additional dependencies and performs
# the additional setup, and require it from the spec files that actually need
# it.
#
# The `.rspec` file also contains a few flags that are not defaults but that
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'capybara/dsl'
require 'capybara/webkit'
require 'capybara/poltergeist'
require 'turnip'
require 'turnip/rspec'
require 'turnip/capybara'
Dir.glob("spec/steps/**/*.rb") { |f| load f, true }
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_than(2).and_smaller_than(4).description
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = true
end
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
# get run.
config.filter_run :focus
config.run_all_when_everything_filtered = true
# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options. We recommend
# you configure your source control system to ignore this file.
config.example_status_persistence_file_path = "spec/examples.txt"
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
config.disable_monkey_patching!
# This setting enables warnings. It's recommended, but in some cases may
# be too noisy due to issues in dependencies.
config.warnings = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
=end
end
########## E2E ######################
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app,
phantomjs: 'phantomjs',
:js_errors => false,
:debug => false,
:phantomjs_options => ['--load-images=no', '--disk-cache=true'],
:timeout => 360
)
end
Capybara.run_server = false
# Capybara.default_driver = :poltergeist
# Capybara.javascript_driver = :poltergeist
Capybara.ignore_hidden_elements = false
Capybara.default_driver = :webkit
Capybara.javascript_driver = :webkit
Capybara::Webkit.configure do |config|
config.allow_unknown_urls
config.allow_url("http://staging.arubaito-ex.jp/premium/api/jobs?page=1")
end
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 eq(code.to_i)
end
step 'response includes :string' do |string|
expect(page).to have_content(string)
end
step 'response includes :input_type input with name :input_name' do |input_type, input_name|
expect(page).to have_selector("input[type='#{input_type}'][name='#{input_name}']")
end
step 'response includes select tag :name with option :option selected' do |name, option|
expect(page).to have_selector("select[name='#{name}'] > option[selected='selected'][value='#{option}']")
end
step 'response includes checkbox :name input with :value checked' do |name, value|
expect(page).to have_selector("input[name='#{name}'][type='checkbox'][checked='checked'][value='#{value}']")
end
step 'response includes radio :name input with :value checked' do |name, value|
expect(page).to have_selector("input[name='#{name}'][type='radio'][checked='checked'][value='#{value}']")
end
step 'response includes text input tag :name with :value filled in' do |name, value|
expect(page).to have_selector("input[name='#{name}'][type='text'][value='#{value}']")
end
step 'title includes :string' do |string|
expect(page.title).to have_content(string)
end
step 'h1 includes :string' do |string|
expect(page.find('h1')).to have_content(string)
end
step 'h2 includes :string' do |string|
expect(page.find('h2')).to have_content(string)
end
step 'have link :link' do |link|
page.should have_selector("a[href='#{link}']")
end
step 'not have link :link' do |link|
page.should_not have_selector('a[href="'+ link +'"]')
end
step 'not find link :link' do |link|
expect(find("a[href='#{link}']", visible: false)).to_not be_visible
end
step 'not have link :link' do |link|
page.should_not have_selector('a[href="'+ link +'"]')
end
step 'check cookies :cookies' do |cookies|
expect(page.driver.cookies["history"].value).to eq(cookies.to_s)
end
step 'click link :link' do |link|
first(:xpath, "//a[@href='" + link + "']").click
end
step 'fill in :field_name with :value' do |field_name, value|
fill_in field_name, with: value, :match => :first
end
step 'click button by class :class_name' do |class_name|
first(:xpath, '//input[@class="' + class_name + '"]').click
end
step 'click button by id :id_name' do |id_name|
first(:xpath, '//input[@id="' + id_name + '"]').click
end
step 'click input button by text :text' do |text|
first(:xpath, '//input[@value="' + text + '"]').click
end
step 'not have input button with value :value' do |value|
expect(page).not_to have_selector(:xpath, '//input[@value="' + value + '"]')
end
step 'checked with id :id' do |id|
find("##{id}").set(true)
end
step 'choose with id :id' do |id|
choose("#{id}")
end
step 'checked with name :name and value :value' do |name, value|
find("input[name='#{name}'][value='#{value}']").set(true)
end
step 'selected :field with :value' do |field, value|
select(value, from: field)
end
step 'fill in email' do
fill_in 'user[email]', with: "abc#{Time.now.to_i}@gmail.com"
end
step 'log in with email :email and password :password' do |email, password|
visit new_user_session_path
fill_in 'user_email', with: email
fill_in 'user_password', with: password
click_button 'ログインする'
end
step 'use smartphone' do
page.driver.headers = { "User-Agent" => "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53" }
end
step 'have :tag with id :id' do |tag, id|
page.should have_selector("#{tag}##{id}")
end
step 'have :tag with class :klass' do |tag, klass|
page.should have_selector("#{tag}.#{klass}")
end
step ':tag with id :id is enabled' do |tag, id|
expect(page).not_to have_selector("#{tag}##{id}[disabled='disabled'], #{tag}##{id}[disabled='true']")
end
step ':tag with id :id is disabled' do |tag, id|
expect(page).to have_selector("#{tag}##{id}[disabled='disabled'], #{tag}##{id}[disabled='true']")
end
step 'click on link with text :text' do |text|
page.driver.browser.switch_to_window(page.driver.browser.window_handles.last)
sleep 5
first(:xpath, "//a[./text()='#{text}']").click
end
step 'trigger event click on link with id :id' do |id|
first(:xpath, '//a[@id="' + id + '"]').trigger('click')
sleep 10
end
step 'current url is :url' do |url|
expect("#{URI.parse(current_url).request_uri}").to eq url
end
step 'current url is :url' do |url|
expect("#{URI.parse(current_url).request_uri}").to eq url
end
step 'current url is :url' do |url|
expect("#{URI.parse(current_url).request_uri}").to eq url
end
step 'current host is :host' do |host|
expect("#{URI.parse(current_url).host}").to eq host
end
step 'current host is capybara app host' do
expect(current_host).to eq Capybara.app_host
end
step 'save screenshot' do
sleep 5
page.save_screenshot("#{Rails.root}/tmp/capybara/capybara-#{Time.now.to_i}.png", :full => true)
end
step 'upload avatar to :locator from :path' do |locator, path|
attach_file(locator, path)
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