Make all spec work, switch to thoughtbot way of integration testing
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# Put your acceptance spec helpers inside spec/acceptance/support
|
||||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
||||
@@ -1,48 +0,0 @@
|
||||
require 'acceptance/acceptance_helper'
|
||||
|
||||
feature 'Supplier main board spec.rb', %q{
|
||||
In order to manage active lists and orders
|
||||
As a confirmed supplier
|
||||
I want to have control over lists and orders from the main activity panel
|
||||
} do
|
||||
background do
|
||||
CouchPotato.couchrest_database.recreate!
|
||||
create_confirmed_supplier 'supplier@qwaiter.com'
|
||||
create_user 'user@qwaiter.com'
|
||||
end
|
||||
|
||||
def create_active_list(options = {})
|
||||
@table = create :table, supplier: @supplier
|
||||
@list = create :list, supplier: @supplier, table: @table, user_ids: [@user.id]
|
||||
end
|
||||
|
||||
context "having javascript activated", js: true do
|
||||
|
||||
scenario 'the active list should be present and contained in row having its id' do
|
||||
create_active_list
|
||||
login_supplier_as 'supplier@qwaiter.com'
|
||||
visit '/supplier'
|
||||
page.should have_selector "#list-row-#{@list.id}"
|
||||
end
|
||||
|
||||
scenario 'an order is added to the list before visiting the page' do
|
||||
create_active_list
|
||||
login_supplier_as 'supplier@qwaiter.com'
|
||||
product = create :product, supplier: @supplier
|
||||
sleep 0.1
|
||||
@list.place_order @user, {product.id => 369}
|
||||
visit '/supplier'
|
||||
page.should have_selector ".of-list-#{@list.id}"
|
||||
end
|
||||
|
||||
scenario 'an order is added to the list after visiting the page' do
|
||||
create_active_list
|
||||
login_supplier_as 'supplier@qwaiter.com'
|
||||
product = create :product, supplier: @supplier
|
||||
visit '/supplier'
|
||||
@list.place_order @user, {product.id => 369}
|
||||
sleep 0.1
|
||||
page.should have_selector ".of-list-#{@list.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,35 +0,0 @@
|
||||
module HelperMethods
|
||||
# Put helper methods you need to be available in all acceptance specs here.
|
||||
|
||||
def create_user(email, password='secret')
|
||||
@user = User.find_by_email(email) || FactoryGirl.create(:user, email: email, password: password)
|
||||
end
|
||||
def create_supplier(email, password='secret')
|
||||
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password)
|
||||
end
|
||||
|
||||
def create_confirmed_supplier(email, password='secret')
|
||||
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, :confirmed, email: email, password: password)
|
||||
@supplier.confirm! unless @supplier.confirmed?
|
||||
end
|
||||
|
||||
def login_user_as(email)
|
||||
visit "/users/sign_in"
|
||||
fill_in "user_email", with: email
|
||||
fill_in "user_password", with: "secret"
|
||||
submit_form
|
||||
end
|
||||
|
||||
def login_supplier_as(email)
|
||||
visit "/suppliers/sign_in"
|
||||
fill_in "supplier_email", with: email
|
||||
fill_in "supplier_password", with: "secret"
|
||||
submit_form
|
||||
end
|
||||
|
||||
def submit_form
|
||||
find("[type=submit]").click
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configuration.include HelperMethods, :type => :acceptance
|
||||
@@ -1,9 +0,0 @@
|
||||
module NavigationHelpers
|
||||
# Put helper methods related to the paths in your application here.
|
||||
|
||||
def homepage
|
||||
"/"
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configuration.include NavigationHelpers, :type => :acceptance
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
require 'acceptance/acceptance_helper'
|
||||
|
||||
require 'spec_helper'
|
||||
feature 'Supplier product categories spec', %q{
|
||||
In order to manage product categories
|
||||
As a confirmed supplier
|
||||
@@ -32,6 +32,7 @@ RSpec.configure do |config|
|
||||
config.include FactoryAttributesFor
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.include EndWithMatcher
|
||||
config.include Features::BasicHelpers, type: :feature
|
||||
#config.use_transactional_fixtures = true
|
||||
config.infer_base_class_for_anonymous_controllers = true
|
||||
config.render_views = true
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
module Features
|
||||
module BasicHelpers
|
||||
# Put helper methods you need to be available in all acceptance specs here.
|
||||
|
||||
def create_user(email, password='secret')
|
||||
@user = User.find_by_email(email) || FactoryGirl.create(:user, email: email, password: password)
|
||||
end
|
||||
def create_supplier(email, password='secret')
|
||||
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password)
|
||||
end
|
||||
|
||||
def create_confirmed_supplier(email, password='secret')
|
||||
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, :confirmed, email: email, password: password)
|
||||
@supplier.confirm! unless @supplier.confirmed?
|
||||
end
|
||||
|
||||
def login_user_as(email)
|
||||
visit "/users/sign_in"
|
||||
fill_in "user_email", with: email
|
||||
fill_in "user_password", with: "secret"
|
||||
submit_form
|
||||
end
|
||||
|
||||
def login_supplier_as(email)
|
||||
visit "/suppliers/sign_in"
|
||||
fill_in "supplier_email", with: email
|
||||
fill_in "supplier_password", with: "secret"
|
||||
submit_form
|
||||
end
|
||||
|
||||
def submit_form
|
||||
find("[type=submit]").click
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user