Fingertips-on-test-spec 0.2.2 → 0.2.3

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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :major: 0
3
2
  :minor: 2
4
- :patch: 2
3
+ :patch: 3
4
+ :major: 0
data/dot.autotest ADDED
@@ -0,0 +1,93 @@
1
+ Autotest.add_hook :initialize do |at|
2
+ at.unit_diff = 'cat'
3
+ at.failed_results_re = /^\s+\d+\) (?:Failure|Error):\n(.*?)\((.*?)\)\n\[([^:]*):.*\]/
4
+
5
+ at.add_exception %r%^\./(?:db|doc|log|public|script|tmp|vendor|data|content|config)%
6
+ at.add_exception %r%\.svn%
7
+
8
+ at.clear_mappings
9
+
10
+ # Add your custom mappings:
11
+ #
12
+ # at.add_mapping %r%^app/(concerns)/(.*)\.rb$% do |_, match|
13
+ # "test/unit/#{match[1]}/#{match[2]}_test.rb"
14
+ # end
15
+ #
16
+ # at.add_mapping %r%^test/unit/(concerns)/.*rb$% do |filename, _|
17
+ # filename
18
+ # end
19
+ #
20
+ # at.add_mapping %r%^lib/(.*).rb% do |_, match|
21
+ # sqwat = match[1].gsub('/', '_')
22
+ # "test/lib/#{sqwat}_test.rb"
23
+ # end
24
+ #
25
+ # at.add_mapping %r%^test/lib/.*rb$% do |filename, _|
26
+ # filename
27
+ # end
28
+
29
+ # Standard Rails
30
+
31
+ at.add_mapping %r%^test/fixtures/(.*)s.yml% do |_, m|
32
+ ["test/unit/#{m[1]}_test.rb",
33
+ "test/controllers/#{m[1]}_controller_test.rb",
34
+ "test/views/#{m[1]}_view_test.rb",
35
+ "test/functional/#{m[1]}_controller_test.rb"]
36
+ end
37
+
38
+ at.add_mapping %r%^test/(unit|integration|controllers|views|functional|helpers)/.*rb$% do |filename, _|
39
+ filename
40
+ end
41
+
42
+ at.add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
43
+ "test/unit/#{m[1]}_test.rb"
44
+ end
45
+
46
+ at.add_mapping %r%^app/helpers/application_helper.rb% do
47
+ ["test/helpers/applications_helper_test.rb"] + at.files_matching(%r%^test/(views|functional)/.*_test\.rb$%)
48
+ end
49
+
50
+ at.add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
51
+ if m[1] == "application" then
52
+ at.files_matching %r%^test/(views|functional)/.*_test\.rb$%
53
+ else
54
+ ["test/helpers/#{m[1]}_helper_test.rb",
55
+ "test/views/#{m[1]}_view_test.rb",
56
+ "test/functional/#{m[1]}_controller_test.rb"]
57
+ end
58
+ end
59
+
60
+ at.add_mapping %r%^app/views/(.*)/% do |_, m|
61
+ ["test/views/#{m[1]}_view_test.rb",
62
+ "test/functional/#{m[1]}_controller_test.rb"]
63
+ end
64
+
65
+ at.add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
66
+ if m[1] == "application" then
67
+ at.files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
68
+ else
69
+ ["test/controllers/#{m[1]}_test.rb",
70
+ "test/functional/#{m[1]}_test.rb"]
71
+ end
72
+ end
73
+
74
+ at.add_mapping %r%^app/views/layouts/% do
75
+ "test/views/layouts_view_test.rb"
76
+ end
77
+
78
+ at.add_mapping %r%^config/routes.rb$% do
79
+ at.files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
80
+ end
81
+
82
+ at.add_mapping %r%^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% do
83
+ at.files_matching %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
84
+ end
85
+
86
+ class << at
87
+ def consolidate_failures(failed)
88
+ failed.inject(new_hash_of_arrays) do |filters, (method, klass, filename)|
89
+ filters[File.expand_path(filename)] << method; filters
90
+ end
91
+ end
92
+ end
93
+ end
@@ -8,8 +8,6 @@ module Test
8
8
  end
9
9
 
10
10
  module ShouldExpectations
11
- include ActiveSupport::Testing::Assertions
12
-
13
11
  # Test that we were redirected somewhere:
14
12
  # should.redirect
15
13
  #
@@ -19,9 +17,9 @@ module Test
19
17
  # should.redirect_to :controller => 'foo', :action => 'bar', :secure => true
20
18
  def redirect(*args)
21
19
  if args.empty?
22
- assert_response @object.response.redirected_to, :redirect
20
+ test_case.assert_response @object.response.redirected_to, :redirect
23
21
  elsif args.length == 1 and args.first.is_a?(String)
24
- assert_equal args.first, @object.response.redirected_to
22
+ test_case.assert_equal args.first, @object.response.redirected_to
25
23
  else
26
24
  options = args.extract_options!
27
25
  if secure = options.delete(:secure)
@@ -30,11 +28,11 @@ module Test
30
28
  end
31
29
  end
32
30
 
33
- @object.instance_eval { assert_redirected_to *args }
31
+ @object.instance_eval { test_case.assert_redirected_to *args }
34
32
  if secure == true
35
- assert @object.response.redirected_to.starts_with?('https:')
33
+ test_case.assert @object.response.redirected_to.starts_with?('https:')
36
34
  elsif secure == false
37
- assert @object.response.redirected_to.starts_with?('http:')
35
+ test_case.assert @object.response.redirected_to.starts_with?('http:')
38
36
  end
39
37
  end
40
38
  end
@@ -57,7 +55,7 @@ module Test
57
55
 
58
56
  # Test that the object is valid
59
57
  def validate
60
- assert_valid @object
58
+ test_case.assert_valid @object
61
59
  end
62
60
 
63
61
  # Tests whether the evaluation of the expression changes.
@@ -79,7 +77,7 @@ module Test
79
77
  expected.in_groups_of(2).each_with_index do |(expression, difference), index|
80
78
  difference = 1 if difference.nil?
81
79
  error = "#{expression.inspect} didn't change by #{difference}"
82
- assert_equal(before[index] + difference, eval(expression, block_binding), error)
80
+ test_case.assert_equal(before[index] + difference, eval(expression, block_binding), error)
83
81
  end
84
82
 
85
83
  block_result
@@ -100,12 +98,12 @@ module Test
100
98
  files = Dir.glob("#{cache_dir}/**/*").map do |filename|
101
99
  filename[cache_dir.length..-1]
102
100
  end
103
- assert pages.all? { |page| files.include?(page) }
101
+ test_case.assert pages.all? { |page| files.include?(page) }
104
102
  end
105
103
 
106
104
  # Test two HTML strings for equivalency (e.g., identical up to reordering of attributes)
107
105
  def dom_equal(expected)
108
- assert_dom_equal expected, @object
106
+ test_case.assert_dom_equal expected, @object
109
107
  end
110
108
 
111
109
  # Tests if the array of records is the same, order may vary
@@ -115,7 +113,7 @@ module Test
115
113
  left = @object.map(&:id).sort
116
114
  right = expected.map(&:id).sort
117
115
 
118
- assert(left == right, message)
116
+ test_case.assert(left == right, message)
119
117
  end
120
118
 
121
119
  # Tests if the array of records is the same, order must be the same
@@ -125,16 +123,14 @@ module Test
125
123
  left = @object.map(&:id)
126
124
  right = expected.map(&:id)
127
125
 
128
- assert(left == right, message)
126
+ test_case.assert(left == right, message)
129
127
  end
130
128
  end
131
129
 
132
130
  module ShouldNotExpectations
133
- include ActiveSupport::Testing::Assertions
134
-
135
131
  # Test that an object is not valid
136
132
  def validate
137
- assert !@object.valid?
133
+ test_case.assert !@object.valid?
138
134
  end
139
135
 
140
136
  # Tests that the evaluation of the expression shouldn't change
@@ -155,7 +151,7 @@ module Test
155
151
  expected.each_with_index do |expression, index|
156
152
  difference = eval(expression, block_binding) - before[index]
157
153
  error = "#{expression.inspect} changed by #{difference}, expected no change"
158
- assert_equal(0, difference, error)
154
+ test_case.assert_equal(0, difference, error)
159
155
  end
160
156
 
161
157
  block_result
@@ -165,7 +161,7 @@ module Test
165
161
 
166
162
  # Test that two HTML strings are not equivalent
167
163
  def dom_equal(expected)
168
- assert_dom_not_equal expected, @object
164
+ test_case.assert_dom_not_equal expected, @object
169
165
  end
170
166
 
171
167
  # Tests if the array of records is not the same, order may vary
@@ -175,7 +171,7 @@ module Test
175
171
  left = @object.map(&:id).sort
176
172
  right = expected.map(&:id).sort
177
173
 
178
- assert(left != right, message)
174
+ test_case.assert(left != right, message)
179
175
  end
180
176
 
181
177
  # Tests if the array of records is not the same, order may vary
@@ -185,7 +181,7 @@ module Test
185
181
  left = @object.map(&:id)
186
182
  right = expected.map(&:id)
187
183
 
188
- assert(left != right, message)
184
+ test_case.assert(left != right, message)
189
185
  end
190
186
  end
