riot-rails 0.0.10.pre.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/{test/rails_root/app/views/rendered_templates/foo_bar.html.erb → README.md} +0 -0
  2. data/Rakefile +10 -32
  3. data/VERSION +1 -1
  4. data/init.rb +0 -0
  5. data/install.rb +0 -0
  6. data/lib/generators/riot_rails.rb +10 -0
  7. data/lib/generators/riot_rails/model/model_generator.rb +22 -0
  8. data/lib/generators/riot_rails/model/templates/fixtures.yml +23 -0
  9. data/lib/generators/riot_rails/model/templates/riot_test.rb +5 -0
  10. metadata +26 -155
  11. data/.gitignore +0 -4
  12. data/CHANGELOG +0 -144
  13. data/MIT-LICENSE +0 -20
  14. data/README.markdown +0 -31
  15. data/lib/riot/action_controller.rb +0 -4
  16. data/lib/riot/action_controller/context_macros/asserts_response.rb +0 -15
  17. data/lib/riot/action_controller/context_middleware.rb +0 -45
  18. data/lib/riot/action_controller/http_methods.rb +0 -19
  19. data/lib/riot/active_record.rb +0 -4
  20. data/lib/riot/active_record/assertion_macros.rb +0 -3
  21. data/lib/riot/active_record/context_middleware.rb +0 -15
  22. data/lib/riot/active_record/database_macros.rb +0 -58
  23. data/lib/riot/active_record/reflection_macros.rb +0 -106
  24. data/lib/riot/active_record/transactional_middleware.rb +0 -21
  25. data/lib/riot/active_record/validation_macros.rb +0 -187
  26. data/lib/riot/rails.rb +0 -1
  27. data/rails/init.rb +0 -1
  28. data/riot-rails.gemspec +0 -130
  29. data/test/action_controller/context_macros/asserts_response_test.rb +0 -35
  30. data/test/action_controller/context_middleware_test.rb +0 -66
  31. data/test/action_controller/delete_request_test.rb +0 -45
  32. data/test/action_controller/get_request_test.rb +0 -37
  33. data/test/action_controller/post_request_test.rb +0 -45
  34. data/test/action_controller/put_request_test.rb +0 -45
  35. data/test/action_controller/restful_delete_request_test.rb +0 -28
  36. data/test/action_controller/restful_get_request_test.rb +0 -25
  37. data/test/action_controller/restful_post_request_test.rb +0 -25
  38. data/test/action_controller/restful_put_request_test.rb +0 -28
  39. data/test/active_record/allowing_values_test.rb +0 -64
  40. data/test/active_record/attribute_is_invalid_test.rb +0 -20
  41. data/test/active_record/belongs_to_test.rb +0 -22
  42. data/test/active_record/context_middleware_test.rb +0 -18
  43. data/test/active_record/has_and_belongs_to_many_test.rb +0 -22
  44. data/test/active_record/has_database_index_on_test.rb +0 -73
  45. data/test/active_record/has_many_test.rb +0 -22
  46. data/test/active_record/has_one_test.rb +0 -22
  47. data/test/active_record/validates_length_of_test.rb +0 -31
  48. data/test/active_record/validates_presence_of_test.rb +0 -14
  49. data/test/active_record/validates_uniqueness_of_test.rb +0 -23
  50. data/test/rails_root/app/controllers/gremlins_controller.rb +0 -21
  51. data/test/rails_root/app/controllers/parties_controller.rb +0 -17
  52. data/test/rails_root/app/controllers/rooms_controller.rb +0 -22
  53. data/test/rails_root/config/database.yml +0 -4
  54. data/test/rails_root/config/environment.rb +0 -46
  55. data/test/rails_root/config/routes.rb +0 -7
  56. data/test/rails_root/db/schema.rb +0 -8
  57. data/test/teststrap.rb +0 -84
  58. data/test/transactional_middleware_test.rb +0 -26
