2011-09-20 19:21:38 +02:00
|
|
|
Given /^a clean server$/ do
|
2011-11-18 22:38:18 +01:00
|
|
|
@initialize_commands = []
|
2011-09-20 19:21:38 +02:00
|
|
|
end
|
|
|
|
|
2009-11-23 00:37:11 +01:00
|
|
|
Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
|
2011-11-18 22:38:18 +01:00
|
|
|
@initialize_commands ||= []
|
2011-09-20 19:21:38 +02:00
|
|
|
|
2011-07-24 07:49:32 +02:00
|
|
|
if state == "enabled"
|
2011-11-18 22:38:18 +01:00
|
|
|
@initialize_commands << lambda { activate(feature.to_sym) }
|
|
|
|
end
|
2011-07-24 07:49:32 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
Given /^"([^\"]*)" is set to "([^\"]*)"$/ do |variable, value|
|
2011-11-18 22:38:18 +01:00
|
|
|
@initialize_commands ||= []
|
|
|
|
@initialize_commands << lambda { set(variable.to_sym, value) }
|
2009-11-23 00:37:11 +01:00
|
|
|
end
|
|
|
|
|
2011-05-29 17:26:58 +02:00
|
|
|
Given /^current environment is "([^\"]*)"$/ do |env|
|
|
|
|
@current_env = env.to_sym
|
|
|
|
end
|
|
|
|
|
2011-07-28 04:59:38 +02:00
|
|
|
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
|
2011-11-18 22:38:18 +01:00
|
|
|
root_dir = File.dirname(File.dirname(File.dirname(__FILE__)))
|
|
|
|
|
|
|
|
initialize_commands = @initialize_commands || []
|
|
|
|
initialize_commands.unshift lambda {
|
|
|
|
set :root, File.join(root_dir, "fixtures", app_path)
|
|
|
|
set :environment, @current_env || :development
|
|
|
|
}
|
|
|
|
|
|
|
|
@server_inst = Middleman.server.inst do
|
|
|
|
initialize_commands.each do |p|
|
|
|
|
instance_exec(&p)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
app_rack = @server_inst.class.to_rack_app
|
|
|
|
@browser = ::Rack::Test::Session.new(::Rack::MockSession.new(app_rack))
|
2009-11-30 20:32:02 +01:00
|
|
|
end
|
|
|
|
|
2009-11-23 00:37:11 +01:00
|
|
|
When /^I go to "([^\"]*)"$/ do |url|
|
|
|
|
@browser.get(url)
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^I should see "([^\"]*)"$/ do |expected|
|
|
|
|
@browser.last_response.body.should include(expected)
|
|
|
|
end
|
2011-04-25 22:45:54 +02:00
|
|
|
|
2010-09-06 19:59:51 +02:00
|
|
|
Then /^I should see '([^\']*)'$/ do |expected|
|
|
|
|
@browser.last_response.body.should include(expected)
|
|
|
|
end
|
2009-11-23 00:37:11 +01:00
|
|
|
|
|
|
|
Then /^I should not see "([^\"]*)"$/ do |expected|
|
|
|
|
@browser.last_response.body.should_not include(expected)
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
|
|
|
@browser.last_response.body.chomp.split($/).length.should == lines.to_i
|
|
|
|
end
|