1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00
draper/spec/integration/integration_spec.rb
Andrew Haines cef5e628be Integration tests for all environments
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.
2012-11-12 19:59:43 +00:00

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