riot-rails 0.0.10.pre.3 → 0.1.0
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/{test/rails_root/app/views/rendered_templates/foo_bar.html.erb → README.md} +0 -0
- data/Rakefile +10 -32
- data/VERSION +1 -1
- data/init.rb +0 -0
- data/install.rb +0 -0
- data/lib/generators/riot_rails.rb +10 -0
- data/lib/generators/riot_rails/model/model_generator.rb +22 -0
- data/lib/generators/riot_rails/model/templates/fixtures.yml +23 -0
- data/lib/generators/riot_rails/model/templates/riot_test.rb +5 -0
- metadata +26 -155
- data/.gitignore +0 -4
- data/CHANGELOG +0 -144
- data/MIT-LICENSE +0 -20
- data/README.markdown +0 -31
- data/lib/riot/action_controller.rb +0 -4
- data/lib/riot/action_controller/context_macros/asserts_response.rb +0 -15
- data/lib/riot/action_controller/context_middleware.rb +0 -45
- data/lib/riot/action_controller/http_methods.rb +0 -19
- data/lib/riot/active_record.rb +0 -4
- data/lib/riot/active_record/assertion_macros.rb +0 -3
- data/lib/riot/active_record/context_middleware.rb +0 -15
- data/lib/riot/active_record/database_macros.rb +0 -58
- data/lib/riot/active_record/reflection_macros.rb +0 -106
- data/lib/riot/active_record/transactional_middleware.rb +0 -21
- data/lib/riot/active_record/validation_macros.rb +0 -187
- data/lib/riot/rails.rb +0 -1
- data/rails/init.rb +0 -1
- data/riot-rails.gemspec +0 -130
- data/test/action_controller/context_macros/asserts_response_test.rb +0 -35
- data/test/action_controller/context_middleware_test.rb +0 -66
- data/test/action_controller/delete_request_test.rb +0 -45
- data/test/action_controller/get_request_test.rb +0 -37
- data/test/action_controller/post_request_test.rb +0 -45
- data/test/action_controller/put_request_test.rb +0 -45
- data/test/action_controller/restful_delete_request_test.rb +0 -28
- data/test/action_controller/restful_get_request_test.rb +0 -25
- data/test/action_controller/restful_post_request_test.rb +0 -25
- data/test/action_controller/restful_put_request_test.rb +0 -28
- data/test/active_record/allowing_values_test.rb +0 -64
- data/test/active_record/attribute_is_invalid_test.rb +0 -20
- data/test/active_record/belongs_to_test.rb +0 -22
- data/test/active_record/context_middleware_test.rb +0 -18
- data/test/active_record/has_and_belongs_to_many_test.rb +0 -22
- data/test/active_record/has_database_index_on_test.rb +0 -73
- data/test/active_record/has_many_test.rb +0 -22
- data/test/active_record/has_one_test.rb +0 -22
- data/test/active_record/validates_length_of_test.rb +0 -31
- data/test/active_record/validates_presence_of_test.rb +0 -14
- data/test/active_record/validates_uniqueness_of_test.rb +0 -23
- data/test/rails_root/app/controllers/gremlins_controller.rb +0 -21
- data/test/rails_root/app/controllers/parties_controller.rb +0 -17
- data/test/rails_root/app/controllers/rooms_controller.rb +0 -22
- data/test/rails_root/config/database.yml +0 -4
- data/test/rails_root/config/environment.rb +0 -46
- data/test/rails_root/config/routes.rb +0 -7
- data/test/rails_root/db/schema.rb +0 -8
- data/test/teststrap.rb +0 -84
- data/test/transactional_middleware_test.rb +0 -26
@@ -1,17 +0,0 @@
|
|
1
|
-
class PartiesController < ActionController::Base
|
2
|
-
def show
|
3
|
-
render :text => "woot"
|
4
|
-
end
|
5
|
-
|
6
|
-
def create
|
7
|
-
render :text => "give this monkey what he wants"
|
8
|
-
end
|
9
|
-
|
10
|
-
def update
|
11
|
-
render :text => "i'll put that over here"
|
12
|
-
end
|
13
|
-
|
14
|
-
def destroy
|
15
|
-
render :text => "all gone"
|
16
|
-
end
|
17
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class RoomsController < ActionController::Base
|
2
|
-
def index
|
3
|
-
render :text => "foo"
|
4
|
-
end
|
5
|
-
|
6
|
-
def create
|
7
|
-
render :text => "created #{params.inspect}"
|
8
|
-
end
|
9
|
-
|
10
|
-
def update
|
11
|
-
render :text => "updated #{params.inspect}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def destroy
|
15
|
-
render :text => "destroyed #{params.inspect}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def echo_params
|
19
|
-
serialized_params = (params.keys - ["action"]).sort.map {|k| "#{k}=#{params[k]}" }.join(",")
|
20
|
-
render :text => serialized_params
|
21
|
-
end
|
22
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
ENV['RAILS_ENV'] = 'test'
|
2
|
-
|
3
|
-
require 'sqlite3'
|
4
|
-
require "active_record/railtie"
|
5
|
-
require "action_controller/railtie"
|
6
|
-
# require "action_mailer/railtie"
|
7
|
-
# require "active_resource/railtie"
|
8
|
-
|
9
|
-
module RiotRails
|
10
|
-
class Application < Rails::Application
|
11
|
-
config.root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
12
|
-
|
13
|
-
config.session_store :cookie_store, {:key => "_riotrails_session"}
|
14
|
-
config.secret_token = "i own you." * 3
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
RiotRails::Application.initialize!
|
19
|
-
|
20
|
-
require File.join(Rails.root, "config", "routes.rb")
|
21
|
-
|
22
|
-
# Logging stuff
|
23
|
-
|
24
|
-
class NilIO
|
25
|
-
def write(*args); end
|
26
|
-
def close(*args); end
|
27
|
-
def puts(*args); end
|
28
|
-
def path; nil; end
|
29
|
-
def fsync; 0; end
|
30
|
-
def to_s; "hello"; end
|
31
|
-
def sync; true; end
|
32
|
-
def sync=(arg); arg; end
|
33
|
-
end
|
34
|
-
|
35
|
-
def shhh(&block)
|
36
|
-
orig_out = $stdout
|
37
|
-
$stdout = NilIO.new
|
38
|
-
yield
|
39
|
-
$stdout = orig_out
|
40
|
-
end
|
41
|
-
|
42
|
-
shhh do
|
43
|
-
load(File.join(Rails.root, "db", "schema.rb"))
|
44
|
-
end
|
45
|
-
|
46
|
-
ActiveRecord::Base.logger = Logger.new(NilIO.new)
|
data/test/teststrap.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'pathname'
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
6
|
-
|
7
|
-
#
|
8
|
-
# Setup faux Rails environment
|
9
|
-
|
10
|
-
require(Pathname(__FILE__).dirname + 'rails_root' + 'config' + 'environment')
|
11
|
-
|
12
|
-
#
|
13
|
-
# Model definition
|
14
|
-
|
15
|
-
class Room < ActiveRecord::Base
|
16
|
-
validates_presence_of :location
|
17
|
-
validates_format_of :email, :with => /^\w+@\w+\.\w+$/
|
18
|
-
validates_uniqueness_of :email
|
19
|
-
validates_length_of :name, :within => 5..20
|
20
|
-
validates_length_of :contents, :within => 0..100, :allow_blank => true
|
21
|
-
|
22
|
-
has_many :doors, :class_name => 'Porthole'
|
23
|
-
has_one :floor, :class_name => "Substrate"
|
24
|
-
has_and_belongs_to_many :walls, :join_table => "floorplans"
|
25
|
-
belongs_to :house
|
26
|
-
belongs_to :owner, :class_name => 'SomethingElse'
|
27
|
-
|
28
|
-
def self.create_with_good_data(attributes={})
|
29
|
-
create!({:location => "a", :email => "a@b.c", :name => "Junior"}.merge(attributes))
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# Blah == anything, whatever. Always passes an equality test
|
35
|
-
|
36
|
-
class Blah
|
37
|
-
def ==(o) true; end
|
38
|
-
def inspect; "<blah>"; end
|
39
|
-
alias :to_s :inspect
|
40
|
-
end
|
41
|
-
|
42
|
-
class Object
|
43
|
-
def blah; Blah.new; end
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# Riot setup
|
48
|
-
|
49
|
-
require 'riot/rails'
|
50
|
-
require 'riot/active_record'
|
51
|
-
require 'riot/action_controller'
|
52
|
-
|
53
|
-
Riot.dots if ENV["TM_MODE"]
|
54
|
-
|
55
|
-
module RiotRails
|
56
|
-
module Context
|
57
|
-
def setup_test_context(context_description="test context")
|
58
|
-
setup { Riot::Context.new(context_description) {} }
|
59
|
-
end
|
60
|
-
|
61
|
-
def setup_for_assertion_test(&block)
|
62
|
-
hookup { topic.setup(&block).run(@situation) }
|
63
|
-
end
|
64
|
-
|
65
|
-
def hookup_for_assertion_test(&block)
|
66
|
-
hookup { topic.hookup(&block).run(@situation) }
|
67
|
-
end
|
68
|
-
|
69
|
-
def assertion_test_passes(description, success_message="", &block)
|
70
|
-
should("pass #{description}") do
|
71
|
-
instance_eval(&block).run(@situation)
|
72
|
-
end.equals([:pass, success_message])
|
73
|
-
end
|
74
|
-
|
75
|
-
def assertion_test_fails(description, failure_message, &block)
|
76
|
-
should("fail #{description}") do
|
77
|
-
instance_eval(&block).run(@situation)
|
78
|
-
end.equals([:fail, failure_message, blah, blah])
|
79
|
-
end
|
80
|
-
|
81
|
-
end # Context
|
82
|
-
end # RiotRails
|
83
|
-
|
84
|
-
Riot::Context.instance_eval { include RiotRails::Context }
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'teststrap'
|
2
|
-
|
3
|
-
context "Transactional middleware" do
|
4
|
-
hookup do
|
5
|
-
ActiveRecord::Base.instance_eval do
|
6
|
-
# Hijacking transaction and just letting stuff fall through
|
7
|
-
def transaction(&block) yield; end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
context "when :transactional is not set" do
|
12
|
-
setup { Riot::Context.new("Room") {} }
|
13
|
-
|
14
|
-
asserts("executing context does not raise errors") do
|
15
|
-
topic.local_run(Riot::SilentReporter.new, Riot::Situation.new)
|
16
|
-
end
|
17
|
-
end # when :transactional is not set
|
18
|
-
|
19
|
-
context "when :transactional is set to true" do
|
20
|
-
setup { Riot::Context.new("Room") { set(:transactional, true) } }
|
21
|
-
|
22
|
-
asserts("executing context") do
|
23
|
-
topic.local_run(Riot::SilentReporter.new, Riot::Situation.new)
|
24
|
-
end.raises(ActiveRecord::Rollback)
|
25
|
-
end # when :transactional is set to true
|
26
|
-
end # Transactional middleware
|