test_urls 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2UzNWZhOWRlZmQ4NzJjOGU0OWI4YmEyMGUyMmMxOGRiMDBhZWYzNw==
5
+ data.tar.gz: !binary |-
6
+ OTg4ZGZlOTUxNzI3OGFlODY2M2Q0ODFhZDIzNGUyMTg1NGU5MjdjNA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ODg2ZGY0Mzk4MDdlYmY4Y2I1ZjIyZTk2N2JmMTA5ZThlNTM1MmY4MDcxYTI1
10
+ ZTY0ZTQ4NGUwNmQ5NWY3NTkxNmYxYmRlOTI4YzE2ZmI4MDdjNzlmYWRiMzcx
11
+ YTQ1MDhjNTViODE4MWE0MjkxOGVkMzQ0NzRiNjc1NDExNjAwNTc=
12
+ data.tar.gz: !binary |-
13
+ MDk4ODFkOWU5MGM3NTdhNjdhMzUyNmViNzUyZjRmNzA0M2VkNjlkNjAxYzZi
14
+ NTNkMjZhYzM3Y2QwNDc3YzQ2N2ZkOTIzYjkwNWY1NDUxZmQzYmM4NDU5NzVi
15
+ NzAyZGUxYmQzZjI2NzE4ZmE2YzYzODI5N2Y2MjY2ODViZmVjNzI=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in test_urls.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Olefine
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # TestUrls
2
+
3
+ Gem for test urls in development server. How it works:
4
+ - Get all "GET" routes
5
+ - Run all migrations on test database
6
+ - Seed db with 1 instances of each model
7
+ - curl each route
8
+
9
+ ## Getting started with rails(>= 3.2)
10
+ 1) add gem to your Gemfile
11
+ 2) start rails s
12
+ 3) run bundle
13
+ 4) run rake test_urls:run in the console
14
+
15
+ *Hint
16
+ If you run gem's rake task, then it drops you test db
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ gem 'test_urls'
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install test_urls
31
+
32
+ ## Usage
33
+
34
+ TODO: Write usage instructions here
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ require 'active_record'
2
+ module TestUrls
3
+ class TestUrls::PrepareDb
4
+ attr_reader :model_instances
5
+ def initialize
6
+ @model_instances = []
7
+ Dir[Rails.root.join("app/models/*.rb")].each {|file| require file }
8
+ ActiveRecord::Base.establish_connection("test")
9
+ end
10
+
11
+ def prepare
12
+ begin
13
+ `rake db:reset`
14
+ `rake db:migrate`
15
+ `rake db:test:prepare`
16
+ end
17
+
18
+ ActiveRecord::Base.descendants.each do |model|
19
+ inst = model.create(id: 1)
20
+ model.validate(inst)
21
+ @model_instances << inst
22
+ end
23
+
24
+ @model_instances
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ require 'test_urls'
2
+ require 'rails'
3
+
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ namespace :test_urls do
7
+ desc "run test that will return hash of routes and their states"
8
+ task :run => :environment do
9
+ p TestUrls.test_it
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'url'
2
+ require_relative 'prepare_db'
3
+ module TestUrls
4
+ class TestUrls::Test
5
+ def initialize
6
+ @host_url = "http://0.0.0.0:3000"
7
+ @routes = TestUrls::Url.new.routes
8
+ TestUrls::PrepareDb.new.prepare
9
+ @url_states = {}
10
+ end
11
+
12
+ def run_test
13
+ @routes.each do |route|
14
+ response = `curl -I #{@host_url}#{route}`
15
+ @url_states[route] = response.split[1]
16
+ end
17
+ @url_states
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ module TestUrls
2
+ class TestUrls::Url
3
+ attr_reader :valid_routes
4
+ def initialize
5
+ @valid_routes = []
6
+ end
7
+
8
+ def routes
9
+ @valid_routes ||= []
10
+ routes = `rake routes`.split("\n").map{ |r| r.gsub(', ', ',').split(' ') }
11
+
12
+ routes.each do |route|
13
+ if route.include? "GET" then @valid_routes << route[2] end
14
+ end
15
+
16
+ @valid_routes.each {|el| el.sub!("(.:format)", '')}
17
+
18
+ @valid_routes.each {|r| r.sub!(":id", '1')}
19
+ @valid_routes << "/"
20
+
21
+ @valid_routes
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module TestUrls
2
+ VERSION = "0.0.1"
3
+ end
data/lib/test_urls.rb ADDED
@@ -0,0 +1,10 @@
1
+ require_relative "test_urls/url"
2
+ require_relative "test_urls/prepare_db"
3
+ require_relative "test_urls/test"
4
+ require_relative "test_urls/railtie" if defined?(Rails)
5
+
6
+ module TestUrls
7
+ def self.test_it
8
+ Test.new.run_test
9
+ end
10
+ end
data/test_urls.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'test_urls/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "test_urls"
8
+ spec.version = TestUrls::VERSION
9
+ spec.authors = ["Olefine"]
10
+ spec.email = ["egor.gorodov@gmail.com"]
11
+ spec.description = %q{tests get urls in project}
12
+ spec.summary = %q{gem summary}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rails", ">= 3.2"
23
+ spec.add_development_dependency "rake"
24
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test_urls
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Olefine
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: tests get urls in project
56
+ email:
57
+ - egor.gorodov@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/test_urls.rb
68
+ - lib/test_urls/prepare_db.rb
69
+ - lib/test_urls/railtie.rb
70
+ - lib/test_urls/test.rb
71
+ - lib/test_urls/url.rb
72
+ - lib/test_urls/version.rb
73
+ - test_urls.gemspec
74
+ homepage: ''
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.0.5
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: gem summary
98
+ test_files: []