test/unit/action/controller_tests.rb in much-rails-0.2.8 vs test/unit/action/controller_tests.rb in much-rails-0.3.0
- old
+ new
@@ -15,22 +15,35 @@
should "include MuchRails::Mixin" do
assert_that(subject).includes(MuchRails::Mixin)
end
- should "know its constants" do
- assert_that(subject::DEFAULT_ACTION_CLASS_FORMAT).equals(:any)
+ should "know its attributes" do
+ assert_that(subject.DEFAULT_ACTION_CLASS_FORMAT).equals(:any)
end
end
class ReceiverTests < UnitTests
desc "receiver"
subject{ receiver_class }
let(:receiver_class) do
Class.new{ include FakeActionController }
end
+
+ should "be configured as expected" do
+ assert_that(subject.prepend_before_action_calls.size).equals(1)
+ assert_that(subject.prepend_before_action_calls.last.args)
+ .equals([
+ :require_much_rails_action_class,
+ only: MuchRails::Action::Router.CONTROLLER_CALL_ACTION_METHOD_NAME,
+ ])
+
+ assert_that(subject.before_action_calls.size).equals(1)
+ assert_that(subject.before_action_calls.last.args)
+ .equals([:permit_all_much_rails_action_params])
+ end
end
class ReceiverInitTests < ReceiverTests
desc "when init"
subject{ receiver_class.new(params1) }
@@ -39,11 +52,11 @@
Assert.stub(::Actions::Show, :format){ nil }
end
let(:params1) do
{
- MuchRails::Action::Router::ACTION_CLASS_PARAM_NAME => "Actions::Show",
+ MuchRails::Action::Router.ACTION_CLASS_PARAM_NAME => "Actions::Show",
controller: "actions",
action: "show",
nested: {
value: "VALUE 1",
},
@@ -51,14 +64,14 @@
end
should have_readers :much_rails_action_class
should have_imeths(
- MuchRails::Action::Router::CONTROLLER_CALL_ACTION_METHOD_NAME,
+ MuchRails::Action::Router.CONTROLLER_CALL_ACTION_METHOD_NAME,
)
should have_imeths(
- MuchRails::Action::Router::CONTROLLER_NOT_FOUND_METHOD_NAME,
+ MuchRails::Action::Router.CONTROLLER_NOT_FOUND_METHOD_NAME,
)
should have_imeths :much_rails_action_class_name
should have_imeths :much_rails_action_class_format
should have_imeths :much_rails_action_params
should have_imeths :require_much_rails_action_class
@@ -67,11 +80,11 @@
should "know its attributes" do
assert_that(subject.much_rails_action_class_name)
.equals("::Actions::Show")
assert_that(subject.much_rails_action_class_format)
- .equals(unit_module::DEFAULT_ACTION_CLASS_FORMAT)
+ .equals(unit_module.DEFAULT_ACTION_CLASS_FORMAT)
assert_that(subject.much_rails_action_params)
.equals(
nested: { value: "VALUE 1" },
value: "VALUE 1",
@@ -89,10 +102,10 @@
desc "when init with an unknown action class"
subject{ receiver_class.new(params1) }
let(:params1) do
{
- MuchRails::Action::Router::ACTION_CLASS_PARAM_NAME =>
+ MuchRails::Action::Router.ACTION_CLASS_PARAM_NAME =>
"Actions::Unknown",
}
end
should "return not found when not raising response exceptions" do