test/server_test.rb in copy-0.0.41 vs test/server_test.rb in copy-0.1.0
- old
+ new
@@ -110,10 +110,16 @@
get 'with_copy_helper_one_line'
assert last_response.ok?
assert_match %Q(<span class="_copy_editable" data-name="headline">Important!</span>), last_response.body
end
+
+ test "partial rendering" do
+ get 'renders_partials'
+ assert last_response.ok?, last_response.errors
+ assert_match "before\none\ntwo\nthree\nafter", last_response.body
+ end
end
class ServerAdminTest < Test::Unit::TestCase
include CopyAppSetup
include Rack::Test::Methods
@@ -144,15 +150,21 @@
assert_match 'jQuery JavaScript Library', last_response.body
end
test "GET /_copy/:name" do
Copy::Storage.stubs(:connected?).returns(true)
- Copy::Storage.expects(:get).with('fun').returns('party')
+ Copy::Storage.expects(:get).with('fun').returns('"party"')
authorize!
get '/_copy/fun'
assert last_response.ok?, last_response.errors
- assert_match "party</textarea>", last_response.body
+ # Single line content renders in a text field
+ assert_match 'value=""party""', last_response.body
+
+ # Multiline renders in a textarea
+ Copy::Storage.expects(:get).with('fun').returns("<b>party\n")
+ get '/_copy/fun'
+ assert_match "<b>party\n</textarea>", last_response.body
end
test "PUT /_copy/:name" do
Copy::Storage.stubs(:connected?).returns(true)
Copy::Storage.expects(:set).with('fun', '_party_').returns(true)
\ No newline at end of file