middleman/features/step_definitions/middleman_steps.rb

27 lines
1 KiB
Ruby
Raw Normal View History

2009-11-23 00:37:11 +01:00
Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
enable_or_disable = (state == "enabled") ? :enable : :disable
Middleman::Base.send(enable_or_disable, feature.to_sym)
@browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Base.new))
end
2009-11-30 20:32:02 +01:00
Given /^generated directory at "([^\"]*)"$/ do |dirname|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", dirname)
2009-12-04 00:26:05 +01:00
init_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "mm-init"))
2009-11-30 20:32:02 +01:00
`cd #{File.dirname(target)} && #{init_cmd} #{File.basename(target)}`
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
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