2012-11-12 02:01:49 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'support/dummy_app'
|
2012-11-16 05:11:53 -05:00
|
|
|
require 'support/matchers/have_text'
|
2012-11-12 02:01:49 -05:00
|
|
|
|
2012-11-13 15:28:15 -05:00
|
|
|
shared_examples_for "a decorator in a view" do
|
|
|
|
it "works" do
|
|
|
|
# it runs in the correct environment
|
2012-11-16 05:11:53 -05:00
|
|
|
page.should have_text(environment).in("#environment")
|
2012-11-13 15:28:15 -05:00
|
|
|
|
|
|
|
# it can use path helpers with a model
|
2012-11-16 05:11:53 -05:00
|
|
|
page.should have_text("/en/posts/1").in("#path_with_model")
|
2012-11-13 15:28:15 -05:00
|
|
|
|
|
|
|
# it can use path helpers with an id
|
2012-11-16 05:11:53 -05:00
|
|
|
page.should have_text("/en/posts/1").in("#path_with_id")
|
2012-11-13 15:28:15 -05:00
|
|
|
|
|
|
|
# it can use url helpers with a model
|
2012-11-16 05:11:53 -05:00
|
|
|
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_model")
|
2012-11-13 15:28:15 -05:00
|
|
|
|
|
|
|
# it can use url helpers with an id
|
2012-11-16 05:11:53 -05:00
|
|
|
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_id")
|
2012-11-13 15:28:15 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-12 02:01:49 -05:00
|
|
|
describe "integration" do
|
2012-11-16 05:34:10 -05:00
|
|
|
app = DummyApp.new(ENV["RAILS_ENV"])
|
2012-11-12 02:01:49 -05:00
|
|
|
|
|
|
|
app.start_server do
|
2012-11-16 05:34:10 -05:00
|
|
|
describe "in #{app.environment}" do
|
|
|
|
let(:environment) { app.environment }
|
2012-11-12 02:01:49 -05:00
|
|
|
|
2012-11-13 15:28:15 -05:00
|
|
|
context "in a view" do
|
2012-11-16 05:34:10 -05:00
|
|
|
let(:page) { app.get("/posts/1") }
|
2012-11-12 02:01:49 -05:00
|
|
|
|
2012-11-13 15:28:15 -05:00
|
|
|
it_behaves_like "a decorator in a view"
|
2012-11-12 02:01:49 -05:00
|
|
|
end
|
|
|
|
|
2012-11-13 15:28:15 -05:00
|
|
|
context "in a mailer" do
|
2012-11-16 05:34:10 -05:00
|
|
|
let(:page) { app.get("/posts/1/mail") }
|
2012-11-12 02:01:49 -05:00
|
|
|
|
2012-11-13 15:28:15 -05:00
|
|
|
it_behaves_like "a decorator in a view"
|
2012-11-12 02:01:49 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|