Commit bd78788b authored by mafolz's avatar mafolz
Browse files

inital commit

parents
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /
FactoryGirl.define do
sequence :nickname do |n|
"#{n}hacker"
end
factory :hacker do
nickname { generate(:nickname) }
email { Faker::Internet.email }
password {'test1234'}
end
end
FactoryGirl.define do
factory :redemption do
points { [1,10,50,150].shuffle.first}
association :hacker, :factory => :hacker
association :user, :factory => :hacker
association :reward, :factory => :reward
end
end
FactoryGirl.define do
factory :reward do
points {[10,20,50,150].shuffle.first}
title {Faker::Lorem.word }
description {Faker::Lorem.sentence }
end
end
require 'spec_helper'
describe Cancel do
context 'validations' do
it 'should not allow Hacker as subject' do
cancellation = Cancel.new(:subject_type => 'Hacker')
cancellation.should_not be_valid
cancellation.errors[:subject_type].should be_present
end
it 'should allow Redemption as subject' do
cancellation = Cancel.new(:subject_type => 'Redemption')
cancellation.should be_valid
cancellation.errors[:subject_type].should be_blank
end
it 'should allow Earning as subject' do
cancellation = Cancel.new(:subject_type => 'Earning')
cancellation.should be_valid
cancellation.errors[:subject_type].should be_blank
end
end # validations
end
require 'spec_helper'
describe Earning do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe Hacker do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe Quest do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe Redemption do
let(:negative_points_redemption) do
FactoryGirl.build(:redemption, {
:points => - 50
})
end
let(:redemption) do
Redemption.new
end
context 'associations' do
it 'should have a user which is instance of hacker' do
redemption.build_user.should be_kind_of(Hacker)
end
end # associations
context 'validations' do
it 'should not allow negative points' do
negative_points_redemption.should_not be_valid
negative_points_redemption.errors[:points].should be_present
end
end # validations
end
require 'spec_helper'
describe Reward do
pending "add some examples to (or delete) #{__FILE__}"
end
# 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'
require 'factory_girl_rails'
require 'ffaker'
# 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 }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
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
# 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
# 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 = false
# 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"
end
ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
Supports Markdown
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