middleman/features/step_definitions/middleman_steps.rb

55 lines
1.5 KiB
Ruby
Raw Normal View History

2011-09-20 19:21:38 +02:00
Given /^a clean server$/ do
@server = Middleman.server
@server.set :show_exceptions, false
end
2009-11-23 00:37:11 +01:00
Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
2011-09-20 19:21:38 +02:00
@server = Middleman.server
@server.set :show_exceptions, false
2011-09-20 19:21:38 +02:00
if state == "enabled"
@server.activate(feature.to_sym)
2011-09-20 19:21:38 +02:00
end
@server.set :environment, @current_env || :development
end
Given /^"([^\"]*)" is set to "([^\"]*)"$/ do |variable, value|
@server ||= Middleman.server
@server.set :show_exceptions, false
@server.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
Given /^the Server is running at "([^\"]*)"$/ do |app_path|
@server ||= Middleman.server
@server.set :show_exceptions, false
root = File.dirname(File.dirname(File.dirname(__FILE__)))
@server.set :root, File.join(root, "fixtures", app_path)
@app = @server.new!
app_rack = @server.build_new(@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
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