Skip to content

Commit

Permalink
Tweaks to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Kleppmann committed Oct 17, 2009
1 parent d2fb758 commit bf8cac6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions features/customer-signup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Story: New customer signup
And he enters 'ab48d' as invitation code
And he clicks submit
Then he should be on subdomain blah at 'users/new'
Then he should see a <form> containing a textfield: 'Your email address', password: 'Your new password', password: 'Confirm your password', textfield: 'Company name (optional)', submit: 'Set up account'
Then he should see a <form> containing a textfield: 'Your email address', password: 'Your new password', password: 'Confirm your password', textfield: 'Company name', submit: 'Set up account'
When he enters 'newuser@example.com' as email
And he enters 'asdfasdf' as password
And he enters 'asdfasdf' as password_confirmation
Expand Down Expand Up @@ -79,4 +79,4 @@ Story: New customer signup
And he enters 'blah' as subdomain
And he clicks submit
Then he should be on subdomain blah at 'users/new'
Then he should see a <form> containing a textfield: 'Your email address', password: 'Your new password', password: 'Confirm your password', textfield: 'Company name (optional)', submit: 'Set up account'
Then he should see a <form> containing a textfield: 'Your email address', password: 'Your new password', password: 'Confirm your password', textfield: 'Company name', submit: 'Set up account'
9 changes: 5 additions & 4 deletions features/step_definitions/ra_response_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@
response.should have_tag(container) do
attributes.each do |tag, label|
case tag
when "textfield" then with_tag "input[type='text']"; with_tag("label", label)
when "password" then with_tag "input[type='password']"; with_tag("label", label)
when "submit" then with_tag "input[type='submit'][value='#{label}']"
when "textfield" then with_tag "input[type='text']"; with_tag("label", label)
when "password" then with_tag "input[type='password']"; with_tag("label", label)
when "radiobutton" then with_tag "input[type='radio']"; with_tag("label", label)
when "submit" then with_tag "input[type='submit'][value='#{label}']"
else with_tag tag, label
end
end
Expand Down Expand Up @@ -117,8 +118,8 @@

Then /^s?he should see a validation error '(.*)'/ do |message|
response.should have_tag(".formError", :text => message)

end

Then /^s?he should see an? (\w+) message '(.*)'$/ do |notice, message|
response.should have_flash(notice, %r{#{message}})
end
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/user_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def create_user!(params)
select sel
end

When "$actor chooses (.*)" do |_, sel|
choose sel
end

#
# Result
#
Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/customers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def arr.count

it "should pass parameters onto the model" do
CustomerSignup.should_receive(:new).with(@params).and_return(@signup)
@signup.should_receive(:has_invitation).any_number_of_times.and_return(1)
@signup.should_receive(:valid?).and_return(true)
post :new, :customer_signup => @params
# FIXME: persuade rspec to somehow understand routing...
Expand All @@ -93,6 +94,7 @@ def arr.count

it "should redisplay the page on error" do
CustomerSignup.should_receive(:new).with(@params).and_return(@signup)
@signup.should_receive(:has_invitation).any_number_of_times.and_return(0)
@signup.should_receive(:valid?).any_number_of_times.and_return(false)
post :new, :customer_signup => @params
response.should render_template("customers/new.erb")
Expand Down

0 comments on commit bf8cac6

Please sign in to comment.