Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 65 lines (45 sloc) 1.373 kb
5d5467a @zzak init
zzak authored
1 Features from Cucumber and Webrat
2 ---------------------------------
3
4
5 **A Feature Example**
6
7 Feature: View my page
8 In order for visitors to feel welcome
9 We must go out of our way
10 With a kind greeting
11
12 Scenario: My page
13 Given I am viewing my page
14 Then I should see "Welcome to my page!"
15
16 **Step to it**
17
18 Given /^I am viewing my page$/ do
19 visit('/')
20 end
21
22 Then /^I should see "([^"]*)"$/ do |text|
23 last_response.body.should match(/#{text}/m)
24 end
25
26 **env.rb**
27
28 ENV['RACK_ENV'] = 'test'
29
30 require 'rubygems'
31 require 'rack/test'
32 require 'rspec/expectations'
33 require 'webrat'
34
35 begin
36 require_relative '../../my-app.rb'
37 rescue NameError
38 require File.expand_path('../../my-app.rb', __FILE__)
39 end
40
41 Webrat.configure do |config|
42 config.mode = :rack
43 end
44
45 class WebratMixinExample
46 include Rack::Test::Methods
47 include Webrat::Methods
48 include Webrat::Matchers
49
50 Webrat::Methods.delegate_to_session :response_code, :response_body
51
52 def app
53 Sinatra::Application
54 end
55 end
56
57 World{WebratMixinExample.new}
58
59 **Cucumber Resources**
60
61 * [Cucumber Homepage](http://cukes.info/)
62 * [Source on github](https://github.com/aslakhellesoy/cucumber)
63 * [Documentation](https://github.com/aslakhellesoy/cucumber/wiki/)
64
Something went wrong with that request. Please try again.