This commit is contained in:
Andrew Haines 2012-11-16 11:55:34 +00:00
parent 067ecd3153
commit d98f623938
2 changed files with 20 additions and 33 deletions

View File

@ -6,5 +6,4 @@ rvm:
- ruby-head
matrix:
allow_failures:
- rvm: rbx-19mode
- rvm: ruby-head

View File

@ -2,44 +2,32 @@ require 'spec_helper'
require 'support/dummy_app'
require 'support/matchers/have_text'
shared_examples_for "a decorator in a view" do
it "works" do
# it runs in the correct environment
page.should have_text(environment).in("#environment")
app = DummyApp.new(ENV["RAILS_ENV"])
# it can use path helpers with a model
page.should have_text("/en/posts/1").in("#path_with_model")
app.start_server do
{view: "/posts/1", mailer: "/posts/1/mail"}.each do |type, path|
page = app.get(path)
# it can use path helpers with an id
page.should have_text("/en/posts/1").in("#path_with_id")
# it can use url helpers with a model
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_model")
# it can use url helpers with an id
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_id")
end
end
describe "integration" do
app = DummyApp.new(ENV["RAILS_ENV"])
app.start_server do
describe "in #{app.environment}" do
let(:environment) { app.environment }
context "in a view" do
let(:page) { app.get("/posts/1") }
it_behaves_like "a decorator in a view"
describe "in a #{type}" do
it "runs in the correct environment" do
page.should have_text(app.environment).in("#environment")
end
context "in a mailer" do
let(:page) { app.get("/posts/1/mail") }
it "can use path helpers with a model" do
page.should have_text("/en/posts/1").in("#path_with_model")
end
it_behaves_like "a decorator in a view"
it "can use path helpers with an id" do
page.should have_text("/en/posts/1").in("#path_with_id")
end
it "can use url helpers with a model" do
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_model")
end
it "can use url helpers with an id" do
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_id")
end
end
end
end