Skip to content

Commit a24de0e

Browse files
author
Rahoul Baruah
committed
basic cucumber story added for adding a comment
1 parent 8c34ff3 commit a24de0e

File tree

7 files changed

+88
-21
lines changed

7 files changed

+88
-21
lines changed

config/database.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
# SQLite version 3.x
2-
# gem install sqlite3-ruby (not necessary on OS X Leopard)
31
development:
42
adapter: sqlite3
53
database: db/development.sqlite3
64
pool: 5
75
timeout: 5000
86

9-
# Warning: The database defined as "test" will be erased and
10-
# re-generated from your development database when you run "rake".
11-
# Do not set this db to the same as development or production.
127
test:
138
adapter: sqlite3
149
database: db/test.sqlite3
1510
pool: 5
1611
timeout: 5000
1712

13+
selenium:
14+
adapter: sqlite3
15+
database: db/test.sqlite3
16+
pool: 5
17+
timeout: 5000
18+
1819
production:
1920
adapter: sqlite3
2021
database: db/production.sqlite3

features/adding-a-comment.feature

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Feature: adding a comment
2+
3+
As a Ruby developer
4+
I would like to comment on a gem
5+
So that I can help the community track which gems work with Ruby 1.9
6+
7+
Scenario: adding a comment
8+
9+
Given a gem called "rubynuts"
10+
11+
When I visit the page for "rubynuts"
12+
Then I see the comment form
13+
14+
When I add a comment
15+
And I press "submit comment"
16+
Then I see my comment on the page
17+
18+
Scenario: adding a comment and then editing it
19+
20+
Scenario: viewing someone else's comment
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Given /^a gem called "(.*)"$/ do | name |
2+
code = Code.find_by_name name
3+
code.destroy unless code.nil?
4+
code = a_saved Code, :name => name
5+
end
6+
7+
When /^I visit the page for "(.*)"$/ do | name |
8+
visit "/#{name}"
9+
end
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Then /^I see the comment form$/ do
2+
response.should have_tag('div#new-comment-form')
3+
end
4+
5+
When /^I add a comment$/ do
6+
fill_in "Name", :with => 'Henry the Tester'
7+
fill_in "Email", :with => '[email protected]'
8+
choose :comment_works_for_me_true
9+
fill_in "Version", :with => '1.0'
10+
fill_in "Platform", :with => 'Mac OSX'
11+
fill_in :comment_body, :with => 'Here is my test comment' # have to request via ID rather than label because of the span around the optional, making it hard to find
12+
end
13+
14+
Then /^I see my comment on the page$/ do
15+
response.should include_text('Here is my test comment')
16+
end
17+
18+

features/step_definitions/webrat_steps.rb

+14-14
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
require 'webrat' if !defined?(Webrat) # Because some people have it installed as a Gem
55

66
When /^I press "(.*)"$/ do |button|
7-
clicks_button(button)
7+
click_button(button)
88
end
99

1010
When /^I follow "(.*)"$/ do |link|
11-
clicks_link(link)
11+
click_link(link)
1212
end
1313

1414
When /^I fill in "(.*)" with "(.*)"$/ do |field, value|
15-
fills_in(field, :with => value)
15+
fill_in(field, :with => value)
1616
end
1717

1818
When /^I select "(.*)" from "(.*)"$/ do |value, field|
19-
selects(value, :from => field)
19+
select(value, :from => field)
2020
end
2121

2222
# Use this step in conjunction with Rail's datetime_select helper. For example:
2323
# When I select "December 25, 2008 10:00" as the date and time
2424
When /^I select "(.*)" as the date and time$/ do |time|
25-
selects_datetime(time)
25+
select_datetime(time)
2626
end
2727

2828
# Use this step when using multiple datetime_select helpers on a page or
@@ -35,51 +35,51 @@
3535
# When I select "November 23, 2004 11:20" as the "Preferred" data and time
3636
# And I select "November 25, 2004 10:30" as the "Alternative" data and time
3737
When /^I select "(.*)" as the "(.*)" date and time$/ do |datetime, datetime_label|
38-
selects_datetime(datetime, :from => datetime_label)
38+
select_datetime(datetime, :from => datetime_label)
3939
end
4040

4141
# Use this step in conjuction with Rail's time_select helper. For example:
4242
# When I select "2:20PM" as the time
4343
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
4444
# will convert the 2:20PM to 14:20 and then select it.
4545
When /^I select "(.*)" as the time$/ do |time|
46-
selects_time(time)
46+
select_time(time)
4747
end
4848

4949
# Use this step when using multiple time_select helpers on a page or you want to
5050
# specify the name of the time on the form. For example:
5151
# When I select "7:30AM" as the "Gym" time
5252
When /^I select "(.*)" as the "(.*)" time$/ do |time, time_label|
53-
selects_time(time, :from => time_label)
53+
select_time(time, :from => time_label)
5454
end
5555

5656
# Use this step in conjuction with Rail's date_select helper. For example:
5757
# When I select "February 20, 1981" as the date
5858
When /^I select "(.*)" as the date$/ do |date|
59-
selects_date(date)
59+
select_date(date)
6060
end
6161

6262
# Use this step when using multiple date_select helpers on one page or
6363
# you want to specify the name of the date on the form. For example:
6464
# When I select "April 26, 1982" as the "Date of Birth" date
6565
When /^I select "(.*)" as the "(.*)" date$/ do |date, date_label|
66-
selects_date(date, :from => date_label)
66+
select_date(date, :from => date_label)
6767
end
6868

6969
When /^I check "(.*)"$/ do |field|
70-
checks(field)
70+
check(field)
7171
end
7272

7373
When /^I uncheck "(.*)"$/ do |field|
74-
unchecks(field)
74+
uncheck(field)
7575
end
7676

7777
When /^I choose "(.*)"$/ do |field|
78-
chooses(field)
78+
choose(field)
7979
end
8080

8181
When /^I attach the file at "(.*)" to "(.*)" $/ do |path, field|
82-
attaches_file(field, path)
82+
attach_file(field, path)
8383
end
8484

8585
Then /^I should see "(.*)"$/ do |text|

features/support/env.rb

+17-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
44
require 'cucumber/rails/world'
55
Cucumber::Rails.use_transactional_fixtures
6-
7-
# Comment out the next line if you're not using RSpec's matchers (should / should_not) in your steps.
86
require 'cucumber/rails/rspec'
7+
require 'webrat/rails'
8+
require 'object_factory'
9+
require 'lib/object_factory_config'
10+
require 'mocha'
11+
12+
prepare_object_factory
13+
14+
#`rm log/selenium.log`
15+
16+
Webrat.configure do | config |
17+
config.mode = :rails
18+
#config.mode = :selenium
19+
end
20+
21+
Before do
22+
ActionMailer::Base.deliveries.clear
23+
end

lib/object_factory_config.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def prepare_object_factory
2+
when_creating_a Code, :auto_generate => :name
3+
4+
end

0 commit comments

Comments
 (0)