Permalink
Browse files

added login to each spec

  • Loading branch information...
1 parent cc3633a commit b6b200591a46c7440941073937f3118a4b743725 @mattetti committed Nov 15, 2008
Showing with 14 additions and 6 deletions.
  1. +14 −6 step-by-step-app-testing/steps/authenticated_articles_route_spec.rb
@@ -16,20 +16,28 @@ def authenticated_articles_route_spec
<<-RUBY
given "a article exists" do
Article.all.destroy!
- User.all.detroy!
- u = User.new(:login => "mattetti")
- u.password = u.password_confirmation = "sekrit"
- u.save
- request("/login", :method => "put", :params => {"login" => "mattetti", "password" => "sekrit"})
+ login
request(resource(:articles), :method => "POST",
:params => { :article => {:title => 'intro', :author => 'Matt', :created_at => '2008-11-07 10:07:12' }})
end
RUBY
end
-
+
+ add_login_to_before_filter
add_login_spec_helpers
end
+ def add_login_to_before_filter
+ matcher = /before\(:each\) do\n*(.*?end)/mi
+ gsub_file "#{path}/spec/requests/articles_spec.rb", matcher do |matched_str|
+<<-RUBY
+before(:each) do
+ login
+ #{matched_str.match(matcher).captures.first.strip}
+RUBY
+ end
+ end
+
def add_login_spec_helpers
test_helpers = <<-RUBY

0 comments on commit b6b2005

Please sign in to comment.