191
187
  end
@@ -21,3 +21,17 @@ class Test::Spec::ShouldNot
21
21
  @object.respond_to?(:should_not_equal) ? @object.should_not_equal(*args) : _test_spec_be(*args)
22
22
  end
23
23
  end
24
+
25
+ module Test
26
+ module Spec
27
+ module ExpectationExt
28
+ # Returns the current test case instance. Use this to call assert methods on.
29
+ def test_case
30
+ $TEST_SPEC_TESTCASE
31
+ end
32
+ end
33
+
34
+ Should.send(:include, ExpectationExt)
35
+ ShouldNot.send(:include, ExpectationExt)
36
+ end
37
+ end
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
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 = %q{on-test-spec}
8
+ s.version = "0.2.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Manfred Stienstra", "Eloy Duran", "Cristi Balan"]
12
+ s.date = %q{2009-09-24}
13
+ s.description = %q{Rails plugin to make testing Rails on test/spec easier.}
14
+ s.email = %q{eloy.de.enige@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README",
23
+ "Rakefile",
24
+ "VERSION.yml",
25
+ "dot.autotest",
26
+ "lib/test/spec/add_allow_switch.rb",
27
+ "lib/test/spec/rails.rb",
28
+ "lib/test/spec/rails/controller_helpers.rb",
29
+ "lib/test/spec/rails/expectations.rb",
30
+ "lib/test/spec/rails/macros.rb",
31
+ "lib/test/spec/rails/macros/authorization.rb",
32
+ "lib/test/spec/rails/request_helpers.rb",
33
+ "lib/test/spec/rails/response_helpers.rb",
34
+ "lib/test/spec/rails/spec_responder.rb",
35
+ "lib/test/spec/rails/test_spec_ext.rb",
36
+ "lib/test/spec/share.rb",
37
+ "on-test-spec.gemspec",
38
+ "test/add_allow_switch_test.rb",
39
+ "test/controller_helpers_test.rb",
40
+ "test/expectations_test.rb",
41
+ "test/macros/authorization_test.rb",
42
+ "test/macros/base_test.rb",
43
+ "test/rails_test.rb",
44
+ "test/share_test.rb",
45
+ "test/test_helper.rb",
46
+ "test/test_spec_ext_test.rb"
47
+ ]
48
+ s.homepage = %q{http://github.com/Fingertips/on-test-spec}
49
+ s.rdoc_options = ["--charset=UTF-8"]
50
+ s.require_paths = ["lib"]
51
+ s.rubygems_version = %q{1.3.5}
52
+ s.summary = %q{Rails plugin to make testing Rails on test/spec easier.}
53
+ s.test_files = [
54
+ "test/add_allow_switch_test.rb",
55
+ "test/controller_helpers_test.rb",
56
+ "test/expectations_test.rb",
57
+ "test/macros/authorization_test.rb",
58
+ "test/macros/base_test.rb",
59
+ "test/rails_test.rb",
60
+ "test/share_test.rb",
61
+ "test/test_helper.rb",
62
+ "test/test_spec_ext_test.rb"
63
+ ]
64
+
65
+ if s.respond_to? :specification_version then
66
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
67
+ s.specification_version = 3
68
+
69
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
70
+ else
71
+ end
72
+ else
73
+ end
74
+ end
@@ -3,29 +3,25 @@ require 'test/spec/rails'
3
3
 
4
4
  module TestingAssertionsThemselves
5
5
  class << self
6
+ def setup
7
+ $TEST_SPEC_TESTCASE = TestingAssertionsThemselves
8
+ TestingAssertionsThemselves.assertions = []
9
+ end
10
+
6
11
  attr_accessor :assertions
12
+
13
+ def assert(*args)
14
+ TestingAssertionsThemselves.assertions << [:assert, args]
15
+ end
16
+
17
+ def assert_equal(*args)
18
+ TestingAssertionsThemselves.assertions << [:assert_equal, args]
19
+ end
20
+
21
+ def last_assertion
22
+ TestingAssertionsThemselves.assertions.last
23
+ end
7
24
  end
8
- @assertions = []
9
-
10
- def assert(*args)
11
- TestingAssertionsThemselves.assertions << [:assert, args]
12
- end
13
-
14
- def assert_equal(*args)
15
- TestingAssertionsThemselves.assertions << [:assert_equal, args]
16
- end
17
-
18
- def self.last_assertion
19
- TestingAssertionsThemselves.assertions.last
20
- end
21
- end
22
-
23
- class Test::Spec::Should
24
- include TestingAssertionsThemselves
25
- end
26
-
27
- class Test::Spec::ShouldNot
28
- include TestingAssertionsThemselves
29
25
  end
30
26
 
31
27
  module AssertionAssertions
@@ -73,7 +69,7 @@ describe "Differ expectations" do
73
69
  attr_accessor :controller
74
70
 
75
71
  before do
76
- TestingAssertionsThemselves.assertions = []
72
+ TestingAssertionsThemselves.setup
77
73
  end
78
74
 
79
75
  it "should succeed when the expected difference occurs on a local variable" do
@@ -186,7 +182,7 @@ describe "NotDiffer expectations" do
186
182
  attr_accessor :controller
187
183
 
188
184
  before do
189
- TestingAssertionsThemselves.assertions = []
185
+ TestingAssertionsThemselves.setup
190
186
  end
191
187
 
192
188
  it "should succeed when no difference occurs on a local variable" do
@@ -279,7 +275,7 @@ describe "Record expectations" do
279
275
  attr_accessor :controller
280
276
 
281
277
  before do
282
- TestingAssertionsThemselves.assertions = []
278
+ TestingAssertionsThemselves.setup
283
279
  end
284
280
 
285
281
  it "should succeed when equal_set assertions are correct" do
@@ -416,7 +412,7 @@ describe "Redirection expectations" do
416
412
  attr_accessor :controller
417
413
 
418
414
  before do
419
- TestingAssertionsThemselves.assertions = []
415
+ TestingAssertionsThemselves.setup
420
416
 
421
417
  @controller = TestController.new
422
418
  @controller.stubs(:url_for).returns(@url)
@@ -86,7 +86,7 @@ describe "Macros::Authorization" do
86
86
  generator.should.is_a(Test::Spec::Rails::Macros::Authorization::TestGenerator)
87
87
  generator.test_case.should == @test_case
88
88
  generator.validation_method.should == :access_denied?
89
- generator.message.should == 'Expected access to be denied'
89
+ generator.message.should == 'Expected access to be allowed'
90
90
  generator.expected.should == false
91
91
  end
92
92
 
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+
3
+ module SomeIncludableAssertions
4
+ def assert_foo
5
+ assert true
6
+ end
7
+ end
8
+
9
+ ActionView::TestCase.send(:include, SomeIncludableAssertions)
10
+
11
+ module SomeIncludableExpectations
12
+ def foo
13
+ test_case.assert_foo
14
+ end
15
+ end
16
+
17
+ Test::Spec::Should.send(:include, SomeIncludableExpectations)
18
+
19
+ module AViewHelper
20
+ end
21
+
22
+ describe "Test::Spec::ExpectationExt, for", AViewHelper do
23
+ it "should call assert methods directly on the test case instance" do
24
+ lambda { Object.new.should.foo }.should.not.raise
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Fingertips-on-test-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manfred Stienstra
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-09-21 00:00:00 -07:00
14
+ date: 2009-09-24 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies: []
17
17
 
@@ -25,10 +25,12 @@ extra_rdoc_files:
25
25
  - LICENSE
26
26
  - README
27
27
  files:
28
+ - .gitignore
28
29
  - LICENSE
29
30
  - README
30
31
  - Rakefile
31
32
  - VERSION.yml
33
+ - dot.autotest
32
34
  - lib/test/spec/add_allow_switch.rb
33
35
  - lib/test/spec/rails.rb
34
36
  - lib/test/spec/rails/controller_helpers.rb
@@ -40,6 +42,7 @@ files:
40
42
  - lib/test/spec/rails/spec_responder.rb
41
43
  - lib/test/spec/rails/test_spec_ext.rb
42
44
  - lib/test/spec/share.rb
45
+ - on-test-spec.gemspec
43
46
  - test/add_allow_switch_test.rb
44
47
  - test/controller_helpers_test.rb
45
48
  - test/expectations_test.rb
@@ -48,7 +51,8 @@ files:
48
51
  - test/rails_test.rb
49
52
  - test/share_test.rb
50
53
  - test/test_helper.rb
51
- has_rdoc: true
54
+ - test/test_spec_ext_test.rb
55
+ has_rdoc: false
52
56
  homepage: http://github.com/Fingertips/on-test-spec
53
57
  licenses:
54
58
  post_install_message:
@@ -73,7 +77,7 @@ requirements: []
73
77
  rubyforge_project:
74
78
  rubygems_version: 1.3.5
75
79
  signing_key:
76
- specification_version: 2
80
+ specification_version: 3
77
81
  summary: Rails plugin to make testing Rails on test/spec easier.
78
82
  test_files:
79
83
  - test/add_allow_switch_test.rb
@@ -84,3 +88,4 @@ test_files:
84
88
  - test/rails_test.rb
85
89
  - test/share_test.rb
86
90
  - test/test_helper.rb
91
+ - test/test_spec_ext_test.rb