Commit c39da75
Changed files (2)
spec
features
support
pages
spec/features/items_spec.rb
@@ -7,12 +7,17 @@ feature "items", type: :feature do
let!(:item) { create(:item, user: user) }
before :each do
- subject.login_with(user.username, 'password')
+ subject.login_with(user.username, "password")
subject.visit_page
end
it "loads a list of items" do
expect(page).to have_content(item.name)
end
+
+ it "can start to add a new item" do
+ subject.add_item("new item")
+ expect(page.find("#item_name")).to have_val("new item")
+ end
end
end
spec/support/pages/items_page.rb
@@ -4,4 +4,11 @@ class ItemsPage < PageModel
def initialize
super dashboard_path
end
+
+ def add_item(item_name)
+ within "#new_item" do
+ fill_in I18n.translate("items.index.item_name"), with: item_name
+ click_button I18n.translate("items.index.new_item_button")
+ end
+ end
end