add fixtures
This commit is contained in:
parent
98f19485e8
commit
cd563dd337
11 changed files with 97 additions and 6 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -21,4 +21,5 @@ test/dummy/db/*.sqlite3
|
|||
test/dummy/db/*.sqlite3-journal
|
||||
test/dummy/log/*.log
|
||||
test/dummy/tmp/
|
||||
test/dummy/.sass-cache
|
||||
test/dummy/.sass-cache
|
||||
test/dummy/test/fixtures/*.y*ml
|
||||
|
|
|
|||
9
Gemfile
9
Gemfile
|
|
@ -11,15 +11,17 @@ gemspec
|
|||
# your gem to rubygems.org.
|
||||
|
||||
group :development do
|
||||
# code style
|
||||
gem "rubocop", "0.32.0"
|
||||
|
||||
# Debugging
|
||||
# debugging
|
||||
gem "pry"
|
||||
gem "pry-debundle"
|
||||
gem "pry-byebug"
|
||||
end
|
||||
|
||||
group :test do
|
||||
# rspec
|
||||
gem "rspec-instafail", "0.2.6", require: false
|
||||
gem "fuubar", "2.0.0"
|
||||
gem "nyan-cat-formatter", require: false
|
||||
|
|
@ -30,12 +32,17 @@ group :test do
|
|||
gem "codeclimate-test-reporter", require: false
|
||||
|
||||
# test helpers
|
||||
gem "fixture_builder", "0.4.1"
|
||||
gem "factory_girl_rails", "4.5.0"
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
# rspec
|
||||
gem "rspec-rails", "3.2.3"
|
||||
|
||||
# GUID generation
|
||||
gem "uuid", "2.3.7"
|
||||
|
||||
# test database
|
||||
gem "sqlite3"
|
||||
end
|
||||
|
|
|
|||
10
Gemfile.lock
10
Gemfile.lock
|
|
@ -61,6 +61,9 @@ GEM
|
|||
factory_girl_rails (4.5.0)
|
||||
factory_girl (~> 4.5.0)
|
||||
railties (>= 3.0.0)
|
||||
fixture_builder (0.4.1)
|
||||
activerecord (>= 2)
|
||||
activesupport (>= 2)
|
||||
fuubar (2.0.0)
|
||||
rspec (~> 3.0)
|
||||
ruby-progressbar (~> 1.4)
|
||||
|
|
@ -70,6 +73,8 @@ GEM
|
|||
json (1.8.3)
|
||||
loofah (2.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
macaddr (1.7.1)
|
||||
systemu (~> 2.6.2)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
method_source (0.8.2)
|
||||
|
|
@ -166,10 +171,13 @@ GEM
|
|||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.10)
|
||||
systemu (2.6.5)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
uuid (2.3.7)
|
||||
macaddr (~> 1.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
|
@ -178,6 +186,7 @@ DEPENDENCIES
|
|||
codeclimate-test-reporter
|
||||
diaspora_federation!
|
||||
factory_girl_rails (= 4.5.0)
|
||||
fixture_builder (= 0.4.1)
|
||||
fuubar (= 2.0.0)
|
||||
nyan-cat-formatter
|
||||
pry
|
||||
|
|
@ -189,6 +198,7 @@ DEPENDENCIES
|
|||
simplecov (= 0.10.0)
|
||||
simplecov-rcov (= 0.2.3)
|
||||
sqlite3
|
||||
uuid (= 2.3.7)
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.3
|
||||
|
|
|
|||
|
|
@ -23,14 +23,12 @@ module DiasporaFederation
|
|||
|
||||
describe "#legacy_webfinger" do
|
||||
it "succeeds when the person exists" do
|
||||
skip
|
||||
post :legacy_webfinger, "q" => "bob@diaspora.pod"
|
||||
post :legacy_webfinger, "q" => "alice@localhost:3000"
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "succeeds with 'acct:' in the query when the person exists" do
|
||||
skip
|
||||
post :legacy_webfinger, "q" => "acct:bob@diaspora.pod"
|
||||
post :legacy_webfinger, "q" => "acct:alice@localhost:3000"
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
|
|
|
|||
16
spec/factories.rb
Normal file
16
spec/factories.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
require "factory_girl"
|
||||
|
||||
def r_str
|
||||
SecureRandom.hex(3)
|
||||
end
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :person do
|
||||
sequence(:diaspora_handle) {|n| "person-#{n}-#{r_str}@localhost:3000" }
|
||||
url "http://localhost:3000/"
|
||||
serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export
|
||||
after(:create) do |u|
|
||||
u.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -3,6 +3,9 @@ require File.join(File.dirname(__FILE__), "..", "test", "dummy", "config", "envi
|
|||
|
||||
require "rspec/rails"
|
||||
|
||||
# load factory girl factories
|
||||
require "factories"
|
||||
|
||||
require "simplecov"
|
||||
require "simplecov-rcov"
|
||||
SimpleCov.formatters = [
|
||||
|
|
@ -16,6 +19,16 @@ end
|
|||
require "codeclimate-test-reporter"
|
||||
CodeClimate::TestReporter.start
|
||||
|
||||
# Force fixture rebuild
|
||||
FileUtils.rm_f(Rails.root.join("tmp", "fixture_builder.yml"))
|
||||
|
||||
# Requires supporting files with custom matchers and macros, etc,
|
||||
# in ./support/ and its subdirectories.
|
||||
fixture_builder_file = "#{File.dirname(__FILE__)}/support/fixture_builder.rb"
|
||||
support_files = Dir["#{File.dirname(__FILE__)}/support/**/*.rb"] - [fixture_builder_file]
|
||||
support_files.each {|f| require f }
|
||||
require fixture_builder_file
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.infer_spec_type_from_file_location!
|
||||
|
||||
|
|
@ -25,6 +38,9 @@ RSpec.configure do |config|
|
|||
expect_config.syntax = :expect
|
||||
end
|
||||
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
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
|
||||
|
|
|
|||
16
spec/support/fixture_builder.rb
Normal file
16
spec/support/fixture_builder.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
require "fixture_builder"
|
||||
|
||||
FixtureBuilder.configure do |fbuilder|
|
||||
# rebuild fixtures automatically when these files change:
|
||||
fbuilder.files_to_check += Dir[
|
||||
"lib/**/*.rb",
|
||||
"spec/factories.rb",
|
||||
"spec/support/fixture_builder.rb",
|
||||
"test/dummy/app/models/*.rb"
|
||||
]
|
||||
|
||||
# now declare objects
|
||||
fbuilder.factory do
|
||||
FactoryGirl.create(:person, diaspora_handle: "alice@localhost:3000")
|
||||
end
|
||||
end
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
class Person < ActiveRecord::Base
|
||||
include ::Diaspora::Guid
|
||||
|
||||
def salmon_url
|
||||
"#{url}receive/users/#{guid}"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,5 +24,8 @@ module Dummy
|
|||
|
||||
# Do not swallow errors in after_commit/after_rollback callbacks.
|
||||
config.active_record.raise_in_transactional_callbacks = true
|
||||
|
||||
# autoload files from test/dummy/lib
|
||||
config.autoload_once_paths += %W(#{config.root}/lib)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
22
test/dummy/lib/diaspora/guid.rb
Normal file
22
test/dummy/lib/diaspora/guid.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
# from diaspora for testing
|
||||
|
||||
module Diaspora
|
||||
module Guid
|
||||
# Creates a before_create callback which calls #set_guid
|
||||
def self.included(model)
|
||||
model.class_eval do
|
||||
after_initialize :set_guid
|
||||
validates :guid, uniqueness: true
|
||||
end
|
||||
end
|
||||
|
||||
# @return [String] The model's guid.
|
||||
def set_guid
|
||||
self.guid = UUID.generate :compact if guid.blank?
|
||||
end
|
||||
end
|
||||
end
|
||||
0
test/dummy/test/fixtures/,keep
vendored
Normal file
0
test/dummy/test/fixtures/,keep
vendored
Normal file
Loading…
Reference in a new issue