mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
cef5e628be
The problem with using Cucumber is that it runs the dummy app in the test environment. Because the view context behaviour is dependent on environment, we need to test it running on an actual server.
49 lines
1.3 KiB
Ruby
49 lines
1.3 KiB
Ruby
require 'spec_helper'
|
|
require 'support/dummy_app'
|
|
|
|
describe "integration" do
|
|
include Capybara::DSL
|
|
|
|
environment = ENV["RAILS_ENV"].to_s
|
|
raise ArgumentError, "RAILS_ENV must be development or production" unless ["development", "production"].include?(environment)
|
|
|
|
app = DummyApp.new(environment)
|
|
|
|
app.start_server do
|
|
describe "in #{environment}" do
|
|
before { Capybara.app_host = app.url }
|
|
|
|
it "runs in the correct environment" do
|
|
visit("/posts/1")
|
|
page.should have_css "#environment", text: environment
|
|
end
|
|
|
|
it "decorates" do
|
|
visit("/posts/1")
|
|
page.should have_content "Today"
|
|
end
|
|
|
|
it "can use path helpers with a model" do
|
|
visit("/posts/1")
|
|
page.should have_css "#path_with_model", text: "/en/posts/1"
|
|
end
|
|
|
|
it "can use path helpers with an id" do
|
|
visit("/posts/1")
|
|
page.should have_css "#path_with_id", text: "/en/posts/1"
|
|
end
|
|
|
|
it "can use url helpers with a model" do
|
|
visit("/posts/1")
|
|
page.should have_css "#url_with_model", text: "http://www.example.com/en/posts/1"
|
|
end
|
|
|
|
it "can use url helpers with an id" do
|
|
visit("/posts/1")
|
|
page.should have_css "#url_with_id", text: "http://www.example.com/en/posts/1"
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
end
|