Module: Charming::Generators::AppGenerator::ScreenSpecTemplates
- Included in:
- Charming::Generators::AppGenerator, ScreenGenerator
- Defined in:
- lib/charming/generators/app_generator/screen_spec_templates.rb
Instance Method Summary collapse
Instance Method Details
#spec_controller ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/charming/generators/app_generator/screen_spec_templates.rb', line 28 def spec_controller %(# frozen_string_literal: true require "#{app_name.snake_name}" RSpec.describe #{app_name.class_name}::#{name.controller_class_name} do let(:application) { #{app_name.class_name}::Application.new } subject(:controller) { described_class.new(application: application) } describe "#show" do it "renders the view with the state" do response = controller.dispatch(:show) expect(response).to respond_to(:body) end end end ) end |
#spec_state ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/charming/generators/app_generator/screen_spec_templates.rb', line 7 def spec_state %(# frozen_string_literal: true require "#{app_name.snake_name}" RSpec.describe #{app_name.class_name}::#{name.class_name}State do describe "#title" do it "has the correct default string value" do instance = described_class.new expect(instance.title).to eq("#{name.class_name}") end it "accepts overridden title values" do instance = described_class.new(title: "Alternative") expect(instance.title).to eq("Alternative") end end end ) end |
#spec_view ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/charming/generators/app_generator/screen_spec_templates.rb', line 49 def spec_view %(# frozen_string_literal: true require "#{app_name.snake_name}" RSpec.describe "#{name.snake_name}/show template" do describe "#render" do it "renders the state title" do template = Charming::Presentation::Templates.resolve("#{name.snake_name}/show", root: #{app_name.class_name}::Application.root) view = Charming::Presentation::TemplateView.new(template: template, #{name.snake_name}: double(title: "#{name.class_name}")) expect(view.render).to eq("#{name.class_name}") end end end ) end |