data/lib/riot/rails.rb DELETED
@@ -1 +0,0 @@
1
- require 'riot'
data/rails/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'riot/rails' if RAILS_ENV == 'test'
data/riot-rails.gemspec DELETED
@@ -1,130 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{riot-rails}
8
- s.version = "0.0.10.pre.3"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Justin 'Gus' Knowlden"]
12
- s.date = %q{2010-06-04}
13
- s.description = %q{Riot specific test support for Rails apps. Protest the slow app.}
14
- s.email = %q{gus@gusg.us}
15
- s.extra_rdoc_files = [
16
- "README.markdown"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- "CHANGELOG",
21
- "MIT-LICENSE",
22
- "README.markdown",
23
- "Rakefile",
24
- "VERSION",
25
- "lib/riot/action_controller.rb",
26
- "lib/riot/action_controller/context_macros/asserts_response.rb",
27
- "lib/riot/action_controller/context_middleware.rb",
28
- "lib/riot/action_controller/http_methods.rb",
29
- "lib/riot/active_record.rb",
30
- "lib/riot/active_record/assertion_macros.rb",
31
- "lib/riot/active_record/context_middleware.rb",
32
- "lib/riot/active_record/database_macros.rb",
33
- "lib/riot/active_record/reflection_macros.rb",
34
- "lib/riot/active_record/transactional_middleware.rb",
35
- "lib/riot/active_record/validation_macros.rb",
36
- "lib/riot/rails.rb",
37
- "rails/init.rb",
38
- "riot-rails.gemspec",
39
- "test/action_controller/context_macros/asserts_response_test.rb",
40
- "test/action_controller/context_middleware_test.rb",
41
- "test/action_controller/delete_request_test.rb",
42
- "test/action_controller/get_request_test.rb",
43
- "test/action_controller/post_request_test.rb",
44
- "test/action_controller/put_request_test.rb",
45
- "test/action_controller/restful_delete_request_test.rb",
46
- "test/action_controller/restful_get_request_test.rb",
47
- "test/action_controller/restful_post_request_test.rb",
48
- "test/action_controller/restful_put_request_test.rb",
49
- "test/active_record/allowing_values_test.rb",
50
- "test/active_record/attribute_is_invalid_test.rb",
51
- "test/active_record/belongs_to_test.rb",
52
- "test/active_record/context_middleware_test.rb",
53
- "test/active_record/has_and_belongs_to_many_test.rb",
54
- "test/active_record/has_database_index_on_test.rb",
55
- "test/active_record/has_many_test.rb",
56
- "test/active_record/has_one_test.rb",
57
- "test/active_record/validates_length_of_test.rb",
58
- "test/active_record/validates_presence_of_test.rb",
59
- "test/active_record/validates_uniqueness_of_test.rb",
60
- "test/rails_root/app/controllers/gremlins_controller.rb",
61
- "test/rails_root/app/controllers/parties_controller.rb",
62
- "test/rails_root/app/controllers/rooms_controller.rb",
63
- "test/rails_root/app/views/rendered_templates/foo_bar.html.erb",
64
- "test/rails_root/config/database.yml",
65
- "test/rails_root/config/environment.rb",
66
- "test/rails_root/config/routes.rb",
67
- "test/rails_root/db/schema.rb",
68
- "test/teststrap.rb",
69
- "test/transactional_middleware_test.rb"
70
- ]
71
- s.homepage = %q{http://github.com/thumblemonks/riot-rails}
72
- s.rdoc_options = ["--charset=UTF-8"]
73
- s.require_paths = ["lib"]
74
- s.rubygems_version = %q{1.3.6}
75
- s.summary = %q{Riot specific test support for Rails apps}
76
- s.test_files = [
77
- "test/action_controller/context_macros/asserts_response_test.rb",
78
- "test/action_controller/context_middleware_test.rb",
79
- "test/action_controller/delete_request_test.rb",
80
- "test/action_controller/get_request_test.rb",
81
- "test/action_controller/post_request_test.rb",
82
- "test/action_controller/put_request_test.rb",
83
- "test/action_controller/restful_delete_request_test.rb",
84
- "test/action_controller/restful_get_request_test.rb",
85
- "test/action_controller/restful_post_request_test.rb",
86
- "test/action_controller/restful_put_request_test.rb",
87
- "test/active_record/allowing_values_test.rb",
88
- "test/active_record/attribute_is_invalid_test.rb",
89
- "test/active_record/belongs_to_test.rb",
90
- "test/active_record/context_middleware_test.rb",
91
- "test/active_record/has_and_belongs_to_many_test.rb",
92
- "test/active_record/has_database_index_on_test.rb",
93
- "test/active_record/has_many_test.rb",
94
- "test/active_record/has_one_test.rb",
95
- "test/active_record/validates_length_of_test.rb",
96
- "test/active_record/validates_presence_of_test.rb",
97
- "test/active_record/validates_uniqueness_of_test.rb",
98
- "test/rails_root/app/controllers/gremlins_controller.rb",
99
- "test/rails_root/app/controllers/parties_controller.rb",
100
- "test/rails_root/app/controllers/rooms_controller.rb",
101
- "test/rails_root/config/environment.rb",
102
- "test/rails_root/config/routes.rb",
103
- "test/rails_root/db/schema.rb",
104
- "test/teststrap.rb",
105
- "test/transactional_middleware_test.rb"
106
- ]
107
-
108
- if s.respond_to? :specification_version then
109
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
110
- s.specification_version = 3
111
-
112
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
113
- s.add_runtime_dependency(%q<riot>, [">= 0.11.0"])
114
- s.add_runtime_dependency(%q<rack-test>, [">= 0.5.3"])
115
- s.add_development_dependency(%q<activerecord>, [">= 3.0.0.beta3"])
116
- s.add_development_dependency(%q<actionpack>, [">= 3.0.0.beta3"])
117
- else
118
- s.add_dependency(%q<riot>, [">= 0.11.0"])
119
- s.add_dependency(%q<rack-test>, [">= 0.5.3"])
120
- s.add_dependency(%q<activerecord>, [">= 3.0.0.beta3"])
121
- s.add_dependency(%q<actionpack>, [">= 3.0.0.beta3"])
122
- end
123
- else
124
- s.add_dependency(%q<riot>, [">= 0.11.0"])
125
- s.add_dependency(%q<rack-test>, [">= 0.5.3"])
126
- s.add_dependency(%q<activerecord>, [">= 3.0.0.beta3"])
127
- s.add_dependency(%q<actionpack>, [">= 3.0.0.beta3"])
128
- end
129
- end
130
-
@@ -1,35 +0,0 @@
1
- require 'teststrap'
2
-
3
- context "An asserts_response context macro" do
4
- context "for context not representing an ActionController" do
5
- setup { Riot::Context.new("Hello") {} }
6
- asserts("asserts_response returns") { topic.asserts_response }.raises(NoMethodError)
7
- end # for context not representing an ActionController
8
-
9
- helper(:situation) do
10
- a_situation = Riot::Situation.new
11
- a_situation.helper(:response) { OpenStruct.new(:status => 200) }
12
- a_situation
13
- end
14
-
15
- setup do
16
- Riot::Context.new(RoomsController) {}
17
- end
18
-
19
- context "when referenced without arguments" do
20
- setup { topic.asserts_response }
21
-
22
- asserts_topic.kind_of(Riot::Assertion)
23
- asserts(:to_s).equals("asserts response")
24
-
25
- asserts("the result of assertion responds to :status") do
26
- topic.responds_to(:status).run(situation).first
27
- end.equals(:pass)
28
- end # when referenced without arguments
29
-
30
- context "with method name provided" do
31
- setup { topic.asserts_response(:status).equals(200) }
32
- asserts(:to_s).equals("asserts response #status")
33
- asserts("output of running the test") { topic.run(situation).first }.equals(:pass)
34
- end
35
- end # An asserts_response context macro
@@ -1,66 +0,0 @@
1
- require 'teststrap'
2
-
3
- context "ActionController middleware" do
4
- setup_test_context
5
-
6
- helper(:assigned) { |var| topic.instance_variable_get(var) }
7
-
8
- context "pre-request state" do
9
- setup do
10
- situation = Riot::Situation.new
11
- topic.context(RoomsController) {}.local_run(Riot::SilentReporter.new, situation)
12
- situation
13
- end
14
-
15
- asserts(:topic).equals(RoomsController)
16
-
17
- asserts("@app") { assigned(:@app).to_s }.equals { ::Rails.application.to_s }
18
- asserts("helper app") { topic.app.to_s }.equals { assigned(:@app).to_s }
19
-
20
- asserts("@env") { assigned(:@env) }.equals({})
21
- asserts("helper env") { topic.env }.equals { assigned(:@env) }
22
-
23
- asserts("helper controller") { topic.controller }.equals { assigned(:@controller) }
24
-
25
- asserts("request before any request made") do
26
- topic.request
27
- end.raises(Exception, "No request made yet")
28
-
29
- asserts("response before any request made") do
30
- topic.response
31
- end.raises(Exception, "No response since no request made yet")
32
-
33
- asserts_topic.responds_to(:get)
34
- asserts_topic.responds_to(:post)
35
- asserts_topic.responds_to(:put)
36
- asserts_topic.responds_to(:delete)
37
- end # pre-request state
38
-
39
- context "post-request state" do
40
- setup do
41
- situation = Riot::Situation.new
42
- topic.context(RoomsController) do
43
- setup { get("/rooms") }
44
- end.local_run(Riot::SilentReporter.new, situation)
45
- situation
46
- end
47
-
48
- asserts(:topic).kind_of(Array)
49
- asserts(:topic).size(3)
50
- asserts("#topic first element response status") { topic.topic[0] }.equals(200)
51
- asserts("#topic second element") { topic.topic[1] }.kind_of(Hash)
52
- asserts("#topic second element") { topic.topic[1] }.includes("ETag")
53
- asserts("#topic last element") { topic.topic[2] }.kind_of(ActionDispatch::Response)
54
-
55
- asserts("helper env") { topic.env }.includes("action_controller.instance")
56
-
57
- asserts("helper controller") { topic.controller }.kind_of(RoomsController)
58
- asserts("env['action_controller.instance']") do
59
- topic.env["action_controller.instance"]
60
- end.kind_of(RoomsController)
61
-
62
- asserts("helper request") { topic.request }.kind_of(Rack::Request)
63
- asserts("helper response") { topic.response }.kind_of(Rack::Response)
64
- end # post-request state
65
-
66
- end # ActionController middleware
@@ -1,45 +0,0 @@
1
- require 'teststrap'
2
-
3
- context RoomsController do
4
-
5
- asserts("DELETEs unknown action for existing controller") do
6
- delete "/rooms/blah"
7
- end.raises(AbstractController::ActionNotFound, "The action 'blah' could not be found")
8
-
9
- context "for a DELETE request" do
10
- helper(:action_name) { env['action_dispatch.request.path_parameters'][:action] }
11
-
12
- context "without parameters" do
13
- setup { delete "/rooms/destroy" }
14
-
15
- asserts("request method") { request.request_method }.equals("DELETE")
16
- asserts("action name") { action_name }.equals("destroy")
17
- asserts("response status") { response.status }.equals(200)
18
- asserts("response body") { response.body }.equals { "destroyed #{controller.params.inspect}" }
19
-
20
- context "response headers" do
21
- setup { response.headers.keys }
22
- asserts_topic.includes("Content-Type")
23
- asserts_topic.includes("ETag")
24
- asserts_topic.includes("Cache-Control")
25
- end # response headers
26
- end # without parameters
27
-
28
- context "with parameters" do
29
- setup { delete "/rooms/destroy", {:momma => "loves you", "love_you_too" => "mom"} }
30
-
31
- asserts("request method") { request.request_method }.equals("DELETE")
32
- asserts("action name") { action_name }.equals("destroy")
33
- asserts("response status") { response.status }.equals(200)
34
-
35
- asserts("response body") { response.body }.equals do
36
- "destroyed #{controller.params.inspect}"
37
- end
38
-
39
- asserts("params") { controller.params }.includes("momma")
40
- asserts("params") { controller.params }.includes("love_you_too")
41
- end # with parameters
42
-
43
- end # for a DELETE request
44
-
45
- end # RoomsController
@@ -1,37 +0,0 @@
1
- require 'teststrap'
2
-
3
- context RoomsController do
4
-
5
- asserts("GETs unknown action for existing controller") do
6
- get "/rooms/blah"
7
- end.raises(AbstractController::ActionNotFound, "The action 'blah' could not be found")
8
-
9
- context "for a GET request" do
10
- helper(:action_name) { env['action_dispatch.request.path_parameters'][:action] }
11
-
12
- context "without parameters" do
13
- setup { get "/rooms/index" }
14
-
15
- asserts("action name") { action_name }.equals("index")
16
- asserts("response status") { response.status }.equals(200)
17
- asserts("response body") { response.body }.equals("foo")
18
- asserts("request method") { request.request_method }.equals("GET")
19
-
20
- context "response headers" do
21
- setup { response.headers.keys }
22
- asserts_topic.includes("Content-Type")
23
- asserts_topic.includes("ETag")
24
- asserts_topic.includes("Cache-Control")
25
- end # response headers
26
- end # without parameters
27
-
28
- context "with parameters" do
29
- setup { get "/rooms/echo_params", {:name => "Juiceton", :foo => "blaz"} }
30
-
31
- asserts("action name") { action_name }.equals("echo_params")
32
- asserts("response body") { response.body }.equals("controller=rooms,foo=blaz,name=Juiceton")
33
- end # with with parameters
34
-
35
- end # for a GET request
36
-
37
- end # RoomsController
@@ -1,45 +0,0 @@
1
- require 'teststrap'
2
-
3
- context RoomsController do
4
-
5
- asserts("POSTs unknown action for existing controller") do
6
- post "/rooms/blah"
7
- end.raises(AbstractController::ActionNotFound, "The action 'blah' could not be found")
8
-
9
- context "for a POST request" do
10
- helper(:action_name) { env['action_dispatch.request.path_parameters'][:action] }
11
-
12
- context "without parameters" do
13
- setup { post "/rooms/create" }
14
-
15
- asserts("request method") { request.request_method }.equals("POST")
16
- asserts("action name") { action_name }.equals("create")
17
- asserts("response status") { response.status }.equals(200)
18
- asserts("response body") { response.body }.equals { "created #{controller.params.inspect}" }
19
-
20
- context "response headers" do
21
- setup { response.headers.keys }
22
- asserts_topic.includes("Content-Type")
23
- asserts_topic.includes("ETag")
24
- asserts_topic.includes("Cache-Control")
25
- end # response headers
26
- end # without parameters
27
-
28
- context "with parameters" do
29
- setup { post "/rooms/create", {:momma => "loves you", "love_you_too" => "mom"} }
30
-
31
- asserts("request method") { request.request_method }.equals("POST")
32
- asserts("action name") { action_name }.equals("create")
33
- asserts("response status") { response.status }.equals(200)
34
-
35
- asserts("response body") { response.body }.equals do
36
- "created #{controller.params.inspect}"
37
- end
38
-
39
- asserts("params") { controller.params }.includes("momma")
40
- asserts("params") { controller.params }.includes("love_you_too")
41
- end # with parameters
42
-
43
- end # for a POST request
44
-
45
- end # RoomsController
@@ -1,45 +0,0 @@
1
- require 'teststrap'
2
-
3
- context RoomsController do
4
-
5
- asserts("PUTs unknown action for existing controller") do
6
- put "/rooms/blah"
7
- end.raises(AbstractController::ActionNotFound, "The action 'blah' could not be found")
8
-
9
- context "for a PUT request" do
10
- helper(:action_name) { env['action_dispatch.request.path_parameters'][:action] }
11
-
12
- context "without parameters" do
13
- setup { put "/rooms/update" }
14
-
15
- asserts("request method") { request.request_method }.equals("PUT")
16
- asserts("action name") { action_name }.equals("update")
17
- asserts("response status") { response.status }.equals(200)
18
- asserts("response body") { response.body }.equals { "updated #{controller.params.inspect}" }
19
-
20
- context "response headers" do
21
- setup { response.headers.keys }
22
- asserts_topic.includes("Content-Type")
23
- asserts_topic.includes("ETag")
24
- asserts_topic.includes("Cache-Control")
25
- end # response headers
26
- end # without parameters
27
-
28
- context "with parameters" do
29
- setup { put "/rooms/update", {:momma => "loves you", "love_you_too" => "mom"} }
30
-
31
- asserts("request method") { request.request_method }.equals("PUT")
32
- asserts("action name") { action_name }.equals("update")
33
- asserts("response status") { response.status }.equals(200)
34
-
35
- asserts("response body") { response.body }.equals do
36
- "updated #{controller.params.inspect}"
37
- end
38
-
39
- asserts("params") { controller.params }.includes("momma")
40
- asserts("params") { controller.params }.includes("love_you_too")
41
- end # with parameters
42
-
43
- end # for a PUT request
44
-
45
- end # RoomsController
@@ -1,28 +0,0 @@
1
- require 'teststrap'
2
-
3
- context "RESTful DELETE request on resource" do
4
-
5
- context GremlinsController do
6
- setup { delete("/gremlins/2") }
7
-
8
- asserts("request method") { request.request_method }.equals("DELETE")
9
- asserts("controller name") { controller.controller_name }.equals("gremlins")
10
- asserts("action name") { controller.action_name }.equals("destroy")
11
- asserts("id param") { controller.params["id"] }.equals("2")
12
- asserts("response body") { response.body }.equals("spendin' money")
13
- end # on a top level resource
14
-
15
- context PartiesController do
16
- setup { delete("/gremlins/2/parties/3", "foo" => "bar") }
17
-
18
- asserts("request method") { request.request_method }.equals("DELETE")
19
- asserts("controller name") { controller.controller_name }.equals("parties")
20
- asserts("action name") { controller.action_name }.equals("destroy")
21
-
22
- asserts("gremlin_id param") { controller.params["gremlin_id"] }.equals("2")
23
- asserts("id param") { controller.params["id"] }.equals("3")
24
- asserts("foo param") { controller.params["foo"] }.equals("bar")
25
-
26
- asserts("response body") { response.body }.equals("all gone")
27
- end # on a nested resource
28
- end # RESTful DELETE request