describe "Rails development-mode support", :type => :rails do
uses_rails_with_template :development_mode_system_spec, :rails_env => :development
it "should automatically reload widgets if they change on disk" do
expect_match("reload_widget", /before_reload/)
# The sleep is unfortunate, but required: without it, Rails will not necessarily pick up our change,
# especially if we run multiple tests back-to-back. (There's a maximum frequency at which Rails can
# detect distinct file changes on disk, which on the order of 1 Hz -- i.e., once a second; any more
# than this and it fails. This is irrelevant for human-centered development, but important for
# tests like this.)
sleep 1
splat_new_widget!
expect_match("reload_widget", /after_reload/)
end
it "should automatically reload widgets if related files change on disk, even if they're named '.html.rb' at the end" do
expect_match("reload_widget_with_html_extension", /with_html_extension.*helper: yo/)
sleep 1
splat_new_module_for_reload_widget_failing!
expect_exception("reload_widget_with_html_extension", NameError, "some_helper")
sleep 1
splat_new_module_for_reload_widget!
expect_match("reload_widget_with_html_extension", /with_html_extension.*helper: yo/)
end
it "should let you change the controller, and that should work fine, too" do
expect(rails_server.get("replaced/reload_widget")).to match(/datum\s+one\s+datum/)
sleep 1
splat_new_controller!
expect(rails_server.get("replaced/reload_widget")).to match(/datum\s+two\s+datum/)
end
it "should, by default, format output" do
expect_match("sample_output", %r{ hello, Jessica
this is the basic mail!
}mi) clear_mails! sleep 1 splat_new_mailer_view! expect_match("mailer_view_test", /mail sent/i) mail = mail_sent_to('mailer_view_test@example.com') expect(mail[:body].strip).to match(%r{this is the NEW basic mail!
}mi) end it "should pick up changes to mailer layouts" do expect_match("mailer_layout_test", /mail sent/i) mail = mail_sent_to('mailer_layout_test@example.com') expect(mail[:body].strip).to match(%r{this is the layout, before.*this is the basic mail!.*this is the layout, after}mi) clear_mails! sleep 1 splat_new_mailer_layout! expect_match("mailer_layout_test", /mail sent/i) mail = mail_sent_to('mailer_layout_test@example.com') expect(mail[:body].strip).to match(%r{this is the NEW layout, before.*this is the basic mail!.*this is the NEW layout, after}mi) end it "should format output and output BEGIN/END debugging tags in mailers" do expect_match("mailer_formatting_test", /mail sent/i) mail = mail_sent_to('mailer_formatting_test@example.com') expect(mail[:body].strip).to eq(%{this is the text!