testoaster 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -3,6 +3,28 @@
3
3
 
4
4
  Some testing goodies for Rails
5
5
 
6
+ = Functionality of Testoaster
7
+
8
+
9
+ This gem is designed for unit and functional tests.
10
+
11
+ This gem does the following:
12
+
13
+ * adds method puts!() that allows you to inspect an element faster. The output (to standard) of puts!() is prepended by "+++ +++" so it is easier to find in logs. The output is .inspect`ed for clarity.
14
+
15
+ * adds method puts_each!() that works like puts!() but on a list
16
+
17
+ * adds method todo(msg='') that fails with a message
18
+
19
+ * suppresses Paperclip attachment warnings
20
+
21
+ * adds method assert_layout(layout)
22
+
23
+ * adds method t(), which returns your localization information from file en.yml . The scopes of translations must be dot-delimited, for example: t('users.errors.unauthorized')
24
+
25
+ * adds method sign_in_path() which always returns '/users/sign_in'
26
+
27
+ * adds assert_contains(str) method which seeks the str as a regex in the response body.
6
28
 
7
29
 
8
30
  == Contributing to testoaster
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/lib/testoaster.rb CHANGED
@@ -0,0 +1,54 @@
1
+
2
+
3
+ def puts! arg
4
+ puts '+++ +++'
5
+ puts arg.inspect
6
+ end
7
+
8
+ def puts_each! arg
9
+ puts '+++ +++'
10
+ arg.each do |e|
11
+ puts e.inspect
12
+ end
13
+ end
14
+
15
+ def todo msg = ''
16
+ assert false, '@TODO: ' + msg
17
+ end
18
+
19
+ begin
20
+ Paperclip.options[:log] = false
21
+ rescue
22
+ end
23
+
24
+ def assert_layout layout
25
+ assert_equal layout, @response.layout
26
+ end
27
+
28
+ def t which, addr = 'config/locales/en.yml'
29
+ file = YAML::load(File.open(addr))
30
+ file = file["en"]
31
+
32
+ arr = which.split('.')
33
+ arr.each do |a|
34
+ file = file[a]
35
+ end
36
+
37
+ file
38
+ end
39
+
40
+ def sign_in_path
41
+ '/users/sign_in'
42
+ end
43
+
44
+ def assert_contains th
45
+
46
+ b = @response.body
47
+
48
+ if b =~ /#{Regexp.quote(th)}/
49
+ assert true
50
+ else
51
+ assert false
52
+ end
53
+
54
+ end
data/test/en.yml ADDED
@@ -0,0 +1,5 @@
1
+
2
+
3
+ en:
4
+ users:
5
+ test: Test
@@ -1,10 +1,79 @@
1
1
 
2
2
  require 'helper'
3
+ require 'testoaster'
4
+ require 'stringio'
5
+
6
+ module Kernel
7
+
8
+ def capture_stdout
9
+ out = StringIO.new
10
+ $stdout = out
11
+ yield
12
+ return out.string
13
+ ensure
14
+ $stdout = STDOUT
15
+ end
16
+
17
+ end
18
+
19
+ class Response
20
+
21
+ attr_accessor :layout
22
+ attr_accessor :body
23
+
24
+ end
25
+
3
26
 
4
27
  class TestTestoaster < Test::Unit::TestCase
5
28
 
6
- should "test sanity" do
7
- assert true
29
+ should 'test puts!' do
30
+ result = capture_stdout do
31
+ puts! 'blah blah'
32
+ end
33
+ expected = "+++ +++\n\"blah blah\"\n"
34
+ assert_equal expected, result
35
+
36
+ end
37
+
38
+ should 'test puts_each!' do
39
+ arr = [ 1, 2, 3]
40
+ result = capture_stdout do
41
+ puts_each! arr
42
+ end
43
+ expected = "+++ +++\n1\n2\n3\n"
44
+ assert_equal expected, result
45
+ end
46
+
47
+ should 'assert test_layout' do
48
+ @response = Response.new
49
+ @response.layout = 'layyy'
50
+
51
+ assert_layout 'layyy'
52
+
53
+ end
54
+
55
+ should 'test t()' do
56
+ result = t('users.test', 'test/en.yml')
57
+ assert_equal 'Test', result
58
+ end
59
+
60
+ should 'test sign_in_path()' do
61
+ assert_equal '/users/sign_in', sign_in_path
62
+ end
63
+
64
+ should 'test assert contains' do
65
+ @r = Response.new
66
+ @r.body = 'ttt'
67
+
68
+ assert_contains @r.body, 'ttt'
69
+ end
70
+
71
+ should 'test todo' do
72
+ begin
73
+ todo
74
+ rescue Exception => e
75
+ assert_equal '@TODO: ', e.to_s
76
+ end
8
77
  end
9
78
 
10
79
  end
@@ -0,0 +1,57 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "testoaster"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Victor Pudeyev"]
12
+ s.date = "2012-07-08"
13
+ s.description = "Some Rails testing goodies."
14
+ s.email = "piousbox@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/testoaster.rb",
28
+ "test/en.yml",
29
+ "test/helper.rb",
30
+ "test/test_testoaster.rb",
31
+ "testoaster.gemspec"
32
+ ]
33
+ s.homepage = "http://github.com/piousbox/testoaster"
34
+ s.licenses = ["GLP v2"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = "1.8.10"
37
+ s.summary = "Some Rails testing goodies."
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
44
+ s.add_development_dependency(%q<bundler>, ["~> 1.2.0.pre.1"])
45
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
46
+ else
47
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
48
+ s.add_dependency(%q<bundler>, ["~> 1.2.0.pre.1"])
49
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
50
+ end
51
+ else
52
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.2.0.pre.1"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
55
+ end
56
+ end
57
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testoaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
16
- requirement: &2163539960 !ruby/object:Gem::Requirement
16
+ requirement: &2163536240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.12'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2163539960
24
+ version_requirements: *2163536240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &2163539440 !ruby/object:Gem::Requirement
27
+ requirement: &2163535580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.2.0.pre.1
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2163539440
35
+ version_requirements: *2163535580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &2163538860 !ruby/object:Gem::Requirement
38
+ requirement: &2163534620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.8.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2163538860
46
+ version_requirements: *2163534620
47
47
  description: Some Rails testing goodies.
48
48
  email: piousbox@gmail.com
49
49
  executables: []
@@ -60,8 +60,10 @@ files:
60
60
  - Rakefile
61
61
  - VERSION
62
62
  - lib/testoaster.rb
63
+ - test/en.yml
63
64
  - test/helper.rb
64
65
  - test/test_testoaster.rb
66
+ - testoaster.gemspec
65
67
  homepage: http://github.com/piousbox/testoaster
66
68
  licenses:
67
69
  - GLP v2
@@ -77,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
79
  version: '0'
78
80
  segments:
79
81
  - 0
80
- hash: -2477995376589768263
82
+ hash: -1140959684856587787
81
83
  required_rubygems_version: !ruby/object:Gem::Requirement
82
84
  none: false
83
85
  requirements: