Skip to content

Commit

Permalink
capybara
Browse files Browse the repository at this point in the history
  • Loading branch information
harshashinde committed Feb 21, 2012
1 parent 62555d3 commit e4b571c
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Guardfile
@@ -0,0 +1,19 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }

# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end

35 changes: 35 additions & 0 deletions lib/beta_invite/feature.rb
@@ -0,0 +1,35 @@
module BetaInvite

class Feature

attr_reader :path

def initialize(path)
@path = path
end

def name
self.source[/^Feature: (.+)$/, 1] || name_lines.first.split(':', 2).second.strip
end

def to_param
relative_path.sub(/^\//, '').sub(/\.feature$/, '')
end

def source
File.read(@path).to_s
end

def ==(other)
to_param == other.to_param
end

private

def relative_path
File.expand_path(path).sub(Courgette.feature_root, '')
end

end

end
3 changes: 3 additions & 0 deletions spec/factories.rb
@@ -0,0 +1,3 @@
FactoryGirl.define :beta_invite do |f|
f.sequence(:email) {|n| "foo#{n}@example.com"}
end
17 changes: 17 additions & 0 deletions spec/requests/send_beta_invite_spec.rb
@@ -0,0 +1,17 @@
require 'spec_helper'

include Capybara::DSL
describe "Task" do
describe "SendBetaInvite" do
it "saves users email for the beta invitation" do
#beta_invite = FactoryGirl.build(:beta_invite)
visit '/'
#click_link "password"
fill_in "beta_invite[recipient_email]", :with => "crap123@gmail.com"
click_button "Get Invited"
current_path.should eq(root_path)
page.should have_content("Thank you for signing up with us. We will keep you updated.")
#last_email.to.should include(user.email)
end
end
end
7 changes: 7 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,7 @@
require 'capybara/rails'

RSpec.configure do |config|
# ...
#config.include(MailerMacros)
#config.before(:each) { reset_email }
end

0 comments on commit e4b571c

Please sign in to comment.