add testing device images and a lot more, before bootstrap:themed
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
FactoryGirl.define do
|
||||
factory :list do
|
||||
association :table
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
FactoryGirl.define do
|
||||
factory :supplier do
|
||||
sequence(:name){|i| "Supplier #{i}"}
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
FactoryGirl.define do
|
||||
factory :table do
|
||||
number 22
|
||||
association :supplier
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
require 'spec_helper'
|
||||
|
||||
|
||||
describe List do
|
||||
before :each do
|
||||
@list = create :list
|
||||
end
|
||||
describe :as_json do
|
||||
it 'should include _id in as_json serialization' do
|
||||
@list.as_json.keys.map(&:to_sym).should include :_id
|
||||
end
|
||||
it 'should include table_number in as_json serialization' do
|
||||
@list.as_json.keys.should include :table_number
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,65 @@
|
||||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'rspec/autorun'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
#Dir[Rails.root.join("spec/factories/**/*.rb")].each {|f| require f }
|
||||
|
||||
I18n.locale = :en
|
||||
Devise.stretches = 1
|
||||
Capybara.default_driver = :selenium
|
||||
RSpec.configure do |config|
|
||||
# == Mock Framework
|
||||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
config.mock_with :rspec
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.include EndWithMatcher
|
||||
#config.use_transactional_fixtures = true
|
||||
config.infer_base_class_for_anonymous_controllers = true
|
||||
config.render_views = true
|
||||
|
||||
# Use color in STDOUT
|
||||
config.color_enabled = true
|
||||
|
||||
# Use color not only in STDOUT but also in pagers and files
|
||||
config.tty = true
|
||||
|
||||
# Use the specified formatter
|
||||
config.formatter = :documentation # :progress, :html, :textmate
|
||||
|
||||
# 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
|
||||
|
||||
config.before :each do
|
||||
CouchPotato.couchrest_database.recreate!
|
||||
end
|
||||
config.before :each, type: :request do
|
||||
#Capybara.current_driver = :selenium
|
||||
#sign_in_user_through_request
|
||||
end
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
# rspec-rails.
|
||||
#config.infer_base_class_for_anonymous_controllers = true
|
||||
def sign_in_user_through_request
|
||||
visit "/users/sign_in"
|
||||
fill_in 'user[email]', with: @user.email
|
||||
fill_in 'user[password]', with: @user.password
|
||||
click_on 'Inloggen'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,43 @@
|
||||
module EndWithMatcher
|
||||
class EndWith
|
||||
def initialize(expected)
|
||||
@expected = expected
|
||||
end
|
||||
|
||||
def matches?(target)
|
||||
@target = target
|
||||
@target =~ /#{@expected}$/
|
||||
end
|
||||
|
||||
def failure_message
|
||||
"expected <#{to_string(@target)}> to " +
|
||||
"end with <#{to_string(@expected)}>"
|
||||
end
|
||||
|
||||
def negative_failure_message
|
||||
"expected <#{to_string(@target)}> not to " +
|
||||
"end with <#{to_string(@expected)}>"
|
||||
end
|
||||
|
||||
# Returns string representation of an object.
|
||||
def to_string(value)
|
||||
# indicate a nil
|
||||
if value.nil?
|
||||
'nil'
|
||||
end
|
||||
|
||||
# join arrays
|
||||
if value.class == Array
|
||||
return value.join(", ")
|
||||
end
|
||||
|
||||
# otherwise return to_s() instead of inspect()
|
||||
return value.to_s
|
||||
end
|
||||
end
|
||||
|
||||
# Actual matcher that is exposed.
|
||||
def end_with(expected)
|
||||
EndWith.new(expected)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user