Skip to content

Instantly share code, notes, and snippets.

@sevos
Created April 7, 2011 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sevos/908551 to your computer and use it in GitHub Desktop.
Save sevos/908551 to your computer and use it in GitHub Desktop.
describe "Activity form" do
let(:user) { Factory(:user) }
before { sign_in user.email, user.password }
describe "entering activity" do
before do
@enter = lambda do |what, duration, project=""|
within("#activity_form") do
fill_in "What?", :with => what
fill_in "How long?", :with => duration
fill_in "Project", :with => project
click_button "Log it"
end
end
end
context "with correct data" do
context "w/o project name" do
it "should save activity with float duration" do
@enter.call("an activity", "1.5")
within("#recent_activities") do
page.should have_content("an activity")
page.should have_content("1.50 (1:30)")
end
end
it "should save activity with duration in format 0:00" do
@enter.call("an activity", "2:40")
within("#recent_activities") do
page.should have_content("an activity")
page.should have_content("2.67 (2:40)")
end
end
end
context "with project name" do
it "create a project" do
@enter.call("an activity", "1.5", "test project")
Project.where(:name => "test project").should exist
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment