source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
hzamani/acts_as_relation
https://github.com/hzamani/acts_as_relation
spec/dummy/config/environments/test.rb
Ruby
mit
181
master
1,112
Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suit...
github
hzamani/acts_as_relation
https://github.com/hzamani/acts_as_relation
spec/dummy/config/environments/development.rb
Ruby
mit
181
master
910
Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web serv...
github
hzamani/acts_as_relation
https://github.com/hzamani/acts_as_relation
spec/dummy/db/schema.rb
Ruby
mit
181
master
1,628
# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative sou...
github
hzamani/acts_as_relation
https://github.com/hzamani/acts_as_relation
spec/dummy/db/migrate/002_create_products.rb
Ruby
mit
181
master
238
class CreateProducts < ActiveRecord::Migration def change create_table :products, as_relation_superclass: 'producible' do |t| t.string :name t.float :price t.integer :store_id t.timestamps end end end
github
hzamani/acts_as_relation
https://github.com/hzamani/acts_as_relation
spec/dummy/app/models/product.rb
Ruby
mit
181
master
240
class Product < ActiveRecord::Base acts_as_superclass as: 'producible' belongs_to :store validates_presence_of :name, :price def parent_method "#{name} - #{price}" end def dummy_raise_method(obj) obj.dummy end end
github
jimweirich/re
https://github.com/jimweirich/re
Rakefile
Ruby
mit
181
master
1,078
#!/usr/bin/env ruby" require 'rake/clean' require 'rake/testtask' require 'rdoc/task' require './lib/re' task :default => :test Rake::TestTask.new(:test) do |t| t.warning = true t.verbose = false t.test_files = FileList['test/*_test.rb'] end namespace "release" do task :new => [ :readme, :check_non...
github
jimweirich/re
https://github.com/jimweirich/re
rakelib/readme.rake
Ruby
mit
181
master
1,748
require './lib/re' class RDocToTextile def initialize @blanks = 0 end def cleanup(line) line.sub(/^# ?/, '').sub(/ +$/, '') end def emit(line="") @outstream.puts line end def flush_blanks @blanks.times do emit("\n") end @blanks = 0 end def queue_blank_line @blanks += 1 e...
github
jimweirich/re
https://github.com/jimweirich/re
rakelib/tags.rake
Ruby
mit
181
master
415
#!/usr/bin/env ruby module Tags PROG = ENV['TAGS'] || 'ctags' RUBY_FILES = FileList['**/*.rb'] RUBY_FILES.include('**/*.rake') end namespace "tags" do desc "Generate an Emacs TAGS file" task :emacs => Tags::RUBY_FILES do puts "Making Emacs TAGS file" verbose(false) do sh "#{Tags::PROG} -e #{Ta...
github
jimweirich/re
https://github.com/jimweirich/re
rakelib/publish.rake
Ruby
mit
181
master
635
# Optional publish task for Rake begin require 'rake/contrib/sshpublisher' require 'rake/contrib/rubyforgepublisher' publisher = Rake::CompositePublisher.new publisher.add Rake::RubyForgePublisher.new('re-lib', 'jimweirich') namespace "publish" do desc "Publish the Documentation to RubyForge." ...
github
jimweirich/re
https://github.com/jimweirich/re
rakelib/gem.rake
Ruby
mit
181
master
1,054
require 'rubygems' require './lib/re' PKG_FILES = FileList[ '[A-Z]*', 'rakefile/**/*', 'lib/*.rb', 'test/*.rb' ] if ! defined?(Gem) puts "Package Target requires RubyGEMs" else require 'rubygems/package_task' SPEC = Gem::Specification.new do |s| s.name = 're' s.version = Re::VERSION s.summ...
github
jimweirich/re
https://github.com/jimweirich/re
rakelib/rdoc.rake
Ruby
mit
181
master
210
Rake::RDocTask.new do |rd| rd.main = "lib/re.rb" rd.rdoc_files = FileList["lib/re.rb", "MIT-LICENSE"] rd.options = [ '--title', 'Re - Regular Expressions Library', '--main', 'lib/re.rb' ] end
github
jimweirich/re
https://github.com/jimweirich/re
bench/date_bench.rb
Ruby
mit
181
master
1,547
#!/usr/bin/ruby -wKU require 're' include Re def date_rexp delim_re = re.any("- /.") century_prefix_re = re("19") | re("20") under_ten_re = re("0") + re.any("1-9") ten_to_twelve_re = re("1") + re.any("012") ten_and_under_thirty_re = re.any("12") + re.any("0-9") thir...
github
jimweirich/re
https://github.com/jimweirich/re
lib/re.rb
Ruby
mit
181
master
23,363
#!/usr/bin/ruby -wKU # # = Regular Expression Construction # # Complex regular expressions are hard to construct and even harder to # read. The Re library allows users to construct complex regular # expressions from simpler expressions. For example, consider the # following regular expression that will parse dates: #...
github
jimweirich/re
https://github.com/jimweirich/re
test/re_test.rb
Ruby
mit
181
master
13,134
#!/usr/bin/env ruby # Copyright 2009 by Jim Weirich (jim.weirich@gmail.com). # All rights reserved. # # Re is provided under the MIT open source license (see MIT-LICENSE) require 'test/unit' require 're' class ReResultTeset < Test::Unit::TestCase include Re extend Re PATTERN = re.any("a-z").one_or_more.captur...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
Gemfile
Ruby
mit
181
master
236
source 'https://rubygems.org' # Specify your gem's dependencies in evil-proxy.gemspec gemspec gem 'activesupport' gem 'colorize' gem 'pry-byebug' gem 'webrick' group :test do gem 'rest-client', '~> 2.0' gem 'rspec', '~> 3.6' end
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
evil-proxy.gemspec
Ruby
mit
181
master
895
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'evil-proxy/version' Gem::Specification.new do |spec| spec.name = "evil-proxy" spec.version = EvilProxy::VERSION spec.authors = ["Theo"] spec.email = ["bbtfrr@...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
spec/spec_helper.rb
Ruby
mit
181
master
204
require 'rest-client' require 'json' require 'evil-proxy' require 'evil-proxy/async' Dir['./spec/support/**/*.rb'].sort.each { |f| require f } RSpec.configure do |config| config.order = 'random' end
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
spec/support/http_client.rb
Ruby
mit
181
master
1,205
class HTTPClient class << self def get(url, proxy) RestClient::Request.execute(method: :get, url: url, proxy: proxy, verify_ssl: OpenSSL::SSL::VERIFY_NONE) end def head(url, proxy) RestClient::Request.execute(method: :head, url: url, proxy: proxy, ...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
spec/evil-proxy/httpproxy_spec.rb
Ruby
mit
181
master
1,392
require 'spec_helper' describe EvilProxy::HTTPProxyServer do before :all do @server = EvilProxy::MITMProxyServer.new Port: 3128, Quiet: true @server.start end after :all do @server.shutdown end let(:proxy) { 'http://127.0.0.1:3128' } it 'proxy GET requests' do content = HTTPClient.get('h...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
lib/evil-proxy/async.rb
Ruby
mit
181
master
306
EvilProxy::HTTPProxyServer.class_eval do attr_reader :thread alias_method :original_start, :start alias_method :original_shutdown, :shutdown def start @thread = Thread.new do self.original_start end end def shutdown @thread.exit end def join @thread.join end end
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
lib/evil-proxy/agentproxy.rb
Ruby
mit
181
master
1,498
require 'webrick' require 'webrick/https' require 'webrick/httpproxy' require 'openssl' class EvilProxy::AgentProxyServer < EvilProxy::HTTPProxyServer def initialize_callbacks config @mitm_server = config[:MITMProxyServer] end def fire key, *args @mitm_server.fire key, *args, self end def perform_...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
lib/evil-proxy/httpproxy.rb
Ruby
mit
181
master
3,025
require 'webrick' require 'webrick/httpproxy' class EvilProxy::HTTPProxyServer < WEBrick::HTTPProxyServer attr_reader :callbacks DEFAULT_CALLBACKS = Hash.new SUPPORTED_METHODS = %w(GET HEAD POST PUT PATCH DELETE OPTIONS CONNECT).freeze def initialize config = {}, default = WEBrick::Config::HTTP initiali...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
lib/evil-proxy/selenium.rb
Ruby
mit
181
master
587
require 'evil-proxy/async' EvilProxy::HTTPProxyServer.class_eval do def selenium_proxy *protocols require 'selenium-webdriver' unless defined?(Selenium) protocols.push :http if protocols.empty? unless (protocols - [:http, :ssl, :ftp]).empty? raise "Invalid protocol specified. Must be one of: :htt...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
lib/evil-proxy/quickcert.rb
Ruby
mit
181
master
11,544
require 'openssl' # QuickCert from http://segment7.net/projects/ruby/QuickCert/ # QuickCert allows you to quickly and easily create SSL # certificates. It uses a simple configuration file to generate # self-signed client and server certificates. # # QuickCert is a compilation of NAKAMURA Hiroshi's post to # ruby-talk ...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
lib/evil-proxy/store.rb
Ruby
mit
181
master
1,461
require 'yaml' EvilProxy::HTTPProxyServer.class_eval do attr_reader :store when_initialize do clean_store end when_shutdown do dump_store end before_response do |req, res| @store << [ req, res ] if match_store_filter req, res end def store_filter &block @store_filter = block end ...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
lib/evil-proxy/mitmproxy.rb
Ruby
mit
181
master
3,733
require 'evil-proxy/httpproxy' require 'evil-proxy/agentproxy' require 'evil-proxy/quickcert' class EvilProxy::MITMProxyServer < EvilProxy::HTTPProxyServer def initialize config super @mitm_pattern = config[:MITMPattern] @mitm_servers = {} @mitm_port = 4433 end def ca return @ca if @ca ...
github
bbtfr/evil-proxy
https://github.com/bbtfr/evil-proxy
bin/evil-proxy.rb
Ruby
mit
181
master
602
PROXY.restart do # @mitm_pattern = /partten/ end # PROXY.before_response do |req, res| # puts "#{req.request_method} #{req.request_uri || req.unparsed_uri}".colorize(:blue) # end PROXY.before_response do |req, res| if req.unparsed_uri.start_with? 'http://101.251.217.210' or req.unparsed_uri.start_with? 'http://...
github
nikolalsvk/ordinare
https://github.com/nikolalsvk/ordinare
ordinare.gemspec
Ruby
mit
181
master
702
# coding: utf-8 lib = File.expand_path("../lib/", __FILE__) $:.unshift lib unless $:.include?(lib) require "ordinare/version" Gem::Specification.new do |s| s.name = "ordinare" s.version = Ordinare::VERSION s.licenses = ["MIT"] s.summary = "Sort your gems in Gemfile with ease" s.des...
github
nikolalsvk/ordinare
https://github.com/nikolalsvk/ordinare
lib/ordinare.rb
Ruby
mit
181
master
1,168
require "ordinare/version" require "ordinare/sort" require "ordinare/check" require "optparse" module Ordinare module_function def hi "Ciao, sono Ordinare" end def parse_args path = "Gemfile" overwrite = true version = nil help = nil check = nil OptionParser.new do |opts| o...
github
nikolalsvk/ordinare
https://github.com/nikolalsvk/ordinare
lib/ordinare/sort.rb
Ruby
mit
181
master
2,403
module Ordinare class Sort def self.sort_gemfile(overwrite = true, path = "Gemfile") new(overwrite, path).sort_gemfile end def self.sort_content(path = "Gemfile", content) new(false, path).sort_content(content) end def initialize(overwrite, path) @overwrite = overwrite @r...
github
nikolalsvk/ordinare
https://github.com/nikolalsvk/ordinare
lib/ordinare/check.rb
Ruby
mit
181
master
634
module Ordinare class Check def self.gemfile_sorted?(path = "Gemfile") new(path).gemfile_sorted? end def initialize(path) @path = path end def gemfile_sorted? unless File.file?(@path) abort "No Gemfile found in the current directory, is this a Rails project with Gemfile...
github
nikolalsvk/ordinare
https://github.com/nikolalsvk/ordinare
spec/spec_helper.rb
Ruby
mit
181
master
4,153
require "simplecov" SimpleCov.start require "codecov" SimpleCov.formatter = SimpleCov::Formatter::Codecov require "ordinare" 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 prefe...
github
nikolalsvk/ordinare
https://github.com/nikolalsvk/ordinare
spec/ordinare_spec.rb
Ruby
mit
181
master
3,507
require "spec_helper" describe Ordinare do describe "#hi" do it "says hi in italian" do expect(Ordinare.hi).to eq "Ciao, sono Ordinare" end end describe "#parse_args" do context "path to Gemfile is passed" do context "using -p" do before { ARGV = ["-p spec/fixtures/Gemfile"] } ...
github
nikolalsvk/ordinare
https://github.com/nikolalsvk/ordinare
spec/ordinare/check_spec.rb
Ruby
mit
181
master
775
require "spec_helper" describe Ordinare::Check do describe "#gemfile_sorted?" do context "no Gemfile found" do it "aborts with message" do expect { described_class.gemfile_sorted?("spec/fixtures/no_gemfile") }.to raise_error(SystemExit) end end context "Gemfile is s...
github
nikolalsvk/ordinare
https://github.com/nikolalsvk/ordinare
spec/ordinare/sort_spec.rb
Ruby
mit
181
master
1,299
require "spec_helper" require "fileutils" describe Ordinare::Sort do describe "#sort_gemfile" do context "no Gemfile found" do it "aborts with message" do expect { Ordinare::Sort.sort_gemfile(false, "spec/fixtures/no_gemfile") }.to raise_error(SystemExit) end end co...
github
scirate/scirate
https://github.com/scirate/scirate
Rakefile
Ruby
mit
181
main
272
#!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) SciRate::Application.load_tasks
github
scirate/scirate
https://github.com/scirate/scirate
Guardfile
Ruby
mit
181
main
1,369
# A sample Guardfile # More info at https://github.com/guard/guard#readme guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do watch('config/application.rb') watch('config/environment.rb') watch(%r{^config/environments/.+\.rb$}) watch(%r{^config/initializers/.+\...
github
scirate/scirate
https://github.com/scirate/scirate
config.ru
Ruby
mit
181
main
514
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) class Garbage def initialize(app) @app = app end def call(env) GC.disable v = @app.call(env) GC.enable v end end use Garbage if Rails.env.profile? use Sta...
github
scirate/scirate
https://github.com/scirate/scirate
settings.rb
Ruby
mit
181
main
6,564
module Settings # Definable application-wide settings which can be # overrided by either a local_settings.rb file or values # of ENV (in that order). Intended to separate SciRate # settings (some of which are sensitive) from general Rails # configuration. # An ordered list of the top-level arxiv categories...
github
scirate/scirate
https://github.com/scirate/scirate
Gemfile
Ruby
mit
181
main
2,814
ruby '2.6.9' source 'https://rubygems.org' # Rails gem 'rails', '6.1.0' gem 'bcrypt', '~> 3.1.7' gem 'stripe' gem 'jwt' # Database stuff # gem 'pg' # Postgres support gem 'pg', '~> 1.1' gem 'activerecord-import' # For bulk importing papers gem 'acts_as_votable' # Comment votes (not scites) gem 'unidecoder', '~> 1.1....
github
scirate/scirate
https://github.com/scirate/scirate
deploy.rb
Ruby
mit
181
main
882
#!/usr/bin/env ruby web = 'web.scirate.com' def run(hosts, commands) pids = [] hosts.each do |host| cmd = "ssh scirate@#{host} 'bash -l -e -s' <<'ENDSSH'\n#{commands}\nENDSSH" pids << Process.spawn(cmd) end pids.each do |pid| Process.wait pid end end run [web], <<END source ~/.ruby-stuff || t...
github
scirate/scirate
https://github.com/scirate/scirate
lib/arxiv_import.rb
Ruby
mit
181
main
5,314
require 'data_helpers' module Arxiv # Remove trailing version from an arXiv paper uid def self.strip_version(uid) if m = uid.match(/(.+)v\d+/) m[1] else uid end end end module Arxiv::Import def self.papers(models, opts={}) new_uids = [] updated_uids = [] ActiveRecord::Base....
github
scirate/scirate
https://github.com/scirate/scirate
lib/data_helpers.rb
Ruby
mit
181
main
522
def map_models(key, query) map = {} query.each do |model| map[model.send(key)] = model end map end def map_exists(key, query) map = {} query.pluck(key).each do |val| map[val] = true end map end def later(&b) future do ActiveRecord::Base.connection_pool.with_connection(&b) end end def ...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/legacy_import.rake
Ruby
mit
181
main
2,836
namespace :db do desc "Import data from the old database" task legacy_import: :environment do |t,args| # HACK (Mispy): The "firsts" here are to force the # Rails database reflection to cache the new schema # instead of the old one. This whole thing is a bit # ad hoc and inefficient but that's fine. ...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/arxiv_authorship_update.rake
Ruby
mit
181
main
931
require 'arxivsync' namespace :arxiv do desc "Update authorship for users with author_identifiers" task authorship_update: :environment do time = Time.now.utc User.where("author_identifier <> ''").each do |user| begin $stderr.puts "Updating username #{user.username}" user.update_auth...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/rebuild_counter_caches.rake
Ruby
mit
181
main
1,410
namespace :db do desc "Rebuild counter caches for users and papers" task rebuild_counter_caches: :environment do puts "Counting scites..." rows = ActiveRecord::Base.connection.execute("SELECT papers.uid, count(*) FROM papers JOIN scites ON (scites.paper_uid = papers.uid) GROUP BY papers.uid;") rows.eac...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/arxiv_paper_sync.rake
Ruby
mit
181
main
489
namespace :arxiv do desc "Idempotent master arxiv paper update task" task paper_sync: :environment do last_update = System.pluck(:arxiv_sync_dt).first # only one entry in table named 'system' update_threshold = Time.now.utc.change(min: 0) if last_update < update_threshold puts "Last OAI sync was ...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/fix_authors.rake
Ruby
mit
181
main
1,382
namespace :db do desc "Recreate authors from author_str" task fix_authors: :environment do def parse_fullnames(author_str) depth = 0 no_parens = "" author_str.chars do |ch| case ch when '(' depth += 1 when ')' depth -= 1 else no_pa...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/arxiv_author_sync.rake
Ruby
mit
181
main
513
namespace :arxiv do desc "Idempotent arxiv user authorship sync task" task author_sync: :environment do daily_update = Time.now.utc.change(hour: Settings::ARXIV_UPDATE_HOUR) last_author_update = System.pluck(:arxiv_author_sync_dt).first if last_author_update < daily_update puts "Last author id sy...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/sample_data.rake
Ruby
mit
181
main
1,260
namespace :db do desc "Fill database with sample data" task populate: :environment do Rake::Task['db:reset'].invoke make_users make_papers end end def make_users first = User.create!(name: "Bill Rosgen", email: "rosgen@gmail.com", password: "18511851...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/fix_categories.rake
Ruby
mit
181
main
565
namespace :db do desc "Remove duplicate papers" task dedup_papers: :environment do uids = {} to_delete = [] i = 0 Paper.find_in_batches(batch_size: 10000) do |papers| papers.each do |paper| if uids[paper.uid] # Evil duplicate to_delete << paper.id else ...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/db_dump_feeds.rake
Ruby
mit
181
main
403
namespace :db do desc "Dumps feeds to seeds.rb format" task dump_feeds: :environment do output = "Feed.create([" feeds = [] Feed.all.each_with_index do |feed, i| attrs = [] feed.attributes.each do |key, val| attrs << "#{key}: \"#{val.to_s}\"" end feeds << "{#{attrs.joi...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/dedup_categories.rake
Ruby
mit
181
main
653
namespace :db do desc "Remove duplicate categories" task dedup_categories: :environment do uids = {} to_delete = [] i = 0 Category.find_in_batches(batch_size: 10000) do |cats| cats.each do |cat| uids[cat.paper_uid] ||= {} if uids[cat.paper_uid][cat.position] # Evil ...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/arxiv_feed_import.rake
Ruby
mit
181
main
1,405
require 'nokogiri' require 'open-uri' def make_feed(uid, fullname, parent=nil) feed = Feed.find_or_create_by(uid: uid) feed.source = 'arxiv' if uid == "cs" # HACK (Mispy) feed.fullname = "Computer Science" elsif uid == "physics" feed.fullname = "More Physics" else feed.fullname = fullname end ...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/arxiv_import.rake
Ruby
mit
181
main
324
require 'arxivsync' require 'arxiv_import' namespace :arxiv do desc "Bulk import of scraped arxiv data" task :import, [:savedir] => :environment do |t,args| archive = ArxivSync::XMLArchive.new(args.savedir) archive.read_metadata do |papers| Arxiv::Import.papers(papers, validate: false) end end ...
github
scirate/scirate
https://github.com/scirate/scirate
lib/tasks/arxiv_oai_update.rake
Ruby
mit
181
main
1,041
require 'arxivsync' namespace :arxiv do desc "Update database with recent papers" task oai_update: :environment do time = Time.now.utc last_paper = Paper.order("submit_date desc").first if last_paper.nil? fromdate = Time.now-1.days else fromdate = last_paper.pubdate-1.days end ...
github
scirate/scirate
https://github.com/scirate/scirate
spec/spec_helper.rb
Ruby
mit
181
main
2,619
# Code coverage for Travis require 'coveralls' Coveralls.wear! # OmniAuth test mode require 'omniauth' OmniAuth.config.test_mode = true require 'capybara/rspec' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' Delayed::Worker.delay_jobs = false Settin...
github
scirate/scirate
https://github.com/scirate/scirate
spec/factories.rb
Ruby
mit
181
main
3,054
FactoryGirl.define do factory :feed do sequence(:uid) { |n| "feed.#{n}" } sequence(:fullname) { |n| "Feed #{n}" } sequence(:position) { |n| n } source 'arxiv' last_paper_date { Date.today } end factory :user do sequence(:fullname) { |n| "Person #{n}" } sequence...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/scite_spec.rb
Ruby
mit
181
main
399
# == Schema Information # # Table name: scites # # id :integer not null, primary key # user_id :integer not null # created_at :datetime # updated_at :datetime # paper_uid :text default(""), not null # require 'spec_helper' describe Scite do it { is_expected.to validate...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/subscription_spec.rb
Ruby
mit
181
main
551
# == Schema Information # # Table name: subscriptions # # id :integer not null, primary key # user_id :integer # created_at :datetime not null # updated_at :datetime not null # feed_uid :text default(""), not null # require 'spec_helper' describe Subscription do ...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/comment_spec.rb
Ruby
mit
181
main
4,131
# == Schema Information # # Table name: comments # # id :integer not null, primary key # user_id :integer not null # score :integer default(0), not null # cached_votes_up :integer default(0), not null # cached_votes_down :integer ...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/comment_change_spec.rb
Ruby
mit
181
main
1,152
require 'spec_helper' describe CommentChange do it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:comment) } let(:user) { FactoryGirl.create(:user) } let(:comment) { FactoryGirl.create(:comment) } it "records creation" do change = comment.history.last expect(change.event).to eq(...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/user_spec.rb
Ruby
mit
181
main
5,398
# == Schema Information # # Table name: users # # id :integer not null, primary key # fullname :text # email :text # remember_token :text # created_at :datetime not null # upda...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/auth_link_spec.rb
Ruby
mit
181
main
506
# == Schema Information # # Table name: auth_links # # id :integer not null, primary key # provider :string(255) not null # uid :string(255) not null # oauth_token :string(255) not null # oauth_expires_at :datetime not null # user_id ...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/category_spec.rb
Ruby
mit
181
main
551
# == Schema Information # # Table name: categories # # id :integer not null, primary key # position :integer not null # feed_uid :text not null # paper_uid :text # crosslist_date :datetime default(2014-01-16 20:06:20 UTC), not null # require 'spec...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/author_spec.rb
Ruby
mit
181
main
903
# == Schema Information # # Table name: authors # # id :integer not null, primary key # position :integer not null # fullname :text not null # searchterm :text not null # paper_uid :text # require 'spec_helper' describe Author do it { is_expected.to valida...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/feed_spec.rb
Ruby
mit
181
main
1,217
# == Schema Information # # Table name: feeds # # id :integer not null, primary key # uid :text not null # source :text not null # fullname :text not null # position :integer default(0), not nu...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/comment_report_spec.rb
Ruby
mit
181
main
462
# == Schema Information # # Table name: comment_reports # # id :integer not null, primary key # user_id :integer # comment_id :integer # created_at :datetime not null # updated_at :datetime not null # require 'spec_helper' describe CommentReport do it { is_expected.to belong...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/paper_spec.rb
Ruby
mit
181
main
3,843
# == Schema Information # # Table name: papers # # id :integer not null, primary key # uid :text not null # submitter :text # title :text not null # abstract :text not null # author_comments :text # msc_class :text...
github
scirate/scirate
https://github.com/scirate/scirate
spec/models/authorship_spec.rb
Ruby
mit
181
main
396
# == Schema Information # # Table name: authorships # # id :integer not null, primary key # user_id :integer not null # paper_uid :text not null # created_at :datetime # updated_at :datetime # require 'spec_helper' describe Authorship do it { is_expected.to validate_pr...
github
scirate/scirate
https://github.com/scirate/scirate
spec/support/utilities.rb
Ruby
mit
181
main
2,681
require 'capybara/rspec' RSpec::Matchers.define :have_title do |title| match do |page| page.body.should have_selector('title', text: full_title(title)) end end RSpec::Matchers.define :have_heading do |heading| match do |page| Capybara.string(page.body).has_selector?('h1', text: heading) end end RSpec...
github
scirate/scirate
https://github.com/scirate/scirate
spec/mailers/user_mailer_spec.rb
Ruby
mit
181
main
2,840
require "spec_helper" describe UserMailer do subject { mail } describe 'signup confirmation email' do let(:user) { FactoryGirl.create(:user, confirmation_token: "some_token") } let(:mail) { UserMailer.signup_confirmation(user) } it 'renders the subject' do expect(mail.subject).to eq('Welcome to...
github
scirate/scirate
https://github.com/scirate/scirate
spec/controllers/papers_controller_spec.rb
Ruby
mit
181
main
759
require 'spec_helper' describe PapersController do let!(:paper) { FactoryGirl.create(:paper) } let!(:user) { FactoryGirl.create(:user) } before { become user } describe 'GET show' do before { get :show, params: { paper_uid: paper.uid } } specify do expect(assigns(:paper).uid).to eq paper.uid ...
github
scirate/scirate
https://github.com/scirate/scirate
spec/controllers/api_controller_spec.rb
Ruby
mit
181
main
2,405
require 'spec_helper' describe ApiController do let(:user) { FactoryGirl.create(:user) } let(:feed) { FactoryGirl.create(:feed) } let(:paper) { FactoryGirl.create(:paper) } before { become user } describe "sciting a paper" do before do post :scite, params: { paper_uid: paper.uid }, xhr: true ...
github
scirate/scirate
https://github.com/scirate/scirate
spec/controllers/users_controller_spec.rb
Ruby
mit
181
main
1,231
require 'spec_helper' describe UsersController do let(:user) { FactoryGirl.create(:user) } describe 'papers' do let(:paper) { FactoryGirl.create(:paper) } before do user.authorships.create!(paper_uid: paper.uid) end it "shows authored papers" do get :papers, params: { username: user....
github
scirate/scirate
https://github.com/scirate/scirate
spec/controllers/comments_controller_spec.rb
Ruby
mit
181
main
3,170
require 'spec_helper' describe CommentsController do let(:paper) { FactoryGirl.create(:paper_with_categories) } let(:comment) { FactoryGirl.create(:comment, paper: paper) } let(:user) { comment.user.reload } let(:other_user) { FactoryGirl.create(:user) } describe "recent comments index" do before do ...
github
scirate/scirate
https://github.com/scirate/scirate
spec/controllers/admin/users_controller_spec.rb
Ruby
mit
181
main
3,541
require 'spec_helper' describe Admin::UsersController do let!(:admin) { FactoryGirl.create(:admin) } let!(:user) { FactoryGirl.create(:user, fullname: 'Foobar', username: 'foo', email: 'foo@bar.io') } describe 'when login as non-admin user' do before { become user } describe 'GET edit' do b...
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/static_pages_spec.rb
Ruby
mit
181
main
246
require 'spec_helper' describe "Static pages" do describe "About page" do before { visit about_path } it "has the right content" do expect(page).to have_heading "About" expect(page).to have_title "About" end end end
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/authentication_pages_spec.rb
Ruby
mit
181
main
4,547
require 'spec_helper' describe "google signup" do let(:mock_auth) { MockAuth.google } before do OmniAuth.config.mock_auth[:google_oauth2] = mock_auth end it "should allow signup via google" do visit login_path click_link "Sign in with Google" #expect(page).to have_content "about to create a n...
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/settings_pages_spec.rb
Ruby
mit
181
main
3,282
require 'spec_helper' describe "Settings page" do before do @user = FactoryGirl.create(:user) sign_in @user visit settings_path end it "has the right settings fields" do expect(page).to have_link('change', href: 'http://gravatar.com/emails') expect(page).to have_field "Name", with: @user.ful...
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/feed_pages_spec.rb
Ruby
mit
181
main
5,216
require 'spec_helper' describe "Feed pages" do subject { page } let!(:time) { Chronic.parse("2015-01-05") } let!(:feed1) { FactoryGirl.create(:feed, last_paper_date: time) } let!(:feed2) { FactoryGirl.create(:feed, last_paper_date: time) } let!(:new_paper1) { FactoryGirl.create(:paper, uid: "1001.1001", tit...
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/admin_pages_spec.rb
Ruby
mit
181
main
2,968
require 'spec_helper' describe "Admin tools" do describe "Comment moderation" do before do @moderator = FactoryGirl.create(:user, account_status: User::STATUS_MODERATOR) @paper = FactoryGirl.create(:paper_with_comments_and_categories) @comment = @paper.comments.where(deleted: false).first ...
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/user_pages_spec.rb
Ruby
mit
181
main
4,015
require 'spec_helper' describe "profile page" do before(:all) do @user = FactoryGirl.create(:user) end it "displays profile if you're logged in" do other_user = FactoryGirl.create(:user) sign_in(other_user) visit user_path(@user) expect(page).to have_heading @user.fullname expect(page).t...
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/change_password_spec.rb
Ruby
mit
181
main
1,998
require 'spec_helper' describe "Password Settings" do subject { page } context "as user signed up with google" do let(:user) { google_user } before do sign_up_with_google visit settings_password_path expect(page).to have_content "does not require a password" fill_in "new_password"...
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/password_resets_spec.rb
Ruby
mit
181
main
2,961
require "spec_helper" describe "password resets" do subject { page } describe "emails user when requesting password reset" do let(:user) { FactoryGirl.create(:user) } before do visit login_path click_link "password" fill_in "Email", :with => user.email click_button "Reset passwor...
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/paper_pages_spec.rb
Ruby
mit
181
main
3,637
require 'spec_helper' describe "Paper pages" do before(:all) do @paper = FactoryGirl.create(:paper, uid: "1404.5997", title: "One weird trick for parallelizing convolutional neural networks", pdf_url: "https://arxiv.org/pdf/1404.5997.pdf", pubdate: Chronic.parse("25 Apr 2014") ) F...
github
scirate/scirate
https://github.com/scirate/scirate
spec/requests/comment_pages_spec.rb
Ruby
mit
181
main
1,723
require 'spec_helper' =begin describe "Comment revision history", js: true do let!(:comment) { FactoryGirl.create(:comment, content: 'this is original comment') } let!(:user) { FactoryGirl.create(:user) } let!(:moderator) { FactoryGirl.create(:user, :moderator) } before do comment.edit!("this is edited co...
github
scirate/scirate
https://github.com/scirate/scirate
spec/importer/importer_spec.rb
Ruby
mit
181
main
7,665
require 'spec_helper' require 'arxivsync' require 'arxiv_import' describe "arxiv importer" do before(:all) do archive = ArxivSync::XMLArchive.new("#{Rails.root.to_s}/spec/data/arxiv") archive.read_metadata do |models| @models = models end end it "estimates pubdates correctly" do # arXiv ru...
github
scirate/scirate
https://github.com/scirate/scirate
spec/search/migration_spec.rb
Ruby
mit
181
main
1,908
require 'spec_helper' describe "Search#migrate" do before :each do Search.drop Search.drop "scirate_test_old" end context "no current search index" do before do expect(Search.true_index_name).to be_nil end it "creates a new index" do Search.migrate expect(Search.true_index...
github
scirate/scirate
https://github.com/scirate/scirate
spec/search/search_spec.rb
Ruby
mit
181
main
2,989
require 'spec_helper' describe "search fields" do it "allows searching for a paper by uid" do paper1 = FactoryGirl.create(:paper) paper2 = FactoryGirl.create(:paper) Search::Paper.index(paper1, paper2) Search.refresh uids = Search::Paper.query_uids(paper1.uid) expect(uids).to eq [paper1.uid...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/feed_preference.rb
Ruby
mit
181
main
412
# == Schema Information # # Table name: feed_preferences # # id :integer not null, primary key # user_id :integer # last_visited :datetime # previous_last_visited :datetime # selected_range :integer # created_at :datetime # updated_at ...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/author.rb
Ruby
mit
181
main
1,689
# == Schema Information # # Table name: authors # # id :integer not null, primary key # position :integer not null # fullname :text not null # searchterm :text not null # paper_uid :text # # An Author represents an element in an ordered # list of paper author...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/category.rb
Ruby
mit
181
main
725
# == Schema Information # # Table name: categories # # id :integer not null, primary key # position :integer not null # feed_uid :text not null # paper_uid :text # crosslist_date :datetime default(2014-01-16 20:06:20 UTC), not null # # Specifies t...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/scite.rb
Ruby
mit
181
main
660
# == Schema Information # # Table name: scites # # id :integer not null, primary key # user_id :integer not null # created_at :datetime # updated_at :datetime # paper_uid :text default(""), not null # class Scite < ActiveRecord::Base belongs_to :user, class_name: "User"...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/user.rb
Ruby
mit
181
main
12,014
# == Schema Information # # Table name: users # # id :integer not null, primary key # fullname :text # email :text # remember_token :text # created_at :datetime not null # upda...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/auth_link.rb
Ruby
mit
181
main
1,252
# == Schema Information # # Table name: auth_links # # id :integer not null, primary key # provider :string(255) not null # uid :string(255) not null # oauth_token :string(255) not null # oauth_expires_at :datetime not null # user_id ...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/feed.rb
Ruby
mit
181
main
2,728
# == Schema Information # # Table name: feeds # # id :integer not null, primary key # uid :text not null # source :text not null # fullname :text not null # position :integer default(0), not nu...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/subscription.rb
Ruby
mit
181
main
541
# == Schema Information # # Table name: subscriptions # # id :integer not null, primary key # user_id :integer # created_at :datetime not null # updated_at :datetime not null # feed_uid :text default(""), not null # class Subscription < ActiveRecord::Base belong...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/authorship.rb
Ruby
mit
181
main
524
# == Schema Information # # Table name: authorships # # id :integer not null, primary key # user_id :integer not null # paper_uid :text not null # created_at :datetime # updated_at :datetime # class Authorship < ActiveRecord::Base belongs_to :user, touch: true belongs...
github
scirate/scirate
https://github.com/scirate/scirate
app/models/paper.rb
Ruby
mit
181
main
4,659
# == Schema Information # # Table name: papers # # id :integer not null, primary key # uid :text not null # submitter :text # title :text not null # abstract :text not null # author_comments :text # msc_class :text...