# spec/features/*.rbfeature'Signing in'dogiven(:something){"hi"}backgrounddoUser.makeemail: 'hi@gmail.com'endscenario'Signing in with credentials'doendend
Helpers
# spec/helpers/*.rbdescribeEventsHelperdodescribe"#link_to_event"doit"displays the title, and formatted date"doevent=Event.new("Ruby Kaigi",Date.new(2010,8,27))# helper is an instance of ActionView::Base configured with the# EventsHelper and all of Rails' built-in helpersexpect(helper.link_to_event).tomatch/Ruby Kaigi, 27 Aug, 2010/endendend
Routing
# spec/routing/*.rbdescribe"routing to profiles"doit"routes /profile/:username to profile#show for username"doexpect(get: "/profiles/jsmith").toroute_to(controller: "profiles",action: "show",username: "jsmith")endit"does not expose a list of profiles"doexpect(get: "/profiles").not_tobe_routableendend
Request
#spec/requests/*.rb
describe "home page" do
it "displays the user's username after successful login" do
get "/login"
post "/login", username: "jdoe", password: "secret"
expect(response.status).to eql 200
expect(response).to redirect_to(...)
expect(response).to render_template(:show)
expect(response.body).to include 'hello'
follow_redirect!
end
end
Top comments (